How to Get Every FDA-Approved Drug with One Line of Code
Get a list of every pharmaceutical drug in the United States with code (or without).
The US Food and Drug Administration (FDA) is required to approve every drug and medical device that medical professionals are allowed to give to Americans. The FDA tracks thousands of drugs and devices that have been on the market dating back to 1939.
Thankfully, the FDA provides a web API, where we can use code to get an updated list of all of the drugs and medical devices on the market.
Further Reading: What the Heck is an API?
TL;DR (Too Long; Didn’t Read)
The rest of the article explains the openFDA API and the command line for new developers. To quickly get the data, you can use wget
on Mac or Linux:
wget https://download.open.fda.gov/drug/drugsfda/drug-drugsfda-0001-of-0001.json.zip
Or curl
on Windows:
curl.exe -o drugs.json.zip https://download.open.fda.gov/drug/drugsfda/drug-drugsfda-0001-of-0001.json.zip
Or visit this link to download the data directly.
The openFDA API
The FDA’s API provides data on multiple FDA-approved products:
- Medical devices
- Drugs
- Food
- Tobacco
And so on. We’ll use the Drugs@FDA API to get details on every drug approved by the FDA.
Finding the Data
Finding the API link requires some clicking around. (Hint: the best source is NOT clicking Drugs@FDA above but rather going to a page buried under Download the Data in the sidebar.)
The full API link is:
https://download.open.fda.gov/drug/drugsfda/drug-drugsfda-0001-of-0001.json.zip
The way we got this was to go to the Downloads page:
Under How to download data, click “available at here” (circled in red below).
This will show you a JSON-ified list of links for every FDA API endpoint, including Devices, Tobacco, Food, etc. Unroll the JSON by clicking on the little grey triangles to the left of the labels. The Drugs@FDA link is in pink below.
The API link:
https://download.open.fda.gov/drug/drugsfda/drug-drugsfda-0001-of-0001.json.zip
Download the Data: Without Code
You can download the Drugs API data without any code, since it’s just a zip file sitting on one of FDA’s servers.
To get the data, copy and paste the API link into your browser:
https://download.open.fda.gov/drug/drugsfda/drug-drugsfda-0001-of-0001.json.zip
Your browser will automatically download the FDA Drugs data as a zipped JSON file. Just unzip it and then you’ll get a file with all of the drug data in it.
As of March 2023, this JSON file has about 2,998,000 lines, with 26,316 listed drugs.
Download the Data: With Code
We can also get the data from the command line using curl
.
Why use code if it’s so easy to download with Chrome or Firefox? Because then we can schedule the download to run whenever we want it to, such as daily or weekly. On Windows, we can use schtasks
for this, and on Mac and Linux we can use cron
.
First open your command line app (Terminal on Mac or Command Prompt on Windows).
On the command line, type:
curl -o drugs.json.zip https://download.open.fda.gov/drug/drugsfda/drug-drugsfda-0001-of-0001.json.zip
If you’re on Windows, type curl.exe
instead of just curl
.
Then curl
will download the zip file for you on your computer. You can unzip the file to get a JSON file of all of the FDA Drug data.
If we scroll through the JSON file, we can see the data on all 26,000 drugs (like isotretinoin), including their route, type, Rx concept unique identifier (rxcui
), and more.
Questions and Feedback
If you have questions or feedback, email us at protobioengineering@gmail.com or message us on Instagram (@protobioengineering).
If you liked this article, consider supporting us by donating a coffee.