Skip to content

API Reference

Fatunmbi Daniel edited this page Jul 24, 2026 · 2 revisions

API Reference

Every export, method, option, return field, and error code. For narrative walkthroughs, see Guides and Use-Cases.

createHolonClient

// create.ts
import { createHolonClient } from "@ontomorph/holon-client";

const holon = createHolonClient({
  apiUrl: "https://holon-api.ontomorph.com",
  apiKey: process.env.HOLON_API_KEY, // holon_…
  timeout: 30_000,
});

createHolonClient(config) returns a HolonClient. It takes one config object.

apiUrl

HOLON API base URL, for example https://holon-api.ontomorph.com. Type string. Required.

apiKey

Your holon_… key, sent as a bearer token in the Authorization: Bearer <apiKey> header on every request. Type string. Required.

timeout

Per-request timeout in milliseconds, applied via AbortSignal.timeout. Type number. Optional.

HolonClient

The object returned by createHolonClient. It exposes five namespaces:

concepts

A ConceptsApi. Search and resolve concepts, and walk the hierarchy.

interactions

An InteractionsApi. Screen drugs for known interactions.

mappings

A MappingsApi. Move a code across vocabularies.

referenceRanges

A ReferenceRangesApi. Read normal ranges for lab tests.

phenotype

A PhenotypeApi. Score similarity between two sets of phenotype terms.

ConceptsApi

getById(conceptId)

await holon.concepts.getById("40213251"); // ConceptResponse

Look up a single concept by its conceptId. Returns a ConceptResponse.

getByCode(code, vocabulary)

await holon.concepts.getByCode("197361", "RxNorm");

Resolve a raw vocabulary code to its concept.

code

The source code, for example "197361".

vocabulary

The vocabulary the code belongs to, for example "RxNorm".

search(query, options?)

await holon.concepts.search("metformin", { domain: "Drug", page: 1, pageSize: 20 });

Search concepts by term. options is optional.

query

The search term.

options.domain

Narrow the search to one domain, for example "Drug".

options.page

The page number to return.

options.pageSize

The number of hits per page.

Returns { hits, total, page, pageSize }.

hits

The array of matching concepts. Each hit carries a conceptId, conceptCode, conceptName, vocabularyId, and domainId.

total

The total number of matches across all pages.

page

The page number returned.

pageSize

The number of hits per page.

getAncestors(conceptId)

await holon.concepts.getAncestors(40213251); // hierarchy up

Return the concepts above this one in the hierarchy.

getDescendants(conceptId)

await holon.concepts.getDescendants(40213251); // hierarchy down

Return the concepts below this one in the hierarchy.

InteractionsApi

getByDrugId(drugId)

await holon.interactions.getByDrugId(11289); // all interactions for a drug

Return every known interaction recorded for a single drug.

check(drugIdA, drugIdB)

await holon.interactions.check(11289, 1191); // → { hasInteraction, interactions }

Pairwise check between two drugs. Returns { hasInteraction, interactions }.

hasInteraction

true when at least one interaction exists between the pair.

interactions

The array of interactions found.

checkList(drugIds)

await holon.interactions.checkList([11289, 1191, 197361]); // whole-list screen

Screen a whole medication list. Takes an array of drug ids and reports interactions within the set.

MappingsApi

getByConceptId(conceptId)

await holon.mappings.getByConceptId(40213251); // all cross-vocab mappings

Return all cross-vocabulary mappings for a concept.

translate(code, sourceVocabulary, targetVocabulary?)

await holon.mappings.translate("197361", "RxNorm", "SNOMED"); // → { source, target, mappings }

Translate a code from one vocabulary into another. Returns { source, target, mappings }.

code

The source code to translate, for example "197361".

sourceVocabulary

The vocabulary the code comes from, for example "RxNorm".

targetVocabulary

The vocabulary to translate into, for example "SNOMED". Optional. Omit it to get mappings into every available vocabulary.

source

The source code and vocabulary echoed back.

target

The target vocabulary of the translation.

mappings

The array of mapping entries produced.

ReferenceRangesApi

getByConceptId(conceptId)

await holon.referenceRanges.getByConceptId(3004249); // by HOLON concept id

Return reference ranges for a HOLON measurement concept.

getByLoincCode(loincCode, age?, sex?)

await holon.referenceRanges.getByLoincCode("2093-3", 45, "male"); // by LOINC, age and sex adjusted

Return reference ranges for a LOINC code, optionally adjusted for a demographic.

loincCode

The LOINC code, for example "2093-3".

age

The patient age. Optional. Supply it to narrow the range.

sex

The patient sex, for example "male". Optional. Supply it to narrow the range.

PhenotypeApi

match(setA, setB)

// Score similarity between two sets of phenotype concept ids.
await holon.phenotype.match([9826, 4245975], [9826, 31967]);

Score how alike two sets of phenotype concept ids are.

setA

The first set of phenotype concept ids.

setB

The second set of phenotype concept ids.

Error handling

A non-2xx response, or a network or timeout failure, throws a HolonError from @ontomorph/holon-types. It carries a machine-readable ErrorCode and the raw response detail.

// error-handling.ts
import { HolonError, ErrorCode } from "@ontomorph/holon-types";

try {
  await holon.concepts.getByCode("bogus", "RxNorm");
} catch (err) {
  if (err instanceof HolonError) {
    console.error(err.code, err.message); // e.g. CONCEPT_NOT_FOUND …
    if (err.code === ErrorCode.RATE_LIMIT_EXCEEDED) backOff();
    // err.details holds { status, body } from the response
  }
}

err.code

The machine-readable ErrorCode for the failure.

err.message

The human-readable message.

err.details

The raw response detail, holding { status, body } from the response.

Common error codes

CONCEPT_NOT_FOUND, VOCABULARY_NOT_FOUND, NO_MAPPING_FOUND, INTERACTION_CHECK_FAILED, UNAUTHORIZED, FORBIDDEN, RATE_LIMIT_EXCEEDED, VALIDATION_ERROR. The full ErrorCode enum lives in @ontomorph/holon-types.

TypeScript types

Response and entity types are exported for you to annotate with:

// types.ts
import type {
  HolonClient,
  ConceptResponse,
  SearchResponse,
  InteractionsResponse,
  MappingEntry,
  ReferenceRangeEntry,
  PhenotypeMatch,
} from "@ontomorph/holon-client";

The lower-level *Api classes (ConceptsApi, InteractionsApi, MappingsApi, ReferenceRangesApi, PhenotypeApi) are exported too, if you want to construct a single namespace on its own.