DEV Community

linderroger-eng
linderroger-eng

Posted on

I Built a Free API for FDA Drug Data — Adverse Events, Recalls, and Drug Labels by Name

If you've ever tried to pull drug safety data from the FDA's openFDA API, you know the pain. The documentation is dense, the search syntax is cryptic, and getting something as simple as "give me adverse event reports for Ozempic" requires constructing a query that looks like this:

https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduct:"OZEMPIC"&limit=10
Enter fullscreen mode Exit fullscreen mode

And that's assuming you spelled the drug name exactly as it appears in their database — which may be uppercase, lowercase, or a brand name vs. generic. Miss it by one character and you get zero results with no helpful error message.

I got frustrated enough that I built a cleaner wrapper around it. This article walks through what I built, why, and how you can use it today — for free.


The Problem with openFDA

OpenFDA is genuinely valuable. The FDA publishes millions of records covering:

  • Adverse event reports (FAERS — FDA Adverse Event Reporting System)
  • Drug labels (indications, dosage, warnings, interactions)
  • Device recalls (medical equipment pulled from market)
  • Drug recalls (contamination, mislabeling, potency issues)

The data is public and updated regularly. But querying it directly is painful:

  1. Weird search syntax — You're writing Lucene-style queries in a URL parameter. Most developers don't know Lucene.
  2. No fuzzy matching — You need to know the exact drug name as stored in the FDA's system. "Tylenol" might be stored as "TYLENOL", "ACETAMINOPHEN", or both.
  3. Inconsistent JSON structure — The response shape changes between endpoints. The nested object paths are deep and inconsistent.
  4. Rate limiting without clear feedback — Hit the limit and you get a 429 with minimal guidance on when to retry.
  5. No aggregation — Want to know the total number of adverse events for a drug? You have to parse the metadata yourself.

For a health tech startup or a pharma developer building a compliance dashboard, this friction adds up to days of wasted integration work.


What I Built

I built the FDA Drug Safety API — a RESTful wrapper that lets you query FDA data by drug name, plain English keywords, and simple parameters. No Lucene. No weird casing rules. Just clean JSON back.

The API is live at: https://fda-drug-safety-api.onrender.com

It's also listed on RapidAPI if you want a managed key and usage dashboard.


Real Examples — Try These Right Now

1. Adverse Events for Ozempic

curl "https://fda-drug-safety-api.onrender.com/drug/adverse-events?name=ozempic"
Enter fullscreen mode Exit fullscreen mode

This returns structured adverse event data from the FDA FAERS database. As of this writing, there are 57,104 reports associated with Ozempic — a staggering number that reflects both the drug's widespread use and the importance of monitoring it.

The response includes:

  • Total report count
  • Top reported reactions (nausea, vomiting, pancreatitis, etc.)
  • Seriousness breakdown (hospitalization, death, life-threatening)
  • Report timeline

No Lucene query required. Just pass the drug name.

2. Drug Label for Tylenol

curl "https://fda-drug-safety-api.onrender.com/drug/label?name=tylenol"
Enter fullscreen mode Exit fullscreen mode

Returns the structured drug label including:

  • Indications and usage
  • Dosage and administration
  • Warnings and precautions
  • Drug interactions
  • Overdose information
  • Active and inactive ingredients

This is the same data that appears on the physical label, but in clean, parseable JSON. Perfect for building drug information tools, patient-facing apps, or compliance documentation.

3. Medical Device Recalls — Insulin Pumps

curl "https://fda-drug-safety-api.onrender.com/device/recalls?keyword=insulin+pump"
Enter fullscreen mode Exit fullscreen mode

Returns FDA device recall records matching "insulin pump" — including the reason for recall, affected device models, recall classification (Class I = most serious), and the recalling firm.

This endpoint is especially useful for medical device companies doing post-market surveillance, or for hospital procurement teams that need to verify equipment safety status.


Python Code: Build an Adverse Event Monitor

Here's a practical 15-line script that pulls adverse event data for a list of drugs and flags any with more than 1,000 reports in the last 90 days:

import requests
from datetime import datetime, timedelta

BASE_URL = "https://fda-drug-safety-api.onrender.com"
DRUGS_TO_MONITOR = ["ozempic", "wegovy", "mounjaro", "jardiance"]
ALERT_THRESHOLD = 1000

def check_adverse_events(drug_name):
    response = requests.get(f"{BASE_URL}/drug/adverse-events", params={"name": drug_name})
    data = response.json()
    total = data.get("total_reports", 0)
    if total > ALERT_THRESHOLD:
        print(f"⚠️  ALERT: {drug_name.upper()} has {total:,} adverse event reports")
    else:
        print(f"{drug_name.upper()}: {total:,} reports (within threshold)")
    return data

for drug in DRUGS_TO_MONITOR:
    check_adverse_events(drug)
Enter fullscreen mode Exit fullscreen mode

This kind of script is the foundation of a pharmacovigilance monitoring tool. Add a cron job, a database, and a Slack webhook, and you've got a basic internal safety alert system — without writing a single line of Lucene.


Who Is This For?

Pharma developers building internal drug information tools, adverse event dashboards, or regulatory submission systems. The FDA data is a requirement; the complexity of querying it shouldn't be.

Health tech startups that need drug safety data as part of a larger product — whether it's a patient portal, a clinical decision support tool, or a medication management app. A clean API means faster integration and fewer bugs.

Compliance and regulatory teams that need to monitor recalls, label changes, and adverse event trends without relying on manual FDA website checks. Automate the tedious parts.

Academic researchers studying drug safety patterns, post-market surveillance, or pharmacoepidemiology. The free tier gives you enough requests to prototype and validate a hypothesis before scaling up.

Healthcare data engineers building pipelines that ingest FDA data into a data warehouse or BI tool. Clean JSON with consistent structure makes ETL work dramatically easier.


Pricing

The API is available on RapidAPI with the following tiers:

Tier Price Requests/Month
Free $0 100
Basic $9/month 1,000
Pro $29/month 10,000
Enterprise $99/month 100,000

The free tier requires no API key and no credit card. You can start hitting the endpoints right now with the curl examples above.

For production use cases, the Basic tier at $9/month covers most small applications. The Pro tier is designed for startups running scheduled data pulls or building user-facing features on top of the API.


Other APIs in the Suite

If you're building data-driven tools in adjacent spaces, I've also published two other APIs on RapidAPI:

SEC EDGAR API — Query SEC filings, company financials, and disclosure documents by ticker symbol or company name. Useful for fintech apps, investor tools, and compliance dashboards that need structured financial data without scraping EDGAR directly.

Government Contracts API — Search federal contract awards, contractor performance data, and procurement history from USASpending.gov and SAM.gov. Built for GovTech startups, BD teams at federal contractors, and researchers studying public procurement patterns.

All three follow the same design philosophy: take a painful government data source and make it queryable in plain English with clean JSON output.


The Broader Point

Government data is incredibly valuable. The FDA, SEC, and federal procurement databases contain information that would cost millions to assemble privately. It's all public. It's all free to use.

The problem is accessibility. These databases were built for internal government use and were opened to the public as an afterthought. The APIs are functional but unfriendly. The documentation assumes you already know the domain.

Wrapper APIs like this one exist to bridge that gap — to take data that's technically public but practically inaccessible, and make it genuinely usable for developers who need it.


Get Started

The API is live and the free tier is open right now:

curl "https://fda-drug-safety-api.onrender.com/drug/adverse-events?name=aspirin"
Enter fullscreen mode Exit fullscreen mode

To get a managed API key, usage analytics, and higher rate limits, find it on RapidAPI by searching "FDA Drug Safety API".

If you build something with it, I'd love to hear about it in the comments. And if there's a specific endpoint or data type you need that isn't covered, drop a feature request — I'm actively expanding the API based on what developers actually need.


Data sourced from openFDA (api.fda.gov). Updated daily. Not intended for direct clinical decision-making.

Top comments (2)

Collapse
 
sam_rivera_87e5b29b7b0de4 profile image
Sam Rivera

this is great. went through similar pain building the moltai app for smoking cessation. openFDA is valuable but the query syntax is rough. thanks for the wrapper.

Collapse
 
linderrogereng profile image
linderroger-eng

Your welcome, let me know if everything works as expected or if there are changes or updates you want to see!