SDKs
The Dart / Flutter (anpheros_sdk) and TypeScript (@anpheros/sdk) clients: same shape, idempotent creates, retries, token refresh and the consent flow.
Official client libraries for a FHIR R4 healthcare API with a free FHIR sandbox: patients, observations, lab results, conditions, medications, International Patient Summary, patient consent and AI context, in TypeScript and Dart / Flutter.
Anpheros is interoperable medical-data infrastructure for building healthcare applications, medical software and AI services. Each patient has one HL7 FHIR R4 record that they control; applications, clinics, laboratories and AI agents read and write it through the Anpheros Platform API — with patient consent (OAuth 2.1 / SMART on FHIR), provenance on every write and an access log the patient can see. This repository contains the official client libraries and runnable examples.
| Language | Package | Install | Source |
|---|---|---|---|
| Dart / Flutter | anpheros_sdk |
dart pub add anpheros_sdk |
dart/anpheros_sdk |
| TypeScript (Node 18+, browsers, Deno, Bun) | @anpheros/sdk |
npm install @anpheros/sdk |
ts |
Quick start in 2 minutes
- Get a free sandbox key: sign in on the dashboard and press Get a sandbox key (
sk_test_…). Your sandbox has 30 synthetic patients. - Check it works:
bash
curl -H "Authorization: Bearer $ANPHEROS_KEY" "https://platform.anpheros.com/fhir/R4/Patient?_count=3"
- Install an SDK and read a record:
npm install @anpheros/sdkordart pub add anpheros_sdk, then run the code under Connect, or clone quickstart-ts.
Who it is for
Developers building patient and family health apps, medical-app backends, clinic and laboratory integrations, and AI assistants or agents that need a patient's structured medical context — without designing a medical database, a consent system and an audit trail from scratch.
Get a sandbox key
The sandbox is free and self-service. Sign in with Google on the dashboard and press Get a sandbox key: you get a sandbox project and a key instantly. Every sandbox project comes with its own 30 synthetic patients — six months of conditions, medications, allergies, lab results and vital signs — that you can change freely and reset at any time. Sandbox keys (sk_test_…) never reach real patient data.
When you go live, production is for verified organisations with a data processing agreement, and production starts at €99 a month with the first month free (pricing).
Connect
import { Anpheros, apiKey } from '@anpheros/sdk';
const anpheros = new Anpheros({ auth: apiKey(process.env.ANPHEROS_KEY!) }); // sk_test_… in the sandbox
const { data: patients } = await anpheros.patients.list();
const labs = await anpheros.observations.list(patients[0].id, { category: 'laboratory', limit: 10 });
const ctx = await anpheros.context.build({ patient: patients[0].id, task: 'weekly check-in', budget_tokens: 1500, format: 'text' });
import 'package:anpheros_sdk/anpheros_sdk.dart';
final anpheros = Anpheros(auth: AnpherosAuth.apiKey('sk_test_…'));
final patients = await anpheros.patients.list();
final labs = await anpheros.observations.list(patients.data.first.id, category: 'laboratory', limit: 10);
API keys belong on servers. An app acting for a person uses OAuth instead: both SDKs implement the consent flow (authorization code + PKCE) and refresh tokens automatically.
What the SDKs cover
Both cover the whole public surface (/v1, /fhir/R4, /oauth/token, /oauth/revoke) with the
same shape: patients, observations, conditions, medications, documents, timeline,
provenance, context, grants, terminology, patterns and research (beta) and raw fhir. Both report the
X-Anpheros-Safety header of a write through onSafety, so an app can show crisis lines at once. A test fails the
build when a public route is missing from either SDK or when an SDK calls a route the server
does not have.
Both SDKs: automatic Idempotency-Key on creates, retries with backoff on 429/5xx, one token
refresh on 401, typed errors with the request id, PKCE helpers and the consent flow.
Medical data and FHIR
The record is made of standard FHIR R4 resources — 26 types, including Observation, Condition, MedicationStatement, DocumentReference, Immunization and AllergyIntolerance — coded with LOINC, ICD-10, ATC and UCUM. The REST API (/v1) and the FHIR API (/fhir/R4) read and write the same resources with the same ids; fhir in both SDKs gives raw FHIR access (search, transactions, $everything, $summary, $validate).
Examples
| Example | Shows |
|---|---|
| quickstart-ts | write and read a record: measurements, lab result, diagnosis, medication, timeline, FHIR search, IPS, AI context |
| quickstart-dart | the same from Dart / Flutter |
| consent-app-ts | a web app that asks for consent (OAuth 2.1 + PKCE) and reads the person's record |
| ai-context-llm | a question about a record answered by a model of your choice (local or hosted) |
| fhir-transaction | a FHIR R4 transaction bundle and the resulting International Patient Summary |
The examples run against the free sandbox, where each sandbox project has its own 30 synthetic patients — see Get a sandbox key.
Related repositories
| Repository | What it is |
|---|---|
| fhir-api-openapi | OpenAPI 3.1 spec and Postman collection of the API |
| mcp-server | the hosted FHIR MCP server for AI agents: configs for Claude, Cursor, VS Code |
| agent-skills | Agent Skill, Claude Code plugin, Cursor rules and AGENTS.md |
| fhir-synthetic-patients | the 30 synthetic patients as FHIR R4 Bundles and NDJSON |
| ips-examples | International Patient Summary documents in FHIR R4 |
| fhir-validate-action | GitHub Action that validates FHIR R4 JSON in CI |
| lab-results-to-fhir | CLI: CSV / HL7 v2 lab reports → FHIR Observations |
| healthcare-app-starters | Next.js and Flutter health app templates |
Conformance
Raw test results, published so they can be checked (test results, not certifications): conformance/. On 28 September 2026 the Standalone Launch group of the Inferno SMART App Launch STU2 test kit (v1.0.3) passed 22 of 22 tests against the platform. EHR launch is not supported.
Documentation
- Developer guides
- Getting started
- FHIR sandbox
- Healthcare API
- Healthcare API platform
- FHIR platform
- SDK guide
- Health patterns developer guide
- API reference (OpenAPI)
- For AI assistants
- Anpheros
Issues and security
Report bugs in this repository's issues. Never include API keys, tokens or patient data in an issue. Security reports: [email protected].
License
Apache License 2.0 — see the LICENSE file of each package. Copyright 2026 Anpheros.
@anpheros/sdk
TypeScript client for Anpheros Platform: a FHIR R4 health record per patient, project
isolation, patient consent (OAuth 2.1 / SMART on FHIR), provenance on every write and an AI
context API. Runs anywhere fetch exists (Node 18+, browsers, Deno, Bun).
import { Anpheros, apiKey } from '@anpheros/sdk';
const anpheros = new Anpheros({ auth: apiKey(process.env.ANPHEROS_KEY!) });
const { data: patients } = await anpheros.patients.list();
const labs = await anpheros.observations.list(patients[0].id, { category: 'laboratory', limit: 10 });
const ctx = await anpheros.context.build({ patient: patients[0].id, task: 'weekly check-in', budget_tokens: 1500, format: 'text' });
Acting for a person:
import { OAuthFlow, OAuthAuth, generatePkce } from '@anpheros/sdk';
const flow = new OAuthFlow({ baseUrl: BASE, clientId: 'client_…', redirectUri: 'https://myapp.example/callback' });
const pkce = await generatePkce();
location.href = flow.authorizeUrl({ scopes: ['patient/Observation.rs?category=laboratory', 'offline_access'], state, pkce, lang: 'ro' });
// on the callback:
const tokens = await flow.exchange(code, pkce);
const anpheros = new Anpheros({ auth: new OAuthAuth({ tokens, onRefresh: flow.refresh, onTokens: persist }) });
Errors are AnpherosError (status, type, message, field, requestId). Creates send an
Idempotency-Key; 429/5xx are retried; expired tokens are refreshed once and the call retried.
Health patterns (beta)
What changed in a record and what recurs, by fixed statistical rules: not diagnoses, not causes. The full guide, with consent, the display rule, maturity, research and the safety obligation, is Health patterns developer guide.
// Sandbox: compute on request for a synthetic person with a planted pattern (p01: home blood pressure falling).
const anpheros = new Anpheros({ auth: apiKey(process.env.ANPHEROS_KEY!) }); // sk_test_…
const bundle = await anpheros.fhir.search('Patient', { identifier: 'https://anpheros.com/fhir/sid/sandbox-persona|p01' });
const patientId = bundle.entry![0].resource!.id!;
const run = await anpheros.patterns.run(patientId, { window_days: 180 });
for (const f of run.findings) {
console.log(f.summary_text, f.statistically_supported, f.method.maturity, f.limitations.map((l) => l.code));
}
const methods = await anpheros.patterns.methods(); // maturity, patient_facing, notify per method
// Trusted first-party project, under the person's anpheros/patterns consent: stored findings.
const stored = await anpheros.patterns.current(patientId);
const forThePerson = stored.findings.filter((f) => f.shown && f.method.patient_facing);
const research = await anpheros.patterns.research(patientId, forThePerson[0].finding_key);
if (!research.available) console.log(research.reason?.key); // e.g. finding.library_not_populated: show this, not a verdict
await anpheros.patterns.feedback(patientId, forThePerson[0].finding_key, { response: 'unsure' });
Safety. A write that records a PHQ-9 item 9 answer above 0 comes back with X-Anpheros-Safety: crisis-resources.
Your app must then show crisis lines to the person at once:
const anpheros = new Anpheros({
auth,
onSafety: async () => showCrisisSheet(await anpheros.patterns.crisisResources(userCountry)),
});
anpheros_sdk
Dart / Flutter client for Anpheros Platform: a health-data backend with a FHIR R4 record per patient, project isolation, patient consent (OAuth 2.1 / SMART on FHIR), provenance on every write and an AI context API.
import 'package:anpheros_sdk/anpheros_sdk.dart';
final anpheros = Anpheros(auth: AnpherosAuth.apiKey('sk_test_…')); // server / sandbox
final patients = await anpheros.patients.list();
final elena = patients.data.first;
final labs = await anpheros.observations.list(elena.id, category: 'laboratory', limit: 10);
final ctx = await anpheros.context.build(ContextRequest(patient: elena.id, task: 'weekly check-in', budgetTokens: 1500));
Acting for a person (apps)
final flow = OAuthFlow(baseUrl: 'https://…', clientId: 'client_…', redirectUri: 'myapp://callback');
final pkce = Pkce.generate();
final url = flow.authorizeUrl(scopes: ['patient/Observation.rs?category=laboratory', 'patient/MedicationStatement.r', 'offline_access'],
state: 'abc', pkce: pkce, lang: 'ro');
// open `url`; on return with ?code=…:
final tokens = await flow.exchange(code: code, pkce: pkce);
final anpheros = Anpheros(auth: AnpherosAuth.oauth(
accessToken: tokens.accessToken, refreshToken: tokens.refreshToken, expiresAt: tokens.expiresAt,
onRefresh: flow.refresh, onTokens: persist));
final meds = await anpheros.medications.listMedications(tokens.patient!);
Every object carries fhir (its /fhir/R4 reference); anpheros.fhir gives raw FHIR access
(read, search, create, transaction, $everything, $summary, $validate).
Errors are AnpherosException with status, type, message, field and requestId.
Creates send an Idempotency-Key automatically; 429/5xx are retried with backoff; expired OAuth
tokens are refreshed once and the call retried.
Health patterns (beta)
What changed in a record and what recurs, by fixed statistical rules: not diagnoses, not causes. Full guide: Health patterns developer guide.
// Sandbox: p01 carries a planted pattern (home blood pressure falling).
final bundle = await anpheros.fhir.search('Patient', {'identifier': 'https://anpheros.com/fhir/sid/sandbox-persona|p01'});
final patientId = ((bundle['entry'] as List).first as Map)['resource']['id'] as String;
final run = await anpheros.patterns.run(patientId, windowDays: 180);
for (final f in run.findings) {
print('${f.summaryText} supported=${f.statisticallySupported} maturity=${f.method.maturity}');
}
// Trusted first-party project, under the person's anpheros/patterns consent: stored findings.
final stored = await anpheros.patterns.current(patientId);
final forThePerson = stored.findings.where((f) => f.shown && f.method.patientFacing).toList();
final research = await anpheros.patterns.research(patientId, forThePerson.first.findingKey);
if (!research.available) print(research.reason?.key); // e.g. finding.library_not_populated: never a verdict
await anpheros.patterns.feedback(patientId, forThePerson.first.findingKey, 'unsure');
Safety. A write that records a PHQ-9 item 9 answer above 0 comes back with X-Anpheros-Safety: crisis-resources;
show crisis lines to the person at once:
late final Anpheros anpheros;
anpheros = Anpheros(auth: auth, onSafety: (_) async => showCrisisSheet(await anpheros.patterns.crisisResources(country: 'US')));
Ask your AI
Paste this into Claude, ChatGPT, Cursor or Claude Code. Your assistant reads this guide and adapts it to your code.
Read https://developers.anpheros.com/guides/sdks.md and help me apply this guide to my own project. Use the Anpheros sandbox (base URL https://platform.anpheros.com) with my API key from the ANPHEROS_KEY environment variable, never written in the code. Give me complete, runnable code, the response I should expect, and how to fix the errors in https://developers.anpheros.com/guides/troubleshooting.md if a call fails.Open in ClaudeOpen in ChatGPTThis guide as MarkdownBuild the whole integration with an AI coding tool
Try it free in the sandbox · first FHIR call in 5 minutesFree · 30 synthetic patients · no cardYour first API call in 2 minutes →
