Node SDK
The official Node.js client for the Synthient API: IP lookups, account details, real-time feed streams, and Parquet exports.
Getting started
1. Install
Install
npm add @synthient/synthient
Requires Node.js 22.12 or later. The package is ESM only, and CommonJS code can require() it. It ships its own TypeScript declarations, tested with TypeScript 5.8 and later. The gRPC schema fetcher is a separate entry point, @synthient/synthient/grpcschema, that needs optional peer dependencies.
Other runtimes, such as Bun and Deno, are not tested. The SDK is for server-side code and has no runtime dependencies.
This SDK follows Semantic Versioning. Breaking changes ship only in a new major version. The 1.x versions on npm are an older, deprecated client with a different API.
2. Make your first lookup
Each lookup costs one credit. The examples on these pages use top-level await, which works in ES modules.
import { Synthient } from "@synthient/synthient";
const client = new Synthient();
const info = await client.lookupIP("8.8.8.8");
console.log(info.network?.isp, info.network?.type);
console.log(info.intelligence?.risk_score, info.intelligence?.categories);
new Synthient() reads the API key from the SYNTHIENT_API_KEY environment variable. IPInfo.network, IPInfo.location, and IPInfo.intelligence are absent when the API has no data for that section, so check them before reading their fields.
3. Check your credits
account returns the account that owns the API key, including its scopes and remaining lookup credits. It costs no credits.
const account = await client.account();
const { credits, resets_in } = account.lookup_quota;
console.log(account.email, account.organization.name, account.scopes);
console.log(credits, "credits, resetting in", resets_in, "seconds");
4. Handle errors
Failed requests reject with a SynthientError or one of its subclasses. Check them with instanceof:
import { APIError } from "@synthient/synthient";
try {
await client.lookupIP("8.8.8.8");
} catch (error) {
if (!(error instanceof APIError)) {
throw error;
}
switch (error.status) {
case 402:
console.log("out of lookup credits");
break;
case 429:
if (error.retryAfter === undefined) {
console.log("monthly request budget spent");
} else {
console.log(`rate limited, retry after ${error.retryAfter} ms`);
}
break;
default:
console.log("request", error.requestID, "failed:", error.detail || error.title);
}
}
5. Keep going
- Client: create and configure the client, and read the metadata of every API response.
- Lookups: look up IP addresses and check your account and the API's health.
- Feeds: stream each feed's real-time events and download its hourly and daily Parquet exports.
- Errors and retries: how failed requests are reported, and which requests are retried.
- Types: the fields of every response and event type, and the enumerations they use.
- gRPC schema: fetch the protobuf schema of the Synthient gRPC API.