mining-pubmed-literature
What it does
This skill searches PubMed and PubMed Central for medical research on a topic, then downloads the abstracts or full text. It is for researchers who need citations, abstracts or a corpus of articles.
When to use it
- ✓When you want citations or abstracts about a condition, drug or gene.
- ✓When you need a corpus of biomedical articles for entity extraction.
- ✓When you want a reproducible MeSH-based literature search with date limits.
Skill link
https://github.com/maziyarpanahi/openmed/blob/master/skills/mining-pubmed-literature/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Find recent PubMed abstracts about metformin and heart failure, and give me the citations.”
5 new skills a week. 1 minute to read.
How it works
The agent runs a search on the public NCBI service to get article IDs, then downloads the records for those IDs in batches, following the service's rate limits.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Mining PubMed & PMC literature (NCBI E-utilities)
Search PubMed (citations/abstracts) and PMC (full text) programmatically
with NCBI E-utilities — the stable HTTP interface to Entrez. The core pattern
is two steps: ESearch returns matching record IDs (PMIDs), then EFetch (or
ESummary) downloads the records. The Entrez History server (usehistory=y)
lets you chain the two without re-sending thousands of IDs.
E-utilities are public. No key is required, but a free API key raises your limit from 3 to 10 requests/second and is strongly recommended for batch work.
When to use
- OpenMed extracted a diagnosis, drug, or gene and you want supporting literature.
- You need abstracts to summarize or to assemble a corpus for biomedical NER.
- You want MeSH-anchored, reproducible searches (date ranges, article types).
For ClinicalTrials.gov use searching-clinicaltrials; this skill is for the
published literature.
Quick start (real E-utilities calls)
Base URL: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/. JSON for ESearch/
ESummary via retmode=json; EFetch returns text or XML (no JSON for PubMed).
import requests, time
BASE = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils"
API_KEY = None # set to your free NCBI key to get 10 req/s instead of 3
def _params(**kw):
if API_KEY:
kw["api_key"] = API_KEY
return kw
def esearch(term: str, retmax: int = 50) -> dict:
"""Find PMIDs; usehistory=y stores them on the Entrez History server."""
r = requests.get(f"{BASE}/esearch.fcgi", params=_params(
db="pubmed", term=term, retmax=retmax,
usehistory="y", retmode="json"), timeout=30)
r.raise_for_status()
res = r.json()["esearchresult"]
return {"count": int(res["count"]), "ids": res["idlist"],
"webenv": res["webenv"], "query_key": res["querykey"]}
def efetch_abstracts(webenv: str, query_key: str, retmax: int = 50) -> str:
"""Pull abstracts by reference to the stored result set (no ID list needed)."""
r = requests.get(f"{BASE}/efetch.fcgi", params=_params(
db="pubmed", WebEnv=webenv, query_key=query_key,
retmax=retmax, rettype="abstract", retmode="text"), timeout=60)
r.raise_for_status()
return r.text
hits = esearch('("type 2 diabetes"[MeSH]) AND metformin AND 2023:2025[pdat]')
print(hits["count"], "papers")
abstracts = efetch_abstracts(hits["webenv"], hits["query_key"])
Equivalent cURL (search then fetch one PMID's abstract):
curl "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=metformin&retmode=json"
curl "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=38000000&rettype=abstract&retmode=text"
ESummary for structured metadata
When you need titles/authors/journal/date as JSON (not the full abstract), use ESummary — it returns one record per ID:
def esummary(ids: list[str]) -> dict:
r = requests.get(f"{BASE}/esummary.fcgi", params=_params(
db="pubmed", id=",".join(ids), retmode="json"), timeout=30)
r.raise_for_status()
return r.json()["result"] # keyed by PMID: title, pubdate, source, authors…
For PMC full text, repeat with db=pmc and EFetch rettype=""/retmode=xml
(JATS XML). Respect each article's license before redistributing full text.
Workflow
- Build the query. Combine OpenMed-extracted terms with MeSH tags and field
filters:
"<disease>"[MeSH] AND <drug>[tiab] AND 2020:2025[pdat]. Use[tiab](title/abstract),[au](author),[pdat](publication date). - ESearch with
usehistory=yto captureWebEnv+query_keyand the count. - Batch-fetch with EFetch/ESummary in pages of ≤ ~200 IDs (or by history), sleeping to stay under your rate limit.
- Parse abstracts/metadata; store PMID, title, journal, date, abstract text.
- NER the abstracts with
openmed.analyze_textto extract diseases, drugs, genes, and oncology entities for downstream synthesis.
Hand-off to / from OpenMed
- OpenMed facts → query.
openmed.analyze_text(note)yields Disease, Pharmaceutical, Genomics, and Oncology entities. Turn the top spans into the ESearchterm(optionally grounded: ICD-10 label, RxNorm ingredient, gene symbol) to retrieve targeted evidence. - Abstracts → OpenMed. Feed fetched abstracts straight into
openmed.analyze_text(abstract, model_name="disease_detection_superclinical")(or a Genomics/Oncology mod
FAQ
Does it need an API key?
No. A free key is optional, and it raises the allowed request rate for large batch work.
Is this for clinical trials?
No. Registered clinical trials are covered by a separate trial search skill.
Can it search by MeSH terms?
Yes. The skill supports MeSH-anchored searches and date ranges.
Details
Original description by the author
Searches and fetches PubMed and PMC via NCBI E-utilities (ESearch then EFetch/ESummary) to gather biomedical evidence and build text corpora. Use when the user wants citations for a condition or drug, abstracts to summarize, MeSH-based searches, or a corpus of literature to run NER over. Trigger keywords: PubMed, PMC, NCBI, E-utilities, ESearch, EFetch, ESummary, MeSH, PMID, literature search, abstracts, evidence. Pairs adjacent to OpenMed: fetched abstracts feed openmed.analyze_text for biomedical NER, and OpenMed-extracted diagnoses/drugs/genes become the search terms. E-utilities are public
repo: maziyarpanahi/openmed
Popularity
- GitHub stars
- 5.8k
- Ranking position
- #14713
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
annotating-variants
5.8kHelps your agent predict what a genetic variant does, convert HGVS names to genome positions and attach population frequencies, using free public annotators.
ask-openmed
5.8kHelps your agent pick the right OpenMed workflow for a clinical text request, starting with a privacy check whenever patient data may be present.
assembling-fhir-bundles
5.8kPackages several FHIR health records into one transaction Bundle ready to send to an EHR, with the internal references linked correctly.
auditing-deid-leakage
5.8kScans de-identified clinical text for leftover identifiers such as SSNs, card numbers, emails and dates, and blocks release if any remain.
Similar skills
graincrawl
394kLets your agent search your saved Granola meeting notes and transcripts, check how fresh they are, and count them over a period.
notcrawl
394kLets your agent search a saved copy of your Notion workspace, look up pages and databases, and export pages to Markdown files.
knowledge-entities
394kHelps your agent identify people, companies, and projects, then write sourced profile pages for them in your Knowledge vault.