
openFDA Database
FreeEfficiently query and download FDA data across multiple categories.
Free · Opens the source repo
What openFDA Database does
The openFDA Database skill enables users to seamlessly query, search, and download comprehensive data from the openFDA API. This includes information on drugs, devices, foods, tobacco, cosmetics, and veterinary products, among others. With access to 28 API endpoints, users can retrieve data related to FDA adverse events, recalls, labeling, approvals, and other regulatory information. This skill is particularly useful for researchers, developers, and analysts who require reliable access to FDA data for their projects or analyses.
The skill operates through a Python script that facilitates various operations, including searching for specific data, counting unique values in results, and downloading large datasets. Users can execute commands to search specific categories and endpoints, ensuring that they can tailor their queries to meet their specific needs. The results are saved in JSON format, which can be easily processed or analyzed further.
To ensure smooth operation, users are required to set up an API key, which significantly increases the daily request limit. The skill also includes built-in rate limiting to prevent users from exceeding the allowed number of requests, which is crucial for maintaining compliance with openFDA's usage policies. Additionally, the skill provides guidance on using exact match searches to enhance the precision of query results, making it a valuable tool for anyone needing detailed and accurate FDA data.
Overall, the openFDA Database skill is an essential resource for developers and researchers who need to interact with FDA data in a structured and efficient manner. By leveraging this skill, users can save time and effort in data retrieval, allowing them to focus on analysis and decision-making based on the retrieved information.
When to use it
Use this skill when you need to retrieve specific FDA data for analysis, research, or application development.
When not to use it
This skill may not be suitable for users who require real-time data updates or those who need extensive data manipulation capabilities beyond basic querying.
What you can build with it
Researching Adverse Events
Use this skill to search for and download data on adverse events related to specific drugs, helping in safety analysis.
Tracking FDA Recalls
Query the openFDA API to get the latest information on FDA recalls for specific products, ensuring compliance and safety.
Analyzing FDA Approvals
Download datasets on FDA approvals to analyze trends in drug or device approvals over time.
How to install openFDA Database
View source1. Install with the skills CLI
npx skills add google-deepmind/science-skills/openfda_database --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by google-deepmindopenFDA Search and Query
Prerequisites
uv: Read theuvskill and follow its Setup instructions to ensureuvis installed and on PATH.- User Notification: If .licenses/openfda_database_LICENSE.txt does not already exist in the workspace root directory then (1) prominently notify the user to check the terms at https://open.fda.gov/apis/ and https://open.fda.gov/license, then (2) create the file recording the notification text and timestamp.
.envfile: Make sure the.envfile exists in your home directory. Create one if it does not exist.FDA_API_KEY(optional but recommended): Raises the daily request limit from 1,000 to 120,000. The skill works without it, but an agent can easily exhaust the keyless limit in a single session. You can register for a free key at https://open.fda.gov/apis/authentication/. You MUST use the safe credentials protocol in thecredentialsskill to check for and request this key if this skill looks relevant to the user's request.
Core Rules
-
Use the Wrapper: ALWAYS execute the provided helper scripts to query the database rather than accessing the database directly. The scripts automatically enforce the required rate limit gracefully.
-
Rate Limiting: Respect openFDA rate limits. Without API key: 240 requests/min, 1,000 requests/day per IP. With API key: 240 requests/min, 120,000 requests/day per key. Always set an API key before running multi-query workflows.
Warning: 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.
You MUST use the safe credentials protocol in the
credentialsskill to help the user addFDA_API_KEYto their.envfile if this skill looks relevant to the user's request. The script will emit a warning to stderr if no API key is detected.
-
Always Use
--output: All subcommands require--output <file>to write results to a file. This prevents large output becoming overwhelming. Use jq or code to read the output file. -
Notification: If this skill is used, ensure this is mentioned in the output.
Utility Script
Single script for all operations:
uv run scripts/openfda_query.py {search,count,download} --output <file> [options]
1. Search
Search any of the 28 endpoints and save JSON results to a file.
uv run scripts/openfda_query.py search \
--category drug --endpoint event \
--search "patient.drug.medicinalproduct:aspirin" \
--limit 5 --output /tmp/fda_results.json
Stdout prints a compact summary:
{"status": "success", "output": "/tmp/fda_results.json", "results_in_file": 5, "total_matching": 601477}
Options:
--output: Output file for full JSON results (required).--category: API category —drug,device,food,tobacco,other,animalandveterinary,cosmetic,transparency.--endpoint: Endpoint within the category (e.g.,event,label,510k). See references/api_endpoints.md for full list.--search: Query string (e.g.,patient.drug.medicinalproduct:aspirin+AND+serious:1).--sort: Sort field and order (e.g.,receivedate:desc).--limit: Max results (default 10, max 1000).--skip: Pagination offset (default 0).--api_key: API key (also readsFDA_API_KEYenv var).
2. Count
Count unique values of a field within matching results.
uv 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
Stdout prints a summary with the top 5 terms. Full data is in the output file.
Additional options:
--count_field: Field to count (append.exactfor whole-phrase counting).--summary N: Return only the top N most frequent terms. Use this to avoid flooding the context with hundreds of infrequent terms.
3. Download
Download multiple pages of results to a file.
uv 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
Additional options:
-
--max_pages: Maximum pages to fetch (default 10). -
--all_results: Automatically paginate to fetch all matching results. Safety cap of 25,000 records maximum per download to prevent runaway downloads and prevent excessive API usage.Tip: Common drugs can have excessive reports. Use a date range (e.g.,
receivedate:[20250101+TO+20250131]) to limit the volume of download.
Entity Resolution: Using .exact for Precision
When searching for specific product names, drug names, or categorical terms,
always use the .exact suffix on the field to get exact-match results. Without
it, the API tokenizes multi-word values and returns noisy partial matches.
# 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.json
Note: Many brand names in the FDA database include variant suffixes (e.g., "TYLENOL Extra Strength" rather than just "TYLENOL"). If an
.exactsearch returns 0 results, try without.exactto see the available brand name variants, then re-query with the full exact name.
The .exact suffix is also required when using --count_field to aggregate
whole phrases instead of individual words.
MedDRA Term Resolution
openFDA adverse event data uses MedDRA (Medical Dictionary for Regulatory Activities) terms for reactions. The API reports Preferred Terms (PTs) but does not provide the MedDRA hierarchy (System Organ Class, High Level Terms, etc.).
Note: 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.
Available Endpoints (28 total)
Category to endpoint mapping:
drug: event, label, ndc, enforcement, drugsfda, shortagesdevice: 510k, classification, enforcement, event, pma, recall, registrationlisting, udi, covid19serologyfood: enforcement, eventtobacco: problem, researchpreventionads, researchdigitalads, researchsmokefreeother: historicaldocument, nsde, substance, uniianimalandveterinary: eventcosmetic: eventtransparency: crl
Reference
- Query syntax and all endpoints: See references/api_endpoints.md for field names, search syntax, date ranges, and boolean operators.
Recipes
Common query patterns for drugs, devices, foods, tobacco, cosmetics, animal and veterinary products, substances, transparency data, adverse events, recalls, labeling, approvals, shortages, 510(k) clearances, NDC lookups, any FDA safety or regulatory data query, and more. See references/recipes.md for the full recipes.
Workflow
- Search for records using
searchwith--output. Read the output file. - Use
countwith--summary 10 --outputto summarize field distributions. - Use
download(with--all_resultsfor exhaustive pulls) to fetch larger datasets. - Read and analyze the output file using standard tools.
- For MedDRA term hierarchy questions, use a biomedical ontology service skill (e.g. EMBL-EBI OLS skill with the HP or NCIT ontology) to look up the term.
Frequently asked questions about openFDA Database
Similar skills
Create Data Lake Tables
Efficiently manage Iceberg tables on Amazon S3.
OneKGPd
Query individual-level data from the 1000 Genomes Project.
Database Lookup
Retrieve data from public APIs with precision and reproducibility.
BigQuery Basics
Manage datasets and run queries in BigQuery easily.
Query Data Lake
Efficiently execute SQL queries on Amazon Athena.
Find Data Lake Assets
Quickly resolve data lake asset references across AWS services.
