Use openFDA's drug/label endpoint when you need JSON search across label sections with harmonized identifiers (24 fields in the openfda block, including RxCUI, NDC and UNII), and DailyMed's v2 web services when you need the SPL document itself, its version history or its images. The openFDA build keeps only the highest version per set id and refreshes weekly, so it cannot answer what a label said on an earlier date. DailyMed's /spls/{SETID}/history lists every spl_version with its published date, and getFile.cfm downloads any of those versions as a zip. openFDA's skip-based paging stops at 26,000 hits and allows 1,000 requests a day per IP without a key; DailyMed caps pages at 100 records. Neither source is the FDA-approved label: openFDA says its text may not match approved or currently distributed labeling. Store set id, version and published date on every chunk you index. Start by pulling the history for the ten products your users ask about most.
openFDA's drug label endpoint holds one record per label. The pipeline that builds it, in the FDA's public openfda repository, groups every SPL file by set id, sorts the group by version number and keeps the last one. That reduce step decides the core of the DailyMed API vs openFDA question: openFDA is a search index over the current version of each label, and DailyMed is the archive of the documents themselves, every version included.
Both are free, both come from the same Structured Product Labeling submissions, and both are what engineers reach for when a pharma, CRO, pharmacy or health-tech team asks for search, RAG or an LLM tool over US drug label text. They answer different questions. Building on the wrong one shows up late: on the day someone asks what the label said when a patient was prescribed the drug.
This post compares them on what each returns, how you get sections out reliably, how current each is, and what neither gives you. Everything below was checked against the DailyMed v2 web services documentation, the openFDA API documentation, and the openfda pipeline source at its June 2026 commit.
The short answer: which drug label API for which job
Use openFDA when the job is search: find every label whose drug interactions section mentions a term, count labels by pharmacologic class, or resolve a brand name to RxCUIs and NDCs in one call. Its records are JSON with one field per label section, and its harmonized openfda block joins identifiers that the raw SPL keeps in different places.
Use DailyMed when the job needs the document: the authoritative SPL XML, the full version history of a set id, an older version's text, product images, or a feed that updates daily rather than weekly.
For a production system, use both, in a specific arrangement: DailyMed as the system of record you ingest and version, openFDA as a lookup and discovery layer you query live, or from its bulk file inside your perimeter. The rest of this post is the reasoning.
openFDA drug/label | DailyMed v2 web services | |
|---|---|---|
| Format | JSON, one field per section | XML or JSON metadata; SPL XML document |
| Versions | Latest version per set id only | Full history per set id; any version as zip |
| Update frequency | Weekly | Current SPL information; daily, weekly, monthly bulk files |
| Search | Full-text and field search, count aggregations | Filters on identifiers, names, class, dates; no text search |
| Page size | Up to 1,000 records; skip stops at 25,000 | Up to 100 records per page |
| Rate limits | 240/min; 1,000/day per IP without key, 120,000/day with key | None on the web services pages |
| Key | Free key; docs say required | None on the web services pages |
| Bulk | 14 zipped JSON parts, about 265,000 records | Full release plus periodic update zips |
| Images | No | /spls/{SETID}/media |
What each API actually returns
# Latest label for one set id, with the harmonized identifiers curl -s "https://api.fda.gov/drug/label.json?api_key=$OPENFDA_KEY&search=set_id:593f0007-9690-4de5-b1e9-59299e587643&limit=1" # Every label whose interactions section mentions caffeine, newest first curl -s "https://api.fda.gov/drug/label.json?api_key=$OPENFDA_KEY&search=drug_interactions:caffeine&sort=effective_time:desc&limit=100"
BASE="https://dailymed.nlm.nih.gov/dailymed/services/v2" # Labels for one RxCUI, published on or after a date curl -s "$BASE/spls.json?rxcui=312962&published_date=2026-01-01&published_date_comparison=gte&pagesize=100" # The current SPL document for a set id (XML only) curl -s "$BASE/spls/593f0007-9690-4de5-b1e9-59299e587643.xml" -o current.xml # Every version of that label, with the date DailyMed published each one curl -s "$BASE/spls/593f0007-9690-4de5-b1e9-59299e587643/history.json" # Images referenced by the label curl -s "$BASE/spls/593f0007-9690-4de5-b1e9-59299e587643/media.json"
openFDA: JSON fields named after label sections
A record from https://api.fda.gov/drug/label.json carries metadata (set_id, id, version, effective_time) and one array-of-strings field per recognized label section: indications_and_usage, boxed_warning, contraindications, warnings_and_cautions, adverse_reactions, drug_interactions and so on. The schema in the openfda repository lists 179 top-level properties, because many sections have a twin ending in _table that holds the section's tables as raw HTML. The openfda block is the reason to use the API at all. It carries 24 harmonized fields, among them brand_name, generic_name, substance_name, rxcui, product_ndc, package_ndc, unii, spl_set_id, application_number and the four pharmacologic class fields (pharm_class_epc, pharm_class_moa, pharm_class_pe, pharm_class_cs). These fields have .exact keyword variants in the index mapping for exact matching. Without limit, a search returns one record. The largest allowed limit is 1,000 and the largest skip is 25,000, so skip plus limit reaches 26,000 hits. Past that, the paging documentation points you to search_after (follow the Link header, never combine it with skip) or to the bulk download.
DailyMed: metadata as JSON, the document as SPL XML
DailyMed's base URI is https://dailymed.nlm.nih.gov/dailymed/services/, the version (v2) must be in the path, and the extension picks the format. The /spls list returns compact JSON rows of setid, spl_version, title and published_date; /history returns spl_version and published_date per version. The document resource, /spls/{SETID}, returns XML only. The /spls resource has no text search. It filters on identifiers and attributes: ndc, rxcui, setid, unii_code, application_number, drug_name with name_type, labeler, manufacturer, drug_class_code, boxed_warning, dea_schedule_code, marketing_category_code, doctype and published_date with a comparison operator (lt, lte, gt, gte, eq). Pages are capped at 100 records. Errors come back as standard HTTP status codes (404, 415 or 5xx), with additional information in the response header.
Coverage is not the same set
The two sources do not hold the same documents. The openFDA pipeline reads each SPL's document type code and keeps only files whose type name contains "human" or "cellular", so animal labels never reach the endpoint. DailyMed serves every type it publishes, including animal, homeopathic and bulk ingredient labels, and its /spls resource takes a doctype filter so you can restrict a sync to prescription labels (document type 34391-3, HUMAN PRESCRIPTION DRUG LABEL) before you download anything. If a count from one source does not match the other, check document types before you suspect a sync bug.
Finding the right label: NDC, RxCUI and set id
Your users will ask about a drug, and neither API is keyed on drugs. A set id identifies one labeler's label for a product line, and it stays stable across versions. One active ingredient maps to many set ids, because every manufacturer, repackager and relabeler submits its own label: the DailyMed documentation's own example for a single simvastatin RxCUI returned 26 labels.
That fan-out is the first design decision. If your tool answers questions about the reference product, pick the set id of the application holder and store the mapping explicitly. If it answers about whatever a pharmacy dispensed, resolve from the package NDC on the dispensing record. Both APIs can do the resolution: DailyMed through /spls?ndc= or /spls?rxcui=, openFDA through the openfda.package_ndc or openfda.rxcui fields. For exact-match lookups of this kind, a keyword or sparse index beats embeddings, the same reason hybrid dense and sparse search works for codes and drug names.
Getting sections out by LOINC code
Every SPL section carries a LOINC code, in the code system with OID 2.16.840.1.113883.6.1. The code, not the heading text, is what you extract on. Headings vary between labels; codes are a controlled list. openFDA's own pipeline maps codes to its field names through a CSV in the repository, and these are the rows that cover the clinical core of a prescription label:
Note the three warnings rows. Labels in the format introduced by the 2006 Physician Labeling Rule use one Warnings and Precautions section (43685-7). Older-format labels split Warnings (34071-1) and Precautions (42232-9). A system that extracts only 43685-7 returns nothing for those labels and reports it as a missing section. Query all three codes and record which one you found.
import xml.etree.ElementTree as ET
V3 = "{urn:hl7-org:v3}"
NS = {"v3": "urn:hl7-org:v3"}
LOINC = "2.16.840.1.113883.6.1"
def _clean(elem):
return " ".join("".join(elem.itertext()).split()) if elem is not None else ""
def section_text(sec):
"""Title, own text, then each subsection, in document order."""
parts = [_clean(sec.find("v3:title", NS)), _clean(sec.find("v3:text", NS))]
for sub in sec.findall("v3:component/v3:section", NS):
parts.append(section_text(sub))
return "\n\n".join(p for p in parts if p)
def extract(xml_path, codes):
root = ET.parse(xml_path).getroot()
meta = {
"set_id": root.find("v3:setId", NS).get("root"),
"version": int(root.find("v3:versionNumber", NS).get("value")),
"effective_time": root.find("v3:effectiveTime", NS).get("value"),
}
found = []
for sec in root.iter(f"{V3}section"):
code = sec.find("v3:code", NS)
if code is not None and code.get("codeSystem") == LOINC and code.get("code") in codes:
found.append({"loinc": code.get("code"), "text": section_text(sec)})
return meta, found
# Warnings, in either label format
meta, sections = extract("current.xml", {"43685-7", "34071-1", "42232-9"})Extracting a section from SPL XML
This reads a DailyMed SPL file with the Python standard library, finds sections by LOINC code, and keeps the subsection structure instead of flattening it. It also returns the set id, the version number and the document's effectiveTime; take the published date for each version from /history. Two limits are deliberate. Tables inside a section's text are flattened to words, so if your users ask about dosing tables, parse table elements separately and keep their rows. And the function matches a code wherever it appears, so a subsection that reuses a parent's code would be returned twice; deduplicate on the element if you hit that.
What openFDA does to the same section
The openFDA conversion makes three choices you inherit. A section whose code is not in its CSV becomes spl_unclassified_section, and unclassified subsections are dropped from output entirely, since their text already sits in the parent. Section text is collected recursively, so a classified subsection's words appear both inside its parent's string and again in its own field. And each section becomes one flat string with subsection headings run into the prose, with tables copied separately as HTML into the matching _table field. For keyword search that is fine. For chunking it is not: you lose the boundary between 5.1 and 5.2 inside Warnings and Precautions, which is the boundary a citation needs. openFDA's documentation warns of "considerable variation between drug products in terms of these sections and their contents", and the flattening hides that variation rather than resolving it. If you are tempted to parse the label PDF instead, the case for structured SPL over long-horizon PDF and OCR parsing for RAG is that you get the section codes for free.
| LOINC code | Section | openFDA field |
|---|---|---|
| 34066-1 | Boxed Warning | boxed_warning |
| 34067-9 | Indications and Usage | indications_and_usage |
| 34068-7 | Dosage and Administration | dosage_and_administration |
| 34070-3 | Contraindications | contraindications |
| 43685-7 | Warnings and Precautions | warnings_and_cautions |
| 34071-1 | Warnings | warnings |
| 42232-9 | Precautions | precautions |
| 34084-4 | Adverse Reactions | adverse_reactions |
Versions and freshness: what did the label say on date X
openFDA updates weekly and, as the pipeline code shows, serves the highest version per set id. A label revised twice since your user's question date has two versions openFDA no longer holds. Its effective_time field tells you which version you have; it cannot give you another.
DailyMed has the history. /spls/{SETID}/history returns every spl_version with its published_date, 100 entries per page. The web services page then documents a second URL, for downloading any of those versions:
# Download any listed version of a label as a zip (SPL XML plus images) curl -sL "https://dailymed.nlm.nih.gov/dailymed/getFile.cfm?type=zip&setid=593f0007-9690-4de5-b1e9-59299e587643&version=2" -o v2.zip
Do not compute version numbers yourself. They are not guaranteed to run 1, 2, 3: the /spls example in DailyMed's own documentation shows one label at spl_version 90384 next to others at 1 and 4. Always take the version list from /history and download only versions it names.
The per-set-id zip download also reports status. DailyMed documents a response header, X-DAILYMED-LABEL-LAST-UPDATED, and a status of ACTIVE or ARCHIVED for the latest-version zip. An archived label still has a history worth keeping, because the question about what a patient was told does not expire when the product leaves the market.
So the documents exist. What does not exist is a query over them. DailyMed has no endpoint that returns Contraindications as of 2023-05-01, no diff between versions, and no way to ask which labels added a phrase in a period. Answering "what did the label say on date X" means listing the history, picking the last version whose published date is on or before X, downloading it, and extracting the section. Doing that per question is slow and fragile; doing it once per label and storing the result is an ingestion job.
Three dates travel with a label, and they are different facts. DailyMed's published_date is when DailyMed posted the version. The SPL's effectiveTime is the date written into the document. An FDA approval date is a third thing that neither field records. Pick one for your as-of logic, name it in the answer, and never present it as the approval date.
If you would rather start from a record than build one, AsOf Drug Labels is our open-source record of every published version of 5,393 US DailyMed labels and 206 EU product texts as git history, one commit per version and one file per section, with a local MCP server that makes no network calls. The US record runs to 2026-10-30, its dates are when DailyMed showed each version rather than FDA approval dates, and the repository is at github.com/Particula-Tech/asof-drug-labels.
Freshness is the other half. openFDA is up to a week behind a label that changed today. DailyMed's web services return current SPL information, with a db_published_date in the response metadata, and its download page offers daily, weekly and monthly update files. If your tool must reflect a new boxed warning the day it posts, sync from DailyMed's daily file; how you trigger and reconcile that sync is the same problem covered in RAG update triggers.
Building RAG on drug label text
The label-specific part of a RAG design is small and strict. Every chunk carries the set id, the version number, the published date of that version, the LOINC code of its section and the subsection title. Those map directly onto a general effective-dating schema: set id is the document family, version is the version ordinal, and published date is the start of the period the version applied. Filtering on them at query time, ranking current versions above superseded ones and splitting archive from live collections are covered in version-aware RAG for superseded documents, and none of it changes for labels.
What does change is the citation. An answer that quotes a label should name the product, the section, the version and its date, and the system should check the quoted sentence against the stored section text for that exact version before showing it. A paraphrase that matches the current version but was attributed to an older one is the failure that matters here, because label text is what medical information, pharmacovigilance and regulatory teams get asked to defend. Store versions you can quote from, not just embeddings of them.
The deployment question is shorter than it looks. Label text is public, so the documents themselves are not the sensitive part. The questions are: a medical information team's queries can reveal an unpublished safety concern or a product strategy, and in regulated work the retrieval log, the prompt and the model's answer become records. Mirror DailyMed's bulk files and run the index and the model inside your own network, and no third party sees which molecules your team is asking about. That changes the openFDA arrangement too: every live search string goes to api.fda.gov, so load its bulk JSON into the same network and query it there. Kept that way, the record of what the system answered stays under the same controls as the rest of your quality system, a point the EU GMP Annex 22 draft makes explicit for GMP-critical uses. More on picking and wiring the surrounding tools is on the AI development tools pillar.
Bulk downloads vs paging the API
Paging is for lookups. If you want the whole corpus, download it.
Building a history from bulk files means keeping every update file you apply, from the day you start; versions published before that day come from getFile.cfm, one set id at a time. For scale, the October 2026 monthly update file covers 4,131 labels in 1.67 GB. OTC, homeopathic, animal and remainder labels are separate releases; the human OTC set alone runs to 12 parts.
A sensible ingestion order: load the human prescription full release once, apply daily update files from then on, pull history and older versions only for the set ids your users ask about, and use openFDA's harmonized fields to resolve names and codes to set ids.
| openFDA bulk | DailyMed bulk | |
|---|---|---|
| Contents | JSON, latest version per set id | SPL zips (XML plus images) |
| Size | About 265,000 records in 14 zipped parts, roughly 1.8 GB | Human prescription full release in 6 parts, about 16.8 GB and 55,196 files |
| Cadence | Rebuilt with the weekly update | Full release plus daily, weekly and monthly update zips |
| History | None | Per-version history via /history and getFile.cfm |
What to do this week
Take the ten products your users ask about most. For each, resolve the set id you mean to treat as the reference label, call /spls/{SETID}/history.json, and count the versions. Download the current SPL and extract Boxed Warning, Indications and Usage, Contraindications, and whichever warnings code that label uses. Then compare the extracted sections with the same fields from openFDA for those ten labels and write down every place the two differ: a missing section, a merged subsection or a version mismatch. That list is the specification for your ingestion layer.
FAQ
Quick answers to the questions this post tends to raise.



