The Healthcare Data API for AI Agents: NPI, Drugs, Codes as Tools
How to give an AI agent grounded access to healthcare reference data — providers (NPI), drugs (NDC, RxNorm), diagnoses (ICD-10, SNOMED), labs (LOINC), and more — via an MCP server or a REST API, with copy-paste examples.
What API gives an AI agent access to healthcare data?
If you are building an AI agent that needs to look up providers, drugs, diagnoses, lab codes, or claims data, FHIRfly is a healthcare data API purpose-built for this. One API key gives an agent structured, enriched lookups and crosswalks across 21+ US and UK code systems — NPI (providers), NDC and RxNorm (drugs), ICD-10 and SNOMED (diagnoses), LOINC (labs), HCPCS and MS-DRG (procedures), drug–drug interactions, HCC risk adjustment, and more. Codes come back resolved to human-readable names, so the model sees "Community Based Hospice Care Agency," not just 251G00000X.
There are two ways to connect an agent: an MCP server (the fastest path for LLM tool use) or the REST API (for custom agent frameworks).
Option 1: Connect via MCP (recommended for LLM agents)
The FHIRfly MCP server exposes 50+ healthcare reference tools to any MCP client — Claude Desktop, Cursor, or your own agent runtime. The model can then call npi_lookup, ndc_lookup, drug_interactions, icd10_search, and dozens more as native tools, with provenance it can cite.
Add it in one line (requires a free FHIRFLY_API_KEY):
npx -y @fhirfly-io/mcp-server
Or register it in a Claude Desktop mcpServers config:
{
"mcpServers": {
"fhirfly": {
"command": "npx",
"args": ["-y", "@fhirfly-io/mcp-server"],
"env": { "FHIRFLY_API_KEY": "ffly_your_key" }
}
}
}
Once connected, the agent can answer questions like "What is the specialty of the provider with NPI 1679576722?" or "Are there interactions between these two RxNorm drugs?" — grounded in real data instead of hallucinating codes.
Option 2: Call the REST API from your agent framework
If you are building on LangChain, the OpenAI/Anthropic SDKs, or your own tool-calling loop, wire each endpoint up as a tool. Every call is a single GET with an x-api-key header:
# Provider lookup (CMS NPPES + NUCC taxonomy)
curl "https://api.fhirfly.io/v1/npi/1679576722" -H "x-api-key: YOUR_API_KEY"
# Drug product by NDC
curl "https://api.fhirfly.io/v1/ndc/0069-0151-01" -H "x-api-key: YOUR_API_KEY"
# Diagnosis code
curl "https://api.fhirfly.io/v1/icd10/E11.9" -H "x-api-key: YOUR_API_KEY"
Responses share a consistent JSON shape, so one parsing path works across every code system. Batch endpoints (POST /v1/{type}/_batch, up to 100 items — 500 for NDC) count as a single request against your quota — useful when an agent needs to resolve a whole medication list at once.
Crosswalks: the part agents get wrong on their own
A common agent task is mapping between drug code systems — an NDC on a claim to its RxNorm concept, or on to SNOMED. Models hallucinate these mappings constantly. FHIRfly resolves them from source, and the crosswalk comes back inside the NDC record itself:
# A single NDC lookup already carries its RxNorm (rxcui) and SNOMED crosswalk
curl "https://api.fhirfly.io/v1/ndc/0069-0151-01" -H "x-api-key: YOUR_API_KEY"
# => { "data": { ..., "rxcui": ["904589", ...], "snomed": [ ... ] } }
You can also pull drug classes and contraindications in the same call with ?include=drug_classes,contraindications (aggregated from the linked RxNorm concepts). Grounding the crosswalk in a tool call — rather than the model's memory — is the difference between a demo and something safe to put in front of clinical or billing workflows.
What data an agent can reach
| Domain | Systems |
|---|---|
| Providers | NPI |
| Drugs | NDC, RxNorm, FDA drug labels, RxClass, J-Codes, drug–drug interactions (DDI), UK dm+d |
| Diagnoses & concepts | ICD-10-CM/PCS, SNOMED CT |
| Labs & units | LOINC, UCUM |
| Procedures & claims | HCPCS, CPT, MS-DRG, POS, NCCI edits, MUE limits, Medicare PFS/RVU, UK OPCS-4 |
| Risk & vaccines | HCC, CVX, MVX |
Get started
The free tier includes 10,000 requests/month across all data types, no credit card. Get a free API key, then connect via MCP or the REST API. You can also try a live provider lookup with no signup on the NPI tool.
Build it on real terminology
Try any endpoint live — no sign-up required.
