Skip to main content
The ClinikAPI TypeScript SDK gives you a typed, server-side interface to all 14 FHIR R4 resource types. Install it with npm, configure it with your secret API key, and start reading and writing clinical data in minutes.

Install

npm install @clinikapi/sdk

Requirements

  • Node.js 18+ (or any runtime with native fetch support)
  • TypeScript 5+ (recommended, not required)

Quick setup

Import Clinik and instantiate it with your secret API key. Store the key in an environment variable — never hardcode it.
import { Clinik } from '@clinikapi/sdk';

const clinik = new Clinik(process.env.CLINIKAPI_SECRET_KEY!);
The SDK is server-side only. It authenticates with your secret API key — never import it in client-side code or ship it to the browser. For frontend UI, use @clinikapi/react with the proxy pattern.

Configuration options

Pass a second argument to the constructor to override defaults.
const clinik = new Clinik(process.env.CLINIKAPI_SECRET_KEY!, {
  baseUrl: 'https://api.clinikehr.com', // default
  timeout: 30000,                        // request timeout in ms (default: 30s)
  retries: 2,                            // auto-retry on 5xx/429 (default: 2)
});
OptionTypeDefaultDescription
baseUrlstringhttps://api.clinikehr.comAPI base URL
timeoutnumber30000Request timeout in milliseconds
retriesnumber2Max retry attempts on 5xx or 429 responses

Framework examples

'use server';
import { Clinik } from '@clinikapi/sdk';

const clinik = new Clinik(process.env.CLINIKAPI_SECRET_KEY!);

export async function getPatient(id: string) {
  const { data } = await clinik.patients.read(id);
  return data;
}