Skip to main content
Tutorial

PubMed API for AI Agents: Search, Summaries, Full Text

Search PubMed, fetch summaries, convert PMID to DOI and pull PMC full text from an agent, without calling E-utilities yourself.

fastcrw
By RecepNovember 10, 20267 min read

By the fastCRW team · Catalogue figures checked 2026-11-05 against GET /v1/data · Verify independently before relying on any figure.

A PubMed API lets a program search the National Library of Medicine's biomedical literature, fetch a record, and convert between PMIDs, PMCIDs and DOIs. This guide shows those calls for an AI agent or a Python script, using the PubMed and Europe PMC providers in the Pergamon catalogue. Every call below returned HTTP 200 when we ran it on 2026-11-05.

E-utilities in one paragraph

PubMed's official interface is NCBI's E-utilities, a set of server endpoints that take a database name and parameters. The NCBI guide says it "recommends that users post no more than three URL requests per second", and it warns that "failure to comply with this policy may result in an IP address being blocked". If you call E-utilities directly from a loop, you own that limit. Calling through Pergamon, your agent sends one request per question to one endpoint, and the upstream limits still apply.

Search by concept with entity-search

The entity-search capability on the pubmed provider takes a free-text query in text, and it matches diseases, drugs and other concepts in the record. Use it when the question is a concept rather than an exact keyword phrase:

curl "https://api.fastcrw.com/v1/data/pubmed/entity-search?text=crispr%20sickle%20cell" \
  -H "Authorization: Bearer $CRW_API_KEY"

The first result, trimmed to the fields an agent usually needs, is:

{
  "pmid": 40763956,
  "title": "CRISPR therapy for sickle cell disease.",
  "journal": "BMJ",
  "date": "2025-08-05T00:00:00Z",
  "doi": "10.1136/bmj.r1596"
}

For a keyword search over a wider literature, use Europe PMC's search capability. It takes a query and an optional pageSize, and it covers PubMed, PMC, preprints and patents:

curl "https://api.fastcrw.com/v1/data/europepmc/search?query=crispr%20sickle%20cell&pageSize=3" \
  -H "Authorization: Bearer $CRW_API_KEY"

The first two titles in that run were "CRISPR-Based Mediated Reactivation of Fetal Hemoglobin as a Therapeutic Strategy for Hemoglobinopathies: Evidence from Preclinical to Clinical Trials in Sickle Cell Disease and β-Thalassemia." and "India's indigenous CRISPR-based gene-editing therapy for sickle cell disease: innovation to equitable implementation."

Fetch a summary

The summary capability returns the bibliographic fields for a PubMed ID. It needs db and id. This call fetches PMID 31378106:

curl "https://api.fastcrw.com/v1/data/pubmed/summary?db=pubmed&id=31378106" \
  -H "Authorization: Bearer $CRW_API_KEY"

The record sits under data.result["31378106"]. Its title is "Estrogen Receptor-β Mediates Estradiol-Induced Pregnancy-Specific Uterine Artery Endothelial Cell Angiotensin Type-2 Receptor Expression.", its source is "Hypertension", and its pubdate is "2019 Oct". The DOI is in the record as well, so an agent can cite the paper without a second call.

Convert between PMID, PMCID and DOI

Many pipelines hold one ID and need another. The idconvert capability takes ids and returns the DOI and PMCID for a PMID. The parameter is ids, not id:

curl "https://api.fastcrw.com/v1/data/pubmed/idconvert?ids=31378106" \
  -H "Authorization: Bearer $CRW_API_KEY"

The record for that PMID returns "doi": "10.1161/HYPERTENSIONAHA.119.13429" and "pmcid": "PMC6739159". The upstream response also carries warnings about missing email and tool parameters. Those warnings come from NCBI's own service and are not errors, so you can drop them from what your agent shows.

Open-access full text

The fulltext capability takes an id that is a PMCID, not a PMID. It returns the body of a PubMed Central open-access article as BioC JSON, with each passage tagged by its section (title, abstract, introduction, methods, results and discussion). Run it on a PMCID from idconvert:

curl "https://api.fastcrw.com/v1/data/pubmed/fulltext?id=PMC6893450" \
  -H "Authorization: Bearer $CRW_API_KEY"

This call returned about 96 KB in our run. It works only for articles that PubMed Central holds as open access. For a paper outside that set, fulltext cannot return the body, so check the record first and link to the publisher when there is no open-access copy.

The NLM licence line on the PubMed row reads: "Public domain information on the National Library of Medicine (NLM) Web pages may be freely distributed and copied." The full text of an individual article carries its own licence, so check that in the article's metadata before you redistribute it.

Citations and MeSH terms

Europe PMC's citations capability takes source and id, and it lists papers that cite a given record. For PMID 31378106 the call is europepmc/citations?source=MED&id=31378106, and its response reports a hitCount and a citationList.

The mesh-search capability maps a plain-language label to MeSH headings, which are the controlled vocabulary PubMed indexes with. It takes label, and for the label asthma it returns headings such as "Asthma", "Asthma, Aspirin-Induced" and "Anti-Asthmatic Agents".

The agent flow

A literature agent runs the same sequence for every question and stops early when a step returns nothing useful. As an MCP tool call, the first step looks like this:

{"name": "crw_get_data", "arguments": {"provider": "pubmed", "capability": "entity-search", "options": {"text": "crispr sickle cell"}}}

The MCP server runs the same capability, and its result is capped at 256 KiB. A large full-text body can exceed that cap and be refused with result_too_large, which is refunded for server sources. Use fulltext over MCP only for articles you expect to be short, or call it over REST and keep the body out of the model's context.

Which call answers which question

Most literature tasks need one or two of these calls. The table lists the capability, the option it requires and what it is for:

QuestionCapabilityRequired option
Find papers about a conceptpubmed entity-searchtext
Keyword search across PubMed and preprintseuropepmc searchquery
Bibliographic fields for a known PMIDpubmed summarydb, id
DOI and PMCID for a PMIDpubmed idconvertids
Body text of an open-access articlepubmed fulltextid (a PMCID)
Papers that cite a recordeuropepmc citationssource, id
Controlled vocabulary for a topicpubmed mesh-searchlabel

Run GET /v1/data/find?provider=pubmed to see the optional options for each capability. A required option that is missing is refused with invalid_options, and the error names the option, so a loop can fix its own call.

A short Python flow with the SDK

This script fetches a summary, converts the PMID, and prints what an agent needs to cite the paper. It uses the same two capabilities as the REST calls above:

# pip install crw
from crw import CrwClient

client = CrwClient()  # reads CRW_API_KEY
summary = client.get_data("pubmed", "summary", {"db": "pubmed", "id": "31378106"})
record = summary["data"]["result"]["31378106"]
print(record["title"])

ids = client.get_data("pubmed", "idconvert", {"ids": "31378106"})
doi, pmcid = ids["data"]["records"][0]["doi"], ids["data"]["records"][0]["pmcid"]
print(doi, pmcid)
print(summary["provenance"]["attributionText"])

The run printed the title "Estrogen Receptor-β Mediates Estradiol-Induced Pregnancy-Specific Uterine Artery Endothelial Cell Angiotensin Type-2 Receptor Expression.", then 10.1161/HYPERTENSIONAHA.119.13429 PMC6739159, then "Source: NCBI / PubMed". Keep the attribution line with the answer, because NCBI's own attribution is what the record carries.

The full agent sequence

  1. Search by concept with entity-search and keep the PMIDs of the hits.
  2. Fetch a summary for the hits that look relevant, and keep the title, journal, publication date and DOI.
  3. Call idconvert for any hit whose summary lacks a DOI or PMCID.
  4. Call fulltext only for a PMCID. When there is no PMCID, cite the DOI and link to the publisher instead.
  5. Call Europe PMC citations for the papers the answer depends on, to show what has built on them.

Keeping each step separate makes the agent's answer traceable. Every claim can point to a PMID, a DOI and the attribution line from the call that produced it.

Validate before you cite

An agent should not cite a paper from a model's memory. Take the title, DOI and PMID from a PubMed record, and check that the DOI from idconvert matches the one in the summary. When a record has no DOI, say so in the answer and cite the PMID, rather than inventing a DOI.

Rate limits in practice

NCBI asks for no more than three requests per second and warns that a client that ignores the policy can be blocked by IP address. An agent that answers one question with a dozen calls should run them one after another and keep the results, so it does not repeat the same call.

What this does not do

  • It does not return full text for paywalled or non-open-access articles.
  • It does not do clinical decision support. Treat the records as literature, not as medical advice.
  • It does not replace a systematic-review database. Search strategies, screening and deduplication still need a human or a dedicated tool.
  • Upstream services can refuse or time out. A failed call returns success: false and is not billed.

Sources

Related: OpenAlex API in Python · Public data API for AI agents · Pergamon catalogue

FAQ

Frequently asked questions

Is there an official PubMed API?
The official interface is NCBI's E-utilities, a set of server endpoints. NCBI asks that clients send no more than three requests per second. Pergamon exposes the same records through a catalogue call, so your agent needs one key and one request shape, and the upstream limits still apply.
Why does fulltext need a PMCID instead of a PMID?
PubMed Central stores the full text of open-access articles under its own identifier. Convert a PMID with idconvert first, and use the pmcid from that record in the fulltext call.
Can I use the full text of any PubMed article?
The fulltext capability only returns PubMed Central open-access articles. The NLM licence on the PubMed row covers NLM's own web pages, and each article carries its own licence, so check that before you redistribute it.

Get Started

Try fastCRW free

Run a live request in the playground — no signup required. Or grab a free API key with 500 credits, earn up to 500 more, no credit card.

Continue exploring

More tutorial posts

View category archive