Loading...
Loading...
Query, search, and download data from the openFDA API for drugs, devices, foods, tobacco, cosmetics, animal and veterinary products, substances, and transparency data. Use for FDA adverse events, recalls, labeling, approvals, shortages, 510(k) clearances, NDC lookups, and any FDA safety or regulatory data query across all 28 API endpoints.
npx skill4agent add google-deepmind/science-skills openfda-databaseuvuvuv.env.envFDA_API_KEY.envENV_FILE.envprintf "Enter openFDA API key (typing hidden): " && read -s key && echo && echo "FDA_API_KEY=$key" >> "ENV_FILE" && echo "Saved."dotenv.envcatgrepechoprintenvos.environ.getWarning: An automated agent can easily exhaust the 1,000-request daily limit in a single research session. Always set an API key before running multi-query workflows.
Instruct the user to register for a free key at https://open.fda.gov/apis/authentication/ and follow the prerequisite instructions above to addto theFDA_API_KEYfile. The script will emit a warning to stderr if no API key is detected..env
--output--output <file>uv run scripts/openfda_query.py {search,count,download} --output <file> [options]uv run scripts/openfda_query.py search \
--category drug --endpoint event \
--search "patient.drug.medicinalproduct:aspirin" \
--limit 5 --output /tmp/fda_results.json{"status": "success", "output": "/tmp/fda_results.json", "results_in_file": 5, "total_matching": 601477}--output--categorydrugdevicefoodtobaccootheranimalandveterinarycosmetictransparency--endpointeventlabel510k--searchpatient.drug.medicinalproduct:aspirin+AND+serious:1--sortreceivedate:desc--limit--skip--api_keyFDA_API_KEYuv run scripts/openfda_query.py count \
--category drug --endpoint event \
--search "patient.drug.medicinalproduct:aspirin" \
--count_field "patient.reaction.reactionmeddrapt.exact" \
--summary 10 --output /tmp/aspirin_reactions.json--count_field.exact--summary Nuv run scripts/openfda_query.py download \
--category drug --endpoint event \
--search "patient.drug.medicinalproduct:aspirin" \
--limit 100 --max_pages 5 \
--output /tmp/aspirin_events.json--max_pages--all_resultsTip: Common drugs can have excessive reports. Use a date range (e.g.,) to limit the volume of download.receivedate:[20250101+TO+20250131]
.exact# Precise: matches only "ADVIL"
uv run scripts/openfda_query.py search --category drug --endpoint label \
--search 'openfda.brand_name.exact:"ADVIL"' \
--limit 5 --output /tmp/advil_label.jsonNote: Many brand names in the FDA database include variant suffixes (e.g., "TYLENOL Extra Strength" rather than just "TYLENOL"). If ansearch returns 0 results, try without.exactto see the available brand name variants, then re-query with the full exact name..exact
.exact--count_fieldNote: MedDRA is a proprietary ontology and is not indexed in the EMBL-EBI OLS. To approximate MedDRA hierarchy lookups, use the Human Phenotype Ontology (HP) or NCI Thesaurus (NCIT) as proxy ontologies — they cross-reference MedDRA IDs and provide parent/ancestor relationships.
# Step 1: Get top reactions from openFDA
uv run scripts/openfda_query.py count \
--category drug --endpoint event \
--search "patient.drug.medicinalproduct:metformin" \
--count_field "patient.reaction.reactionmeddrapt.exact" \
--summary 5 --output /tmp/metformin_reactions.json
# Step 2: Look up the top reaction term using a biomedical ontology service
# skill (e.g. embl-ebi-ols skill).
# MedDRA is not available in OLS; use the Human Phenotype Ontology (HP) or
# NCI Thesaurus (NCIT) as a proxy to find the hierarchical classification of
# the reaction term.drugdevicefoodtobaccootheranimalandveterinarycosmetictransparencysearch--outputcount--summary 10 --outputdownload--all_results