# Mining Pubmed Literature

Searches and fetches PubMed and PMC via NCBI E-utilities (ESearch then EFetch/ESummary)...

- Repository: https://github.com/maziyarpanahi/openmed (5755 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add maziyarpanahi/openmed --skill mining-pubmed-literature -g -a claude-code -y`
Codex: `npx skills add maziyarpanahi/openmed --skill mining-pubmed-literature -g -a codex -y`
Cursor: `npx skills add maziyarpanahi/openmed --skill mining-pubmed-literature -g -a cursor -y`
Gemini CLI: `npx skills add maziyarpanahi/openmed --skill mining-pubmed-literature -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add maziyarpanahi/openmed`

## Description

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; an optional free API key raises rate limits from 3 to 10 requests/second.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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).

```python
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"]}

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/mining-pubmed-literature/SKILL.md
