openFDA API
US FDA open data on drugs, devices, food and adverse events.
What it does
openFDA exposes US Food and Drug Administration public datasets as queryable JSON APIs: drug adverse-event reports, drug and device labelling, recalls and enforcement actions, NDC directory, food enforcement, and more. Queries use an Elasticsearch-style syntax with search, count and pagination.
Base URL
Authentication
Works with no key at a lower limit. A free API key (?api_key=YOUR_KEY) raises the limits significantly. Endpoints are /{domain}/{subject}.json, e.g. /drug/event.json, /drug/label.json, /food/enforcement.json.
Code examples
curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduct:ibuprofen&count=patient.reaction.reactionmeddrapt.exact"
import requests
r = requests.get("https://api.fda.gov/drug/label.json", params={
"search": "openfda.brand_name:advil", "limit": 1}, timeout=15)
res = r.json()["results"][0]
print(res["openfda"]["generic_name"], res.get("warnings", ["-"])[0][:120])Rate limits & quotas
Without a key: about 240 requests/minute and 1,000/day per IP. With a free key: 240/minute and 120,000/day. limit maxes at 1,000 results per call; deep paging with skip is capped (around 25,000) — use search_after or narrower queries for large extracts.
Key response fields
| meta.results.total | Total documents matching the query |
| results[] | The matching records (structure differs per endpoint) |
| results[].openfda | Normalised cross-reference fields (brand/generic name, NDC, UNII, RxCUI) |
| (with count=) results[].term / count | Aggregated term frequencies instead of documents |
| error.code / error.message | On a bad query |
Common errors
| 404 NOT_FOUND | The query matched zero documents (openFDA returns 404, not an empty list). |
| 400 BAD_REQUEST | Syntax error in search, or a non-.exact field used with count. |
| 429 OVER_RATE_LIMIT | Per-minute or per-day cap hit — add a key or slow down. |
| (stale data) | Datasets update on FDA’s schedule (often weekly/quarterly), not in real time. |
When to use it (and alternatives)
The authoritative free source for US drug/device safety data, recalls and labelling — good for health dashboards, pharmacovigilance prototypes and consumer ‘is this recalled?’ tools. Always surface openFDA’s disclaimer: the data is not a substitute for professional or regulatory advice.
FAQ
Why do I get a 404 instead of an empty result set?
openFDA returns 404 NOT_FOUND when a query matches nothing. Treat 404 as ‘no results’, not as a broken request, and check meta.results.total when you do get 200.
How do I get counts instead of records?
Add count=field.exact (the .exact suffix matters for string fields). You get back term/frequency pairs — ideal for charts — and it does not count against the 1,000-result limit.
Do I need an API key?
Not to start, but the keyless daily limit is only 1,000 requests. The free key is instant and takes you to 120,000/day.
New to APIs?
Short guides for working with this API — and any other.