SDKs

Node / TypeScript SDK

The official TypeScript SDK — typed, retry-safe, and idempotent by default.

The Node SDK wraps the REST API with types, automatic retries, and idempotency handled for you.

Install#

npm install @neolifehealth/sdk

Initialize#

import { Neolife } from "@neolifehealth/sdk";

const neolife = new Neolife({
  apiKey: process.env.NEOLIFE_API_KEY!, // nk_live_… or nk_sandbox_…
});

Submit an order#

const order = await neolife.orders.submit("ord_123");
console.log(order.status); // "submitted"

The SDK derives a stable idempotency key for you, so a retried submit never double-ships. To supply your own:

await neolife.orders.submit("ord_123", { idempotencyKey: "<uuid>" });

Automatic retries#

Transient failures (429, 5xx, network errors) are retried with exponential backoff, reusing one idempotency key across the retries of a mutation — so a retry never acts twice. You can tune it:

const neolife = new Neolife({ apiKey, maxRetries: 4 });

Typed errors#

Failures throw typed errors you can branch on:

import { RateLimitError, NotApprovedError, NeolifeError } from "@neolifehealth/sdk";

try {
  await neolife.orders.submit(orderId);
} catch (err) {
  if (err instanceof RateLimitError) { /* back off */ }
  else if (err instanceof NotApprovedError) { /* needs provider approval */ }
  else if (err instanceof NeolifeError) { console.error(err.code, err.requestId); }
}

Webhooks#

Verify inbound webhook signatures with the SDK — see Webhooks & events.

import { verifyWebhook } from "@neolifehealth/sdk";
const event = verifyWebhook({ payload, headers, secret });

Sandbox vs. live#

The SDK's behavior is identical in both environments — only the key prefix differs. Build against nk_sandbox_… (synthetic patients), then switch the environment variable to go live.