@neariq/sdk package is the official JavaScript and TypeScript client for the NearIQ API. It wraps every API endpoint in a typed, promise-based interface with zero runtime dependencies beyond the standard fetch API.
TypeScript types are bundled with the package — no separate @types/ package is needed.
Installation
fetch support), or any modern browser runtime.
Initializing the client
Import theNearIQ class and pass your API key. Store the key in an environment variable — never hardcode it.
Constructor options
Your NearIQ API key. Must start with
niq_live_. Generate one in Settings → API Keys.Override the base URL. Useful for testing against a local proxy or staging environment. Trailing slashes are stripped automatically.
Making your first request
Error handling
When the API returns a non-2xx status, the SDK throws an error that extends the built-inError class with two additional properties:
status(number) — the HTTP status codebody(unknown) — the full parsed JSON response body
NearIQError is an interface on Error, not a class, so use 'status' in err rather than instanceof NearIQError to detect it.TypeScript
All request parameter types, response types, and error types are exported from the package. Import them directly for use in your own code:Next steps
- SDK method reference — every method with TypeScript signatures and examples
- API reference overview — raw HTTP endpoints if you prefer not to use the SDK