-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Install the SDK, understand the two credentials, configure the client, and make a first call end to end.
npm install @ontomorph/dtp-sdk
# pnpm add @ontomorph/dtp-sdk
# yarn add @ontomorph/dtp-sdk
# bun add @ontomorph/dtp-sdkRuns on Node.js 18+, Bun, Deno, and any modern browser or edge runtime with fetch. No runtime dependencies beyond the bundled HOLON client.
The SDK uses two credentials for two different jobs. For the full model see Concepts.
Identifies your application to the platform. A key beginning dtp_live_ talks to production; dtp_test_ talks to the sandbox. You pass it as apiKey in the constructor, and the SDK sends it as the X-DTP-API-Key header on every twin-core request.
On its own an API key never unlocks patient data. It says who you are, not what you may see.
Get an API key from the developer dashboard.
A signed JWT the patient issues through their consent flow. It authorizes access to exactly one twin, scoped to the body systems and event types they approved. You pass it to dtp.twins.connect(grantToken).
No grant token, no patient data.
Only apiKey is required. Everything else has a default or is needed only for a specific feature.
// client.ts
import { DTP } from "@ontomorph/dtp-sdk";
const dtp = new DTP({
apiKey: process.env.DTP_API_KEY, // required, dtp_live_… or dtp_test_…
});The full option set:
Required. Your DTP API key (dtp_live_… or dtp_test_…). Sent as X-DTP-API-Key on twin requests.
Twin-core endpoint. Defaults to https://api.ontomorph.com.
Identity-consent endpoint used by dtp.keys. Defaults to https://api.ontomorph.com.
A Zitadel user JWT. Required only for dtp.keys.*.
HOLON base URL. Required only for dtp.holon.
HOLON API key (holon_…). Required only for dtp.holon.
Per-request timeout in milliseconds. Defaults to 30000.
// first-call.ts
import { DTP } from "@ontomorph/dtp-sdk";
const dtp = new DTP({ apiKey: process.env.DTP_API_KEY });
// A patient issues you a grant token; connect to their twin with it.
const twin = await dtp.twins.connect(grantToken);
twin.grant.twinId; // the twin this grant authorizes
twin.grant.systems; // e.g. ["cardiovascular"], or null for all
// Read one body system.
const cardio = await twin.systems.get("cardiovascular");
console.log(cardio.events.length, "cardiovascular events");connect decodes the grant locally and returns fast. The token is verified server-side on the first data request (here, systems.get), so the grant claims on twin.grant are available right away.
Next: Guides for each capability, Concepts for the domain model, API-Reference for exact signatures.