PubMed Search
Search the full PubMed database (30M+ articles) — abstracts for all records, full text for PMC open-access articles.
What PMC Harvest misses: PubMed indexes ~30M biomedical articles; only ~4M (13%) are in PMC with full text. This skill retrieves abstracts for the remaining 26M non-OA articles, making it suitable for comprehensive literature review.
Core Workflow
Search PubMed (db=pubmed) → get PMIDs
→ esummary: metadata for all (title, authors, journal, PMID, DOI)
→ efetch: structured abstract XML for any PMID
→ idconv: check if PMID maps to PMCID
→ if PMCID exists → OAI-PMH full text (PMC open access)
→ if no PMCID → abstract only (non-OA)
Features
- PubMed-wide search —
db=pubmed, covers all 30M+ indexed articles - Abstract for every article —
efetchwithrettype=abstract&retmode=xml - Auto full-text fallback — if PMID maps to PMCID, retrieves full text via OAI-PMH
- OA/non-OA annotation — every PMID auto-labeled as
[OA]or[非OA]based on PMC availability - Batch processing — search journals, keywords, MeSH terms
- No API key required — public NCBI E-utilities (3 req/s rate limit)
Output Format — OA/非OA 标注(强制规则)
每次向用户呈现参考文献列表时,必须逐条标注 OA 状态。
标注规则:
- 若该文献存在 PMCID(即 pmcid 非空),标注 [OA] —— 表示可通过 PMC 免费获取全文
- 若该文献无 PMCID(即 pmcid 为空),标注 [非OA] —— 表示仅摘要可用,全文需通过机构订阅或出版商获取
标注位置:紧跟在 [PMID:xxxxxxxx] 之后。
标准参考文献格式示例:
1. [PMID:30311866] [OA] — Title of the article. Authors. Journal. Year.
2. [PMID:35480500] [非OA] — Title of the article. Authors. Journal. Year.
批量搜索时:在结果末尾附加汇总统计 —— OA: X/Y (Z%),让用户一目了然。
摘要详情时:
- OA 文献额外显示 [OA] PMCID: PMCxxxxxxxx,提示全文可获取路径
- 非 OA 文献显示 [非OA] 仅摘要,全文需通过机构订阅或出版商获取
技术实现:
- getSummaries() 返回的 pmcid 字段直接反映 OA 状态(来源:PubMed esummary API 的 articleids.idtype=pmc)
- checkPMC() 可作为二次验证手段(通过 NCBI ID Converter)
- 两级验证在绝大多数情况下结果一致;若不致,以 checkPMC() 为准
Usage
# Search PubMed by keyword
node {baseDir}/scripts/pubmed-search.js search --query "myasthenia gravis thymus" --max 20
# Search with year filter
node {baseDir}/scripts/pubmed-search.js search --query "IFN alpha thymic epithelial" --year 2023 --max 30
# Search by journal
node {baseDir}/scripts/pubmed-search.js search --query "\"J Neuroimmunol\"[journal] AND MG" --max 20
# Get abstract for specific PMID
node {baseDir}/scripts/pubmed-search.js abstract --pmid 30311866
# Get abstract + try full text
node {baseDir}/scripts/pubmed-search.js fetch --pmid 30311866
# Test with sample query
node {baseDir}/scripts/pubmed-search.js test
Options
| Flag | Description |
|---|---|
search |
Search PubMed for articles |
--query <text> |
PubMed search query (supports full PubMed syntax) |
--year <year> |
Filter by publication year |
--max <n> |
Max results (default: 50) |
--offset <n> |
Pagination offset (default: 0) |
abstract |
Get structured abstract for a PMID |
--pmid <id> |
PubMed ID (PMID) |
fetch |
Full fetch: abstract + auto full-text if OA |
test |
Run test with sample query |
Programmatic API
const pubmed = require('{baseDir}/lib/api.js');
// Search PubMed
const { count, pmids } = await pubmed.searchPubMed('myasthenia gravis', { year: 2025, retmax: 50 });
// Get metadata summaries
const summaries = await pubmed.getSummaries(pmids);
// Get structured abstract
const { title, abstract, authors, journal, doi } = await pubmed.fetchAbstract('30311866');
// Fetch full text (auto maps PMID→PMCID, tries OAI-PMH)
const { available, xml, abstract, reason } = await pubmed.fetchArticle('30311866');
// Check if PMID has PMC full text
const { hasPMC, pmcid } = await pubmed.checkPMC('30311866');
// Batch search multiple journals
const articles = await pubmed.harvestJournals([{ name: 'Neurology', query: '"Neurology"[journal]' }], { year: 2025 });
Journal Query Examples
const queries = {
'Neurology': '"Neurology"[journal]',
'J Neuroimmunol': '"J Neuroimmunol"[journal]',
'Muscle Nerve': '"Muscle Nerve"[journal]',
'J Neurol Sci': '"J Neurol Sci"[journal]',
'Autoimmun Rev': '"Autoimmun Rev"[journal]',
'Front Immunol': '"Front Immunol"[journal]',
'Nat Rev Neurol': '"Nat Rev Neurol"[journal]',
};
PubMed Search Syntax
Full PubMed query syntax is supported:
- "keyword phrase"[tiab] — title/abstract search
- "journal name"[journal] — journal filter
- YYYY[dp] or YYYY[pdat] — date filter (dp returns exact matches, pdat returns that year forward)
- AND, OR, NOT — boolean operators
- gene[mesh] — MeSH term
- smith j[author] — author filter
- english[lang] — language filter
- review[ptyp] — publication type
Limitations
- Non-OA articles: abstract + metadata only, no full text
- Rate limit: ~3 requests/second without API key (built-in 400ms delay between requests)
- Peak hours: NCBI recommends avoiding 5AM-9PM ET for large batches
- Abstract quality: structured abstracts from PubMed XML; older pre-1975 articles may have limited metadata
API Reference
- E-utilities:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils esearch.fcgi?db=pubmed— Search PubMed (30M+ records)esummary.fcgi?db=pubmed— Article metadata (JSON)efetch.fcgi?db=pubmed&rettype=abstract&retmode=xml— Structured abstract- ID Converter:
https://www.ncbi.nlm.nih.gov/pmc/utils/idconv/v1.0/— PMID ↔ PMCID mapping - OAI-PMH:
https://pmc.ncbi.nlm.nih.gov/api/oai/v1/mh/GetRecord— Full text XML (OA only)
Full docs: https://www.ncbi.nlm.nih.gov/books/NBK25501/