Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.omophub.com/llms.txt

Use this file to discover all available pages before exploring further.

Prerequisites

Installation

npm install @omophub/omophub-node
The SDK ships as an ESM-only package with bundled .d.ts types. It runs in Node ≥ 22, modern browsers (CORS permitting), and edge runtimes (Cloudflare Workers, Vercel Edge).

Quick Start

import { OMOPHub } from '@omophub/omophub-node';

const client = new OMOPHub('oh_xxxxxxxxx');

// Get a concept
const { data, error } = await client.concepts.get(201826);
if (error) throw new Error(error.message);
console.log(data.concept_name); // "Type 2 diabetes mellitus"

// Search concepts
const results = await client.search.basic('diabetes', { pageSize: 5 });
if (results.error) throw new Error(results.error.message);
for (const concept of results.data.concepts) {
  console.log(`${concept.concept_id}: ${concept.concept_name}`);
}

Errors Are Return Values, Not Exceptions

Every SDK method returns a discriminated { data, error, meta, headers } union. The SDK never throws on network or API errors - narrow with if (error) ... and TypeScript will type data correctly in the success branch.
const { data, error } = await client.concepts.get(999_999_999);
if (error) {
  console.error(error.name, error.message, error.statusCode);
  return;
}
// `data` is now typed as Concept
console.log(data.concept_name);
See Error Handling for the full pattern.

Configuration

const client = new OMOPHub('oh_xxx', {
  baseUrl: 'https://api.omophub.com/v1',
  timeoutMs: 30_000,
  maxRetries: 3,
  vocabVersion: '2025.1',
});
You can also set your API key via environment variable:
export OMOPHUB_API_KEY=oh_xxxxxxxxx
// API key is read from process.env.OMOPHUB_API_KEY
const client = new OMOPHub();
OptionEnv varDefault
apiKey (1st arg)OMOPHUB_API_KEY- (required)
baseUrlOMOPHUB_API_URLhttps://api.omophub.com/v1
timeoutMs-30000 (set to 0 to disable)
maxRetries-3 (set to 0 to disable)
vocabVersion-unset (server picks latest)
userAgent-omophub-node/<version>
fetch-globalThis.fetch

Retries

The client automatically retries 429, 502, 503, 504, and transient network errors with full-jitter exponential backoff (500 ms → 8 s, capped). Retry-After is honoured up to 60 s. POST and PATCH only retry when an Idempotency-Key is set - pass it via { idempotencyKey: '...' } to opt in.

Next Steps

Concepts

Get, batch, and explore concepts

Search

Keyword, semantic, autocomplete

Mappings

Map between vocabularies

Error Handling

Discriminated errors, retries, async iterators