Skip to content

FDA NDC directory lookup

$0.004 per callUSDC via x402GET /api/drug-ndc

Look up the FDA National Drug Code directory (openFDA) by NDC or by brand or generic name: product NDC, labeler, dosage form, routes, active ingredients with strengths...

Category: Live public dataTags: fda drug ndc national-drug-code pharmacy openfda health government

Try in playground →

Details

Look up the FDA National Drug Code directory (openFDA) by NDC or by brand or generic name: product NDC, labeler, dosage form, routes, active ingredients with strengths, marketing category and application number, pharmacologic class, marketing and listing dates, and the package NDCs with their descriptions. The answer says how many products matched. Live FDA data, no key.

Parameters

NameTypeRequiredDescription
ndcstringnoProduct NDC (e.g. 58151-155) or package NDC (e.g. 58151-155-77), hyphenated The example sends 58151-155.
namestringnoBrand or generic name, used when no ndc is given (e.g. lipitor) Up to 100 characters.
limitnumbernoProducts to return, 1-20 (default 5)

Example request

curl -i "https://agent402.tools/api/drug-ndc?ndc=58151-155"

Watch a call get paid

RequestGET /api/drug-ndc
402$0.004 USDC
SignPAYMENT-SIGNATURE
Settleon 14 chains
Answer200 OK
ReceiptAgent402-ReceiptEd25519

Example response

{
  "query": {
    "ndc": "58151-155",
    "name": null
  },
  "count": 1,
  "products": [
    {
      "productNdc": "58151-155",
      "brandName": "Lipitor",
      "genericName": "atorvastatin calcium",
      "labeler": "Viatris Specialty LLC",
      "dosageForm": "TABLET, FILM COATED",
      "routes": [
        "ORAL"
      ],
      "productType": "HUMAN PRESCRIPTION DRUG",
      "marketingCategory": "NDA",
      "applicationNumber": "NDA020702",
      "activeIngredients": [
        {
          "name": "ATORVASTATIN CALCIUM TRIHYDRATE",
          "strength": "10 mg/1"
        }
      ],
      "pharmClass": [
        "HMG-CoA Reductase Inhibitor [EPC]"
      ],
      "marketingStartDate": "2024-05-01",
      "listingExpirationDate": "2027-12-31",
      "finished": true,
      "packaging": [
        {
          "packageNdc": "58151-155-77",
          "description": "90 TABLET, FILM COATED in 1 BOTTLE (58151-155-77)",
          "marketingStartDate": "2024-05-01",
          "sample": false
        }
      ],
      "packagingCount": 1
    }
  ],
  "returned": 1,
  "matched": 1,
  "complete": true,
  "truncated": false,
  "disclaimer": "openFDA data is unvalidated and is not medical advice; do not rely on it to make decisions regarding medical care.",
  "source": "api.fda.gov (openFDA NDC directory, public domain)",
  "credit": "Data provided by the U.S. Food and Drug Administration (https://open.fda.gov)."
}
FieldTypeAlways presentIn the example
queryobjectyes2 fields: ndc, name
countnumberyes1
productsarray of objectsyes1 item in the example
returnednumberyes1
matchednumberyes1
completebooleanyestrue
truncatedbooleanyesfalse
disclaimerstringyesopenFDA data is unvalidated and is not medical advice; do not rely on it to m...
sourcestringyesapi.fda.gov (openFDA NDC directory, public domain)
creditstringyesData provided by the U.S. Food and Drug Administration (https://open.fda.gov).

From an MCP client

catalog.call {
  "slug": "drug-ndc",
  "params": {
    "ndc": "58151-155"
  }
}

Hosted connector (https://agent402.tools/mcp): paid in the call. Stdio package (npx -y agent402-mcp@0.17.2): pays from a wallet or an AGENT402_CREDITS_KEY issued earlier.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.004" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/drug-ndc?ndc=58151-155");

Get a wallet or run npx -y agent402-mcp@0.17.2 wallet new.

The quote (Python)

import base64, json, urllib.error, urllib.request

req = urllib.request.Request("https://agent402.tools/api/drug-ndc?ndc=58151-155", method="GET", headers={})
try:
    urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
    quote = json.loads(base64.b64decode(e.headers["PAYMENT-REQUIRED"]))
    print(e.code, [(a["network"], a["amount"]) for a in quote["accepts"]])  # the price, per chain, in base units

Related tools