DailyMed Drug Label Database
Overview
DailyMed is the National Library of Medicine's official repository of FDA-approved drug labeling information, containing 140,000+ structured product labels (SPLs) for prescription drugs, OTC medications, biologics, and vaccines. The REST API (v2) provides structured JSON/XML access to the full label content including indications, dosage, warnings, contraindications, adverse reactions, and packaging data — with no authentication required.
When to Use
- Retrieving official FDA-approved prescribing information for a drug by name, NDC code, or set ID
- Extracting structured label sections (indications, warnings, dosage, adverse reactions) for pharmacological research
- Looking up all marketed formulations of an active ingredient with packaging and NDC codes
- Cross-referencing drug labels using RxCUI identifiers from RxNorm integration
- Building drug information pipelines that require authoritative FDA label content (not user-reported data)
- Comparing label content across brand name and generic formulations of the same drug
- For adverse event reports from FAERS, use
fda-databaseinstead; DailyMed contains label text, not post-market safety signals - For drug-drug interaction severity data, use
ddinter-database; DailyMed label text is unstructured for interactions
Prerequisites
- Python packages:
requests,pandas,matplotlib - Data requirements: drug names, NDC codes, set IDs, or RxCUI identifiers
- Environment: internet connection; no API key required
- Rate limits: no officially published limit; ~100 requests/minute is safe for polite access; add
time.sleep(0.3)in batch loops
pip install requests pandas matplotlib
Quick Start
import requests
BASE = "https://dailymed.nlm.nih.gov/dailymed/services/v2"
# Search drug labels by name
r = requests.get(f"{BASE}/spls.json", params={"drug_name": "metformin", "pagesize": 5})
r.raise_for_status()
data = r.json()
print(f"Total labels found: {data['metadata']['total_elements']}")
for spl in data["data"][:3]:
print(f" {spl['title']!r:60s} setid={spl['setid']}")
Core API
Query 1: Search Drug Labels by Name
Search for structured product labels (SPLs) using drug name. Returns paginated list of matching labels with set IDs.
import requests
import pandas as pd
BASE = "https://dailymed.nlm.nih.gov/dailymed/services/v2"
def search_spls(drug_name, pagesize=20, page=1):
"""Search DailyMed SPLs by drug name. Returns list of label summaries."""
r = requests.get(f"{BASE}/spls.json",
params={"drug_name": drug_name, "pagesize": pagesize, "page": page},
timeout=15)
r.raise_for_status()
return r.json()
result = search_spls("atorvastatin", pagesize=10)
meta = result["metadata"]
print(f"Search: 'atorvastatin' → {meta['total_elements']} labels across {meta['total_pages']} pages")
df = pd.DataFrame(result["data"])
print(df[["setid", "title", "published_date"]].to_string(index=False))
# setid title published_date
# 8f6c7c7c-... ATORVASTATIN CALCIUM tablet 2024-03-15
# a4b7d3e1-... ATORVASTATIN CALCIUM tablet, film coated 2023-11-20
Query 2: Retrieve Full Label by Set ID
Fetch the complete structured product label for a specific drug using its set ID. Returns all label sections including indications, warnings, dosage, and adverse reactions.
import requests
BASE = "https://dailymed.nlm.nih.gov/dailymed/services/v2"
def get_spl(setid):
"""Retrieve full SPL document by set ID. Returns label metadata and XML/JSON."""
r = requests.get(f"{BASE}/spls/{setid}.json", timeout=20)
r.raise_for_status()
return r.json()
# Use a known set ID from search results
setid = "8f6c7c7c-1f7f-4f1a-af86-8b2eef2a8b2c" # example atorvastatin label
label = get_spl(setid)
data = label["data"]
print(f"Title: {data.get('title')}")
print(f"Set ID: {data.get('setid')}")
print(f"Published: {data.get('published_date')}")
print(f"Version: {data.get('version')}")
# Access structured sections
if "sections" in data:
sections = data["sections"]
print(f"\nLabel sections ({len(sections)} total):")
for sec in sections[:5]:
print(f" [{sec.get('loinc_code', 'N/A')}] {sec.get('title', 'Untitled')}")
Query 3: Search by NDC Code
Look up drug labels by National Drug Code (NDC) — useful when you have a product barcode or dispensing record.
import requests
BASE = "https://dailymed.nlm.nih.gov/dailymed/services/v2"
def search_by_ndc(ndc_code):
"""Find SPL by NDC code (formatted as XXXXX-XXXX-XX or without dashes)."""
r = requests.get(f"{BASE}/spls.json",
params={"ndc": ndc_code},
timeout=15)
r.raise_for_status()
return r.json()
# NDC for Lipitor 10mg (atorvastatin)
result = search_by_ndc("0071-0155-23")
if result["data"]:
spl = result["data"][0]
print(f"Drug: {spl['title']}")
print(f"Set ID: {spl['setid']}")
print(f"Published: {spl['published_date']}")
else:
print("No label found for this NDC")
Query 4: Retrieve Packaging Information
Get detailed packaging data (NDC codes, package types, quantities) for a specific drug label by set ID.
import requests
import pandas as pd
BASE = "https://dailymed.nlm.nih.gov/dailymed/services/v2"
def get_packaging(setid):
"""Retrieve packaging information for a label (NDC codes, dosage forms, quantities)."""
r = requests.get(f"{BASE}/spls/{setid}/packaging.json", timeout=15)
r.raise_for_status()
return r.json()
setid = "8f6c7c7c-1f7f-4f1a-af86-8b2eef2a8b2c" # example setid
pkg = get_packaging(setid)
if pkg["data"]:
packages = pkg["data"]
print(f"Packaging variants: {len(packages)}")
df = pd.DataFrame(packages)
# Common fields: ndc, dosage_form, route, marketing_status
for col in ["ndc", "dosage_form", "route", "marketing_status"]:
if col in df.columns:
print(f"\n{col.upper()}:")
print(df[col].value_counts().head(5))
Query 5: Look Up by RxCUI
Retrieve drug labels using RxNorm Concept Unique Identifier (RxCUI) for integration with RxNorm-based clinical systems.
import requests
import time
BASE = "https://dailymed.nlm.nih.gov/dailymed/services/v2"
def get_spls_by_rxcui(rxcui):
"""Get all SPLs associated with an RxCUI. Returns list of set IDs and titles."""
r = requests.get(f"{BASE}/rxcuis/{rxcui}/spls.json", timeout=15)
r.raise_for_status()
return r.json()
# RxCUI for atorvastatin: 83367
rxcui = "83367"
result = get_spls_by_rxcui(rxcui)
print(f"SPLs for RxCUI {rxcui} (atorvastatin):")
for spl in result["data"][:5]:
print(f" {spl['setid']} | {spl['title'][:70]}")
print(f" Total: {result['metadata']['total_elements']} labels")
Query 6: Search Drug Names Index
List all standardized drug names in DailyMed — useful for name normalization and autocomplete in drug lookup pipelines.
import requests
BASE = "https://dailymed.nlm.nih.gov/dailymed/services/v2"
def search_drug_names(query, pagesize=20):
"""Search the DailyMed drug name index for name normalization."""
r = requests.get(f"{BASE}/drugnames.json",
params={"drug_name": query, "pagesize": pagesize},
timeout=15)
r.raise_for_status()
return r.json()
result = search_drug_names("metformin")
print(f"Drug name matches for 'metformin': {result['metadata']['total_elements']}")
for entry in result["data"][:8]:
print(f" {entry['drug_name']}")
# METFORMIN HYDROCHLORIDE
# METFORMIN HYDROCHLORIDE AND SITAGLIPTIN PHOSPHATE
# METFORMIN HYDROCHLORIDE AND SAXAGLIPTIN
Query 7: Batch Label Section Extraction
Extract specific label sections (e.g., indications, warnings) from multiple drug labels for comparative an