Skill Tracer
Skills › Scientific Agent Skills › citation-management › pubmed_search.md

pubmed_search.md

855 lines · skills/citation-management/references/pubmed_search.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# PubMed Search Guide
2
3Comprehensive guide to searching PubMed for biomedical and life sciences literature, including MeSH terms, field tags, advanced search strategies, and E-utilities API usage.
4

PubMed Search Guide

Comprehensive guide to searching PubMed for biomedical and life sciences literature, including MeSH terms, field tags, advanced search strategies, and E-utilities API usage.

Raw lines 1 to 4
5## Overview
6
7PubMed is the premier database for biomedical literature:
8- **Coverage**: Biomedical citations, including MEDLINE records and online books
9- **Scope**: Biomedical and life sciences
10- **Sources**: MEDLINE, life science journals, online books
11- **Authority**: Maintained by National Library of Medicine (NLM) / NCBI
12- **Access**: Free, no account required
13- **Updates**: Daily with new citations
14- **Curation**: High-quality metadata, MeSH indexing

Overview

PubMed is the premier database for biomedical literature:

  • Coverage: Biomedical citations, including MEDLINE records and online books
  • Scope: Biomedical and life sciences
  • Sources: MEDLINE, life science journals, online books
  • Authority: Maintained by National Library of Medicine (NLM) / NCBI
  • Access: Free, no account required
  • Updates: Daily with new citations
  • Curation: High-quality metadata, MeSH indexing
Raw lines 5 to 15
16## Basic Search

Basic Search

Raw lines 16 to 17
18### Simple Keyword Search
20PubMed automatically maps terms to MeSH and searches multiple fields:
22```
23diabetes
24CRISPR gene editing
25Alzheimer's disease treatment
26cancer immunotherapy
27```
29**Automatic Features**:
30- Automatic MeSH mapping
31- Plural/singular variants
32- Abbreviation expansion
33- Spell checking

Simple Keyword Search

PubMed automatically maps terms to MeSH and searches multiple fields:

diabetes
CRISPR gene editing
Alzheimer's disease treatment
cancer immunotherapy

Automatic Features:

  • Automatic MeSH mapping
  • Plural/singular variants
  • Abbreviation expansion
  • Spell checking
Raw lines 18 to 34
35### Exact Phrase Search
37Use quotation marks for exact phrases:
39```
40"CRISPR-Cas9"
41"systematic review"
42"randomized controlled trial"
43"machine learning"
44```

Exact Phrase Search

Use quotation marks for exact phrases:

"CRISPR-Cas9"
"systematic review"
"randomized controlled trial"
"machine learning"
Raw lines 35 to 45
46## MeSH (Medical Subject Headings)

MeSH (Medical Subject Headings)

Raw lines 46 to 47
48### What is MeSH?
50MeSH is a controlled vocabulary thesaurus for indexing biomedical literature:
51- **Hierarchical structure**: Organized in tree structures
52- **Consistent indexing**: Same concept always tagged the same way
53- **Comprehensive**: Covers diseases, drugs, anatomy, techniques, etc.
54- **Indexing**: NLM assigns MeSH using automated indexing and curation; recent and non-MEDLINE records can lack MeSH

What is MeSH?

MeSH is a controlled vocabulary thesaurus for indexing biomedical literature:

  • Hierarchical structure: Organized in tree structures
  • Consistent indexing: Same concept always tagged the same way
  • Comprehensive: Covers diseases, drugs, anatomy, techniques, etc.
  • Indexing: NLM assigns MeSH using automated indexing and curation; recent and non-MEDLINE records can lack MeSH
Raw lines 48 to 55
56### Finding MeSH Terms
58**MeSH Browser**: https://meshb.nlm.nih.gov/search
60**Example**:
61```
62Search: "heart attack"
63MeSH term: "Myocardial Infarction"
64```
66**In PubMed**:
671. Search with keyword
682. Open a relevant article record and inspect its MeSH terms when present
693. Confirm descriptors in the MeSH Browser
704. Combine descriptors with title/abstract synonyms

Finding MeSH Terms

MeSH Browser: https://meshb.nlm.nih.gov/search

Example:

Search: "heart attack"
MeSH term: "Myocardial Infarction"

In PubMed:

  1. Search with keyword
  2. Open a relevant article record and inspect its MeSH terms when present
  3. Confirm descriptors in the MeSH Browser
  4. Combine descriptors with title/abstract synonyms
Raw lines 56 to 71
72### Using MeSH in Searches
74**Basic MeSH search**:
75```
76"Diabetes Mellitus"[MeSH]
77"CRISPR-Cas Systems"[MeSH]
78"Alzheimer Disease"[MeSH]
79"Neoplasms"[MeSH]
80```
82**MeSH with subheadings**:
83```
84"Diabetes Mellitus/drug therapy"[MeSH]
85"Neoplasms/genetics"[MeSH]
86"Heart Failure/prevention and control"[MeSH]
87```
89**Common subheadings**:
90- `/drug therapy`: Drug treatment
91- `/diagnosis`: Diagnostic aspects
92- `/genetics`: Genetic aspects
93- `/epidemiology`: Occurrence and distribution
94- `/prevention and control`: Prevention methods
95- `/etiology`: Causes
96- `/surgery`: Surgical treatment
97- `/metabolism`: Metabolic aspects

Using MeSH in Searches

Basic MeSH search:

"Diabetes Mellitus"[MeSH]
"CRISPR-Cas Systems"[MeSH]
"Alzheimer Disease"[MeSH]
"Neoplasms"[MeSH]

MeSH with subheadings:

"Diabetes Mellitus/drug therapy"[MeSH]
"Neoplasms/genetics"[MeSH]
"Heart Failure/prevention and control"[MeSH]

Common subheadings:

  • /drug therapy: Drug treatment
  • /diagnosis: Diagnostic aspects
  • /genetics: Genetic aspects
  • /epidemiology: Occurrence and distribution
  • /prevention and control: Prevention methods
  • /etiology: Causes
  • /surgery: Surgical treatment
  • /metabolism: Metabolic aspects
Raw lines 72 to 98
99### MeSH Explosion
101By default, MeSH searches include narrower terms (explosion):
103```
104"Neoplasms"[MeSH]
105# Includes: Breast Neoplasms, Lung Neoplasms, etc.
106```
108**Disable explosion** (exact term only):
109```
110"Neoplasms"[MeSH:NoExp]
111```

MeSH Explosion

By default, MeSH searches include narrower terms (explosion):

"Neoplasms"[MeSH]
# Includes: Breast Neoplasms, Lung Neoplasms, etc.

Disable explosion (exact term only):

"Neoplasms"[MeSH:NoExp]
Raw lines 99 to 112
113### MeSH Major Topic
115Search only where MeSH term is a major focus:
117```
118"Diabetes Mellitus"[MeSH Major Topic]
119# Only papers where diabetes is main topic
120```

MeSH Major Topic

Search only where MeSH term is a major focus:

"Diabetes Mellitus"[MeSH Major Topic]
# Only papers where diabetes is main topic
Raw lines 113 to 121
122## Field Tags
124Field tags specify which part of the record to search.

Field Tags

Field tags specify which part of the record to search.

Raw lines 122 to 125
126### Common Field Tags
128**Title and Abstract**:
129```
130cancer[Title] # In title only
131treatment[Title/Abstract] # In title or abstract
132"machine learning"[Title/Abstract]
133```
135**Author**:
136```
137"Smith J"[Author]
138"Doudna JA"[Author]
139"Collins FS"[Author]
140```
142**Author - Full Name**:
143```
144"Smith, John"[Full Author Name]
145```
147**Journal**:
148```
149"Nature"[Journal]
150"Science"[Journal]
151"New England Journal of Medicine"[Journal]
152"Nat Commun"[Journal] # Abbreviated form
153```
155**Publication Date**:
156```
1572023[Publication Date]
1582020:2024[Publication Date] # Date range
1592023/01/01:2023/12/31[Publication Date]
160```
162**Date Created**:
163```
1642023[Date - Create] # When added to PubMed
165```
167**Publication Type**:
168```
169"Review"[Publication Type]
170"Clinical Trial"[Publication Type]
171"Meta-Analysis"[Publication Type]
172"Randomized Controlled Trial"[Publication Type]
173```
175**Language**:
176```
177English[Language]
178French[Language]
179```
181**DOI**:
182```
18310.1038/nature12345[DOI]
184```
186**PMID (PubMed ID)**:
187```
18812345678[PMID]
189```
191**Article ID**:
192```
193PMC1234567[PMC] # PubMed Central ID
194```

Common Field Tags

Title and Abstract:

cancer[Title]                    # In title only
treatment[Title/Abstract]        # In title or abstract
"machine learning"[Title/Abstract]

Author:

"Smith J"[Author]
"Doudna JA"[Author]
"Collins FS"[Author]

Author - Full Name:

"Smith, John"[Full Author Name]

Journal:

"Nature"[Journal]
"Science"[Journal]
"New England Journal of Medicine"[Journal]
"Nat Commun"[Journal]           # Abbreviated form

Publication Date:

2023[Publication Date]
2020:2024[Publication Date]      # Date range
2023/01/01:2023/12/31[Publication Date]

Date Created:

2023[Date - Create]              # When added to PubMed

Publication Type:

"Review"[Publication Type]
"Clinical Trial"[Publication Type]
"Meta-Analysis"[Publication Type]
"Randomized Controlled Trial"[Publication Type]

Language:

English[Language]
French[Language]

DOI:

10.1038/nature12345[DOI]

PMID (PubMed ID):

12345678[PMID]

Article ID:

PMC1234567[PMC]                  # PubMed Central ID
Raw lines 126 to 195
196### Less Common But Useful Tags
198```
199humans[MeSH Terms] # Only human studies
200animals[MeSH Terms] # Only animal studies
201"United States"[Place of Publication]
202nih[Grant Number] # NIH-funded research
203"Female"[MeSH Terms] # Female subjects
204"Aged, 80 and over"[MeSH Terms] # Elderly subjects
205```

Less Common But Useful Tags

humans[MeSH Terms]               # Only human studies
animals[MeSH Terms]              # Only animal studies
"United States"[Place of Publication]
nih[Grant Number]                # NIH-funded research
"Female"[MeSH Terms]                    # Female subjects
"Aged, 80 and over"[MeSH Terms]        # Elderly subjects
Raw lines 196 to 206
207## Boolean Operators
209Combine search terms with Boolean logic.

Boolean Operators

Combine search terms with Boolean logic.

Raw lines 207 to 210
211### AND
213Both terms must be present (default behavior):
215```
216diabetes AND treatment
217"CRISPR-Cas9" AND "gene editing"
218cancer AND immunotherapy AND "clinical trial"[Publication Type]
219```

AND

Both terms must be present (default behavior):

diabetes AND treatment
"CRISPR-Cas9" AND "gene editing"
cancer AND immunotherapy AND "clinical trial"[Publication Type]
Raw lines 211 to 220
221### OR
223Either term must be present:
225```
226"heart attack" OR "myocardial infarction"
227diabetes OR "diabetes mellitus"
228CRISPR OR Cas9 OR "gene editing"
229```
231**Use case**: Synonyms and related terms

OR

Either term must be present:

"heart attack" OR "myocardial infarction"
diabetes OR "diabetes mellitus"
CRISPR OR Cas9 OR "gene editing"

Use case: Synonyms and related terms

Raw lines 221 to 232
233### NOT
235Exclude terms:
237```
238cancer NOT review
239diabetes NOT animal
240"machine learning" NOT "deep learning"
241```
243**Caution**: May exclude relevant papers that mention both terms.

NOT

Exclude terms:

cancer NOT review
diabetes NOT animal
"machine learning" NOT "deep learning"

Caution: May exclude relevant papers that mention both terms.

Raw lines 233 to 244
245### Combining Operators
247Use parentheses for complex logic:
249```
250(diabetes OR "diabetes mellitus") AND (treatment OR therapy)
252("CRISPR" OR "gene editing") AND ("therapeutic" OR "therapy")
253 AND 2020:2024[Publication Date]
255(cancer OR neoplasm) AND (immunotherapy OR "immune checkpoint inhibitor")
256 AND ("clinical trial"[Publication Type] OR "randomized controlled trial"[Publication Type])
257```

Combining Operators

Use parentheses for complex logic:

(diabetes OR "diabetes mellitus") AND (treatment OR therapy)

("CRISPR" OR "gene editing") AND ("therapeutic" OR "therapy") 
  AND 2020:2024[Publication Date]

(cancer OR neoplasm) AND (immunotherapy OR "immune checkpoint inhibitor") 
  AND ("clinical trial"[Publication Type] OR "randomized controlled trial"[Publication Type])
Raw lines 245 to 258
259## Advanced Search Builder
261**Access**: https://pubmed.ncbi.nlm.nih.gov/advanced/
263**Features**:
264- Visual query builder
265- Add multiple query boxes
266- Select field tags from dropdowns
267- Combine with AND/OR/NOT
268- Preview results
269- Shows final query string
270- Save queries
272**Workflow**:
2731. Add search terms in separate boxes
2742. Select field tags
2753. Choose Boolean operators
2764. Preview results
2775. Refine as needed
2786. Copy final query string
2797. Use in scripts or save
281**Example built query**:
282```
283#1: "Diabetes Mellitus, Type 2"[MeSH]
284#2: "Metformin"[MeSH]
285#3: "Clinical Trial"[Publication Type]
286#4: 2020:2024[Publication Date]
287#5: #1 AND #2 AND #3 AND #4
288```

Advanced Search Builder

Access: https://pubmed.ncbi.nlm.nih.gov/advanced/

Features:

  • Visual query builder
  • Add multiple query boxes
  • Select field tags from dropdowns
  • Combine with AND/OR/NOT
  • Preview results
  • Shows final query string
  • Save queries

Workflow:

  1. Add search terms in separate boxes
  2. Select field tags
  3. Choose Boolean operators
  4. Preview results
  5. Refine as needed
  6. Copy final query string
  7. Use in scripts or save

Example built query:

#1: "Diabetes Mellitus, Type 2"[MeSH]
#2: "Metformin"[MeSH]
#3: "Clinical Trial"[Publication Type]
#4: 2020:2024[Publication Date]
#5: #1 AND #2 AND #3 AND #4
Raw lines 259 to 289
290## Filters and Limits

Filters and Limits

Raw lines 290 to 291
292### Article Types
294```
295"Review"[Publication Type]
296"Systematic Review"[Publication Type]
297"Meta-Analysis"[Publication Type]
298"Clinical Trial"[Publication Type]
299"Randomized Controlled Trial"[Publication Type]
300"Case Reports"[Publication Type]
301"Comparative Study"[Publication Type]
302```

Article Types

"Review"[Publication Type]
"Systematic Review"[Publication Type]
"Meta-Analysis"[Publication Type]
"Clinical Trial"[Publication Type]
"Randomized Controlled Trial"[Publication Type]
"Case Reports"[Publication Type]
"Comparative Study"[Publication Type]
Raw lines 292 to 303
304### Species
306```
307humans[MeSH Terms]
308mice[MeSH Terms]
309rats[MeSH Terms]
310```

Species

humans[MeSH Terms]
mice[MeSH Terms]
rats[MeSH Terms]
Raw lines 304 to 311
312### Sex
314```
315"Female"[MeSH Terms]
316"Male"[MeSH Terms]
317```

Sex

"Female"[MeSH Terms]
"Male"[MeSH Terms]
Raw lines 312 to 318
319### Age Groups
321```
322"Infant"[MeSH Terms]
323"Child"[MeSH Terms]
324"Adolescent"[MeSH Terms]
325"Adult"[MeSH Terms]
326"Aged"[MeSH Terms]
327"Aged, 80 and over"[MeSH Terms]
328```

Age Groups

"Infant"[MeSH Terms]
"Child"[MeSH Terms]
"Adolescent"[MeSH Terms]
"Adult"[MeSH Terms]
"Aged"[MeSH Terms]
"Aged, 80 and over"[MeSH Terms]
Raw lines 319 to 329
330### Text Availability
332```
333free full text[Filter] # Free full-text available
334```

Text Availability

free full text[Filter]           # Free full-text available
Raw lines 330 to 335
336### Journal Categories
338```
339"Journal Article"[Publication Type]
340```

Journal Categories

"Journal Article"[Publication Type]
Raw lines 336 to 341
342## E-utilities API
344NCBI provides programmatic access via E-utilities (Entrez Programming Utilities).

E-utilities API

NCBI provides programmatic access via E-utilities (Entrez Programming Utilities).

Raw lines 342 to 345
346### Overview
348**Base URL**: `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/`
350**Main Tools**:
351- **ESearch**: Search and retrieve PMIDs
352- **EFetch**: Retrieve full records
353- **ESummary**: Retrieve document summaries
354- **ELink**: Find related articles
355- **EInfo**: Database statistics
357**No API key required**, but recommended for:
358- Higher rate limits (10/sec vs 3/sec)
359- Better performance
360- Identify your project
362**Get API key**: https://www.ncbi.nlm.nih.gov/account/

Overview

Base URL: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/

Main Tools:

  • ESearch: Search and retrieve PMIDs
  • EFetch: Retrieve full records
  • ESummary: Retrieve document summaries
  • ELink: Find related articles
  • EInfo: Database statistics

No API key required, but recommended for:

  • Higher rate limits (10/sec vs 3/sec)
  • Better performance
  • Identify your project

Get API key: https://www.ncbi.nlm.nih.gov/account/

Raw lines 346 to 363
364### ESearch - Search PubMed
366Retrieve PMIDs for a query. The 10,000 ceiling is a total query window, not
367a per-page limit that cursor/history parameters bypass. Split larger searches
368into disjoint date ranges and deduplicate, or use NCBI EDirect. See
369[NCBI's PubMed update](https://ncbiinsights.ncbi.nlm.nih.gov/2021/10/05/updated-pubmed-api/).
371**Endpoint**: `/esearch.fcgi`
373**Parameters**:
374- `db`: Database (pubmed)
375- `term`: Search query
376- `retmax`: Maximum results (default 20, max 10000)
377- `retstart`: Zero-based offset within the first 10,000 matches; `retstart + retmax` cannot exceed 10,000
378- `sort`: PubMed values include `relevance`, `pub_date`, `Author`, and `JournalName`
379- `api_key`: Your API key (optional but recommended)
381**Example URL**:
382```
383https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?
384 db=pubmed&
385 term=diabetes+AND+treatment&
386 retmax=100&
387 retmode=json&
388 api_key=YOUR_API_KEY
389```
391**Illustrative response (two-record excerpt)**:
392```json
394 "esearchresult": {
395 "count": "250000",
396 "retmax": "100",
397 "idlist": ["12345678", "12345679"]
398 }
400```

ESearch - Search PubMed

Retrieve PMIDs for a query. The 10,000 ceiling is a total query window, not a per-page limit that cursor/history parameters bypass. Split larger searches into disjoint date ranges and deduplicate, or use NCBI EDirect. See NCBI's PubMed update.

Endpoint: /esearch.fcgi

Parameters:

  • db: Database (pubmed)
  • term: Search query
  • retmax: Maximum results (default 20, max 10000)
  • retstart: Zero-based offset within the first 10,000 matches; retstart + retmax cannot exceed 10,000
  • sort: PubMed values include relevance, pub_date, Author, and JournalName
  • api_key: Your API key (optional but recommended)

Example URL:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?
  db=pubmed&
  term=diabetes+AND+treatment&
  retmax=100&
  retmode=json&
  api_key=YOUR_API_KEY

Illustrative response (two-record excerpt):

{
  "esearchresult": {
    "count": "250000",
    "retmax": "100",
    "idlist": ["12345678", "12345679"]
  }
}
Raw lines 364 to 401
402### EFetch - Retrieve Records
404Get full metadata for PMIDs.
406**Endpoint**: `/efetch.fcgi`
408**Parameters**:
409- `db`: Database (pubmed)
410- `id`: Comma-separated PMIDs
411- `retmode=xml`: Full PubMed XML (omit `rettype`); JSON is not a PubMed EFetch format
412- `retmode=text&rettype=abstract` or `retmode=text&rettype=medline`: Text views
413- `api_key`: Optional NCBI API key; `tool` and `email` identify the caller
415**Example URL**:
416```
417https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?
418 db=pubmed&
419 id=12345678,12345679&
420 retmode=xml&
421 api_key=YOUR_API_KEY
422```
424**Response**: XML with complete metadata including:
425- Title
426- Authors (with affiliations)
427- Abstract
428- Journal
429- Publication date
430- DOI
431- PMID, PMCID
432- MeSH terms
433- Keywords

EFetch - Retrieve Records

Get full metadata for PMIDs.

Endpoint: /efetch.fcgi

Parameters:

  • db: Database (pubmed)
  • id: Comma-separated PMIDs
  • retmode=xml: Full PubMed XML (omit rettype); JSON is not a PubMed EFetch format
  • retmode=text&rettype=abstract or retmode=text&rettype=medline: Text views
  • api_key: Optional NCBI API key; tool and email identify the caller

Example URL:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?
  db=pubmed&
  id=12345678,12345679&
  retmode=xml&
  api_key=YOUR_API_KEY

Response: XML with complete metadata including:

  • Title
  • Authors (with affiliations)
  • Abstract
  • Journal
  • Publication date
  • DOI
  • PMID, PMCID
  • MeSH terms
  • Keywords
Raw lines 402 to 434
435### ESummary - Get Summaries
437Lighter-weight alternative to EFetch.
439**Example**:
440```
441https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?
442 db=pubmed&
443 id=12345678&
444 retmode=json&
445 api_key=YOUR_API_KEY
446```
448**Returns**: JSON `result.uids` plus records keyed by PMID; this is not ESearch's
449`esearchresult` shape. This endpoint is an illustrative manual alternative; the
450bundled search script uses ESearch and EFetch only.

ESummary - Get Summaries

Lighter-weight alternative to EFetch.

Example:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?
  db=pubmed&
  id=12345678&
  retmode=json&
  api_key=YOUR_API_KEY

Returns: JSON result.uids plus records keyed by PMID; this is not ESearch's esearchresult shape. This endpoint is an illustrative manual alternative; the bundled search script uses ESearch and EFetch only.

Raw lines 435 to 451
452### ELink - Find Related Articles
454Find related articles or links to other databases.
456**Example**:
457```
458https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?
459 dbfrom=pubmed&
460 db=pubmed&
461 id=12345678&
462 linkname=pubmed_pubmed_citedin&
463 cmd=neighbor&
464 retmode=xml
465```
467**Link types**:
468- `pubmed_pubmed`: Related articles
469- `pubmed_pubmed_citedin`: Papers citing this article
470- `pubmed_pmc`: PMC full-text versions (set target `db=pmc`)
471- `pubmed_protein`: Related protein records
473ELink XML contains `LinkSet/LinkSetDb/Link/Id` when matching links exist; an
474empty link set is valid. The cited-in relationship is not a complete citation
475index. EInfo (`einfo.fcgi?db=pubmed&retmode=json`) reports database fields and
476link names, not article records. These are illustrative manual API calls.

ELink - Find Related Articles

Find related articles or links to other databases.

Example:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?
  dbfrom=pubmed&
  db=pubmed&
  id=12345678&
  linkname=pubmed_pubmed_citedin&
  cmd=neighbor&
  retmode=xml

Link types:

  • pubmed_pubmed: Related articles
  • pubmed_pubmed_citedin: Papers citing this article
  • pubmed_pmc: PMC full-text versions (set target db=pmc)
  • pubmed_protein: Related protein records

ELink XML contains LinkSet/LinkSetDb/Link/Id when matching links exist; an empty link set is valid. The cited-in relationship is not a complete citation index. EInfo (einfo.fcgi?db=pubmed&retmode=json) reports database fields and link names, not article records. These are illustrative manual API calls.

Raw lines 452 to 477
478### Rate Limiting
480**Without API key**:
481- 3 requests per second
482- Block if exceeded
484**With API key**:
485- 10 requests per second
486- Better for programmatic access
488**Best practice**:
489```python
490import time
491time.sleep(0.34) # ~3 requests/second
492# or
493time.sleep(0.11) # ~10 requests/second with API key
494```

Rate Limiting

Without API key:

  • 3 requests per second
  • Block if exceeded

With API key:

  • 10 requests per second
  • Better for programmatic access

Best practice:

import time
time.sleep(0.34)  # ~3 requests/second
# or
time.sleep(0.11)  # ~10 requests/second with API key
Raw lines 478 to 495
496### API Key Usage
498**Get API key**:
4991. Create NCBI account: https://www.ncbi.nlm.nih.gov/account/
5002. Settings → API Key Management
5013. Create new API key
5024. Copy key
504**Use in requests**:
505```
506&api_key=YOUR_API_KEY_HERE
507```
509**Store securely**:
510```bash
511# In environment variable
512export NCBI_API_KEY="your_key_here"
514# In script
515import os
516api_key = os.getenv('NCBI_API_KEY')
517```

API Key Usage

Get API key:

  1. Create NCBI account: https://www.ncbi.nlm.nih.gov/account/
  2. Settings → API Key Management
  3. Create new API key
  4. Copy key

Use in requests:

&api_key=YOUR_API_KEY_HERE

Store securely:

# In environment variable
export NCBI_API_KEY="your_key_here"

# In script
import os
api_key = os.getenv('NCBI_API_KEY')
Raw lines 496 to 518
519## Search Strategies

Search Strategies

Raw lines 519 to 520
521### Comprehensive Systematic Search
523For systematic reviews and meta-analyses:
525```
526# 1. Identify key concepts
527Concept 1: Diabetes
528Concept 2: Treatment
529Concept 3: Outcomes
531# 2. Find MeSH terms and synonyms
532Concept 1: "Diabetes Mellitus"[MeSH] OR diabetes OR diabetic
533Concept 2: "Drug Therapy"[MeSH] OR treatment OR therapy OR medication
534Concept 3: "Treatment Outcome"[MeSH] OR outcome OR efficacy OR effectiveness
536# 3. Combine with AND
537("Diabetes Mellitus"[MeSH] OR diabetes OR diabetic)
538 AND ("Drug Therapy"[MeSH] OR treatment OR therapy OR medication)
539 AND ("Treatment Outcome"[MeSH] OR outcome OR efficacy OR effectiveness)
541# 4. Add filters
542AND 2015:2024[Publication Date]
543AND ("Clinical Trial"[Publication Type] OR "Randomized Controlled Trial"[Publication Type])
544AND English[Language]
545AND humans[MeSH Terms]
546```

Comprehensive Systematic Search

For systematic reviews and meta-analyses:

# 1. Identify key concepts
Concept 1: Diabetes
Concept 2: Treatment
Concept 3: Outcomes

# 2. Find MeSH terms and synonyms
Concept 1: "Diabetes Mellitus"[MeSH] OR diabetes OR diabetic
Concept 2: "Drug Therapy"[MeSH] OR treatment OR therapy OR medication
Concept 3: "Treatment Outcome"[MeSH] OR outcome OR efficacy OR effectiveness

# 3. Combine with AND
("Diabetes Mellitus"[MeSH] OR diabetes OR diabetic) 
  AND ("Drug Therapy"[MeSH] OR treatment OR therapy OR medication)
  AND ("Treatment Outcome"[MeSH] OR outcome OR efficacy OR effectiveness)

# 4. Add filters
AND 2015:2024[Publication Date]
AND ("Clinical Trial"[Publication Type] OR "Randomized Controlled Trial"[Publication Type])
AND English[Language]
AND humans[MeSH Terms]
Raw lines 521 to 547
548### Finding Clinical Trials
550```
551# Specific disease + clinical trials
552"Alzheimer Disease"[MeSH]
553 AND ("Clinical Trial"[Publication Type]
554 OR "Randomized Controlled Trial"[Publication Type])
555 AND 2020:2024[Publication Date]
557# Specific drug trials
558"Metformin"[MeSH]
559 AND "Diabetes Mellitus, Type 2"[MeSH]
560 AND "Randomized Controlled Trial"[Publication Type]
561```

Finding Clinical Trials

# Specific disease + clinical trials
"Alzheimer Disease"[MeSH] 
  AND ("Clinical Trial"[Publication Type] 
       OR "Randomized Controlled Trial"[Publication Type])
  AND 2020:2024[Publication Date]

# Specific drug trials
"Metformin"[MeSH] 
  AND "Diabetes Mellitus, Type 2"[MeSH]
  AND "Randomized Controlled Trial"[Publication Type]
Raw lines 548 to 562
563### Finding Reviews
565```
566# Systematic reviews on topic
567"CRISPR-Cas Systems"[MeSH]
568 AND ("Systematic Review"[Publication Type] OR "Meta-Analysis"[Publication Type])
570# Reviews in high-impact journals
571cancer immunotherapy
572 AND "Review"[Publication Type]
573 AND ("Nature"[Journal] OR "Science"[Journal] OR "Cell"[Journal])
574```

Finding Reviews

# Systematic reviews on topic
"CRISPR-Cas Systems"[MeSH] 
  AND ("Systematic Review"[Publication Type] OR "Meta-Analysis"[Publication Type])

# Reviews in high-impact journals
cancer immunotherapy 
  AND "Review"[Publication Type]
  AND ("Nature"[Journal] OR "Science"[Journal] OR "Cell"[Journal])
Raw lines 563 to 575
576### Finding Recent Papers
578```
579# Papers from last year
580"machine learning"[Title/Abstract]
581 AND "drug discovery"[Title/Abstract]
582 AND 2024[Publication Date]
584# Recent papers in specific journal
585"CRISPR"[Title/Abstract]
586 AND "Nature"[Journal]
587 AND 2023:2024[Publication Date]
588```

Finding Recent Papers

# Papers from last year
"machine learning"[Title/Abstract] 
  AND "drug discovery"[Title/Abstract]
  AND 2024[Publication Date]

# Recent papers in specific journal
"CRISPR"[Title/Abstract] 
  AND "Nature"[Journal]
  AND 2023:2024[Publication Date]
Raw lines 576 to 589
590### Author Tracking
592```
593# Specific author's recent work
594"Doudna JA"[Author] AND 2020:2024[Publication Date]
596# Author + topic
597"Church GM"[Author] AND "synthetic biology"[Title/Abstract]
598```

Author Tracking

# Specific author's recent work
"Doudna JA"[Author] AND 2020:2024[Publication Date]

# Author + topic
"Church GM"[Author] AND "synthetic biology"[Title/Abstract]
Raw lines 590 to 599
600### High-Quality Evidence
602```
603# Meta-analyses and systematic reviews
604(diabetes OR "diabetes mellitus")
605 AND (treatment OR therapy)
606 AND ("Meta-Analysis"[Publication Type] OR "Systematic Review"[Publication Type])
608# RCTs only
609cancer immunotherapy
610 AND "Randomized Controlled Trial"[Publication Type]
611 AND 2020:2024[Publication Date]
612```

High-Quality Evidence

# Meta-analyses and systematic reviews
(diabetes OR "diabetes mellitus") 
  AND (treatment OR therapy)
  AND ("Meta-Analysis"[Publication Type] OR "Systematic Review"[Publication Type])

# RCTs only
cancer immunotherapy 
  AND "Randomized Controlled Trial"[Publication Type]
  AND 2020:2024[Publication Date]
Raw lines 600 to 613
614## Script Integration
616The bundled client fetches explicit PMIDs in batches of 200, checks each batch
617for completeness, and refuses to export when any batch fails or includes
618unsupported PubmedBookArticle records. It does not export the full PubMed XML.

Script Integration

The bundled client fetches explicit PMIDs in batches of 200, checks each batch for completeness, and refuses to export when any batch fails or includes unsupported PubmedBookArticle records. It does not export the full PubMed XML.

Raw lines 614 to 619
620### search_pubmed.py Usage
622**Basic search**:
623```bash
624python scripts/search_pubmed.py "diabetes treatment"
625```
627**With MeSH terms**:
628```bash
629python scripts/search_pubmed.py \
630 --query '"Diabetes Mellitus"[MeSH] AND "Drug Therapy"[MeSH]'
631```
633**Date range filter**:
634```bash
635python scripts/search_pubmed.py "CRISPR" \
636 --date-start 2020-01-01 \
637 --date-end 2024-12-31 \
638 --limit 200
639```
641**Publication type filter**:
642```bash
643python scripts/search_pubmed.py "cancer immunotherapy" \
644 --publication-types "Clinical Trial,Randomized Controlled Trial" \
645 --limit 100
646```
648**Export to BibTeX**:
649```bash
650python scripts/search_pubmed.py "Alzheimer's disease" \
651 --limit 100 \
652 --format bibtex \
653 --output alzheimers.bib
654```
656**Complex query from file**:
657```bash
658# Save complex query in query.txt
659cat > query.txt << 'EOF'
660("Diabetes Mellitus, Type 2"[MeSH] OR "diabetes"[Title/Abstract])
661AND ("Metformin"[MeSH] OR "metformin"[Title/Abstract])
662AND "Randomized Controlled Trial"[Publication Type]
663AND 2015:2024[Publication Date]
664AND English[Language]
665EOF
667# Run search
668python scripts/search_pubmed.py --query-file query.txt --limit 500
669```

search_pubmed.py Usage

Basic search:

python scripts/search_pubmed.py "diabetes treatment"

With MeSH terms:

python scripts/search_pubmed.py \
  --query '"Diabetes Mellitus"[MeSH] AND "Drug Therapy"[MeSH]'

Date range filter:

python scripts/search_pubmed.py "CRISPR" \
  --date-start 2020-01-01 \
  --date-end 2024-12-31 \
  --limit 200

Publication type filter:

python scripts/search_pubmed.py "cancer immunotherapy" \
  --publication-types "Clinical Trial,Randomized Controlled Trial" \
  --limit 100

Export to BibTeX:

python scripts/search_pubmed.py "Alzheimer's disease" \
  --limit 100 \
  --format bibtex \
  --output alzheimers.bib

Complex query from file:

# Save complex query in query.txt
cat > query.txt << 'EOF'
("Diabetes Mellitus, Type 2"[MeSH] OR "diabetes"[Title/Abstract])
AND ("Metformin"[MeSH] OR "metformin"[Title/Abstract])
AND "Randomized Controlled Trial"[Publication Type]
AND 2015:2024[Publication Date]
AND English[Language]
EOF

# Run search
python scripts/search_pubmed.py --query-file query.txt --limit 500
Raw lines 620 to 670
Runs code python scripts/search_pubmed.py :624
671### Batch Searches
673```bash
674# Search multiple topics
675TOPICS=("diabetes treatment" "cancer immunotherapy" "CRISPR gene editing")
677for topic in "${TOPICS[@]}"; do
678 python scripts/search_pubmed.py "$topic" \
679 --limit 100 \
680 --output "${topic// /_}.json"
681 sleep 1
682done
683```

Batch Searches

# Search multiple topics
TOPICS=("diabetes treatment" "cancer immunotherapy" "CRISPR gene editing")

for topic in "${TOPICS[@]}"; do
  python scripts/search_pubmed.py "$topic" \
    --limit 100 \
    --output "${topic// /_}.json"
  sleep 1
done
Raw lines 671 to 684
Runs code python scripts/search_pubmed.py :678
685### Extract Metadata
687```bash
688# Search returns PMIDs
689python scripts/search_pubmed.py "topic" --output results.json
691# Extract full metadata
692python scripts/extract_metadata.py \
693 --input results.json \
694 --output references.bib
695```

Extract Metadata

# Search returns PMIDs
python scripts/search_pubmed.py "topic" --output results.json

# Extract full metadata
python scripts/extract_metadata.py \
  --input results.json \
  --output references.bib
Raw lines 685 to 696
Runs code python scripts/search_pubmed.py :689
Runs code python scripts/extract_metadata.py :692
697## Tips and Best Practices

Tips and Best Practices

Raw lines 697 to 698
699### Search Construction
7011. **Start with MeSH terms**:
702 - Use MeSH Browser to find correct terms
703 - More precise than keyword search
704 - Combine with text words: not every PubMed record has MeSH indexing
7062. **Include text word variants**:
707 ```
708 # Better coverage
709 ("Diabetes Mellitus"[MeSH] OR diabetes OR diabetic)
710 ```
7123. **Use field tags appropriately**:
713 - `[MeSH]` for standardized concepts
714 - `[Title/Abstract]` for specific terms
715 - `[Author]` for known authors
716 - `[Journal]` for specific venues
7184. **Build incrementally**:
719 ```
720 # Step 1: Basic search
721 diabetes
723 # Step 2: Add specificity
724 "Diabetes Mellitus, Type 2"[MeSH]
726 # Step 3: Add treatment
727 "Diabetes Mellitus, Type 2"[MeSH] AND "Metformin"[MeSH]
729 # Step 4: Add study type
730 "Diabetes Mellitus, Type 2"[MeSH] AND "Metformin"[MeSH]
731 AND "Clinical Trial"[Publication Type]
733 # Step 5: Add date range
734 ... AND 2020:2024[Publication Date]
735 ```

Search Construction

  1. Start with MeSH terms:
  2. Use MeSH Browser to find correct terms
  3. More precise than keyword search
  4. Combine with text words: not every PubMed record has MeSH indexing
  1. Include text word variants: `` # Better coverage ("Diabetes Mellitus"[MeSH] OR diabetes OR diabetic)
  1. Use field tags appropriately:
  2. [MeSH] for standardized concepts
  3. [Title/Abstract] for specific terms
  4. [Author] for known authors
  5. [Journal] for specific venues
  1. Build incrementally: ``` # Step 1: Basic search diabetes

# Step 2: Add specificity "Diabetes Mellitus, Type 2"[MeSH]

# Step 3: Add treatment "Diabetes Mellitus, Type 2"[MeSH] AND "Metformin"[MeSH]

# Step 4: Add study type "Diabetes Mellitus, Type 2"[MeSH] AND "Metformin"[MeSH] AND "Clinical Trial"[Publication Type]

# Step 5: Add date range ... AND 2020:2024[Publication Date] ```

Raw lines 699 to 736
737### Optimizing Results
7391. **Too many results**: Add filters
740 - Restrict publication type
741 - Narrow date range
742 - Add more specific MeSH terms
743 - Use Major Topic: `[MeSH Major Topic]`
7452. **Too few results**: Broaden search
746 - Remove restrictive filters
747 - Use OR for synonyms
748 - Expand date range
749 - Use MeSH explosion (default)
7513. **Irrelevant results**: Refine terms
752 - Use more specific MeSH terms
753 - Add exclusions with NOT
754 - Use Title field instead of all fields
755 - Add MeSH subheadings

Optimizing Results

  1. Too many results: Add filters
  2. Restrict publication type
  3. Narrow date range
  4. Add more specific MeSH terms
  5. Use Major Topic: [MeSH Major Topic]
  1. Too few results: Broaden search
  2. Remove restrictive filters
  3. Use OR for synonyms
  4. Expand date range
  5. Use MeSH explosion (default)
  1. Irrelevant results: Refine terms
  2. Use more specific MeSH terms
  3. Add exclusions with NOT
  4. Use Title field instead of all fields
  5. Add MeSH subheadings
Raw lines 737 to 756
757### Quality Control
7591. **Document search strategy**:
760 - Save exact query string
761 - Record search date
762 - Note number of results
763 - Save filters used
7652. **Export systematically**:
766 - Use consistent file naming
767 - Export to JSON for flexibility
768 - Convert to BibTeX as needed
769 - Keep original search results
7713. **Validate retrieved citations**:
772 ```bash
773 python scripts/validate_citations.py pubmed_results.bib
774 ```

Quality Control

  1. Document search strategy:
  2. Save exact query string
  3. Record search date
  4. Note number of results
  5. Save filters used
  1. Export systematically:
  2. Use consistent file naming
  3. Export to JSON for flexibility
  4. Convert to BibTeX as needed
  5. Keep original search results
  1. Validate retrieved citations: ``bash python scripts/validate_citations.py pubmed_results.bib
Raw lines 757 to 775
Runs code python scripts/validate_citations.py :773
776### Staying Current
7781. **Set up search alerts**:
779 - PubMed → Save search
780 - Receive email updates
781 - Daily, weekly, or monthly
7832. **Track specific journals**:
784 ```
785 "Nature"[Journal] AND CRISPR[Title]
786 ```
7883. **Follow key authors**:
789 ```
790 "Church GM"[Author]
791 ```

Staying Current

  1. Set up search alerts:
  2. PubMed → Save search
  3. Receive email updates
  4. Daily, weekly, or monthly
  1. Track specific journals: `` "Nature"[Journal] AND CRISPR[Title]
  1. Follow key authors: `` "Church GM"[Author]
Raw lines 776 to 792
793## Common Issues and Solutions

Common Issues and Solutions

Raw lines 793 to 794
795### Issue: MeSH Term Not Found
797**Solution**:
798- Check spelling
799- Use MeSH Browser
800- Try related terms
801- Use text word search as fallback

Issue: MeSH Term Not Found

Solution:

  • Check spelling
  • Use MeSH Browser
  • Try related terms
  • Use text word search as fallback
Raw lines 795 to 802
803### Issue: Zero Results
805**Solution**:
806- Remove filters
807- Check query syntax
808- Use OR for broader search
809- Try synonyms

Issue: Zero Results

Solution:

  • Remove filters
  • Check query syntax
  • Use OR for broader search
  • Try synonyms
Raw lines 803 to 810
811### Issue: Poor Quality Results
813**Solution**:
814- Add publication type filters
815- Restrict to recent years
816- Use MeSH Major Topic
817- Filter by journal quality

Issue: Poor Quality Results

Solution:

  • Add publication type filters
  • Restrict to recent years
  • Use MeSH Major Topic
  • Filter by journal quality
Raw lines 811 to 818
819### Issue: Duplicates from Different Sources
821**Solution**:
822```bash
823python scripts/format_bibtex.py results.bib \
824 --deduplicate \
825 --output clean.bib
826```

Issue: Duplicates from Different Sources

Solution:

python scripts/format_bibtex.py results.bib \
  --deduplicate \
  --output clean.bib
Raw lines 819 to 827
Runs code python scripts/format_bibtex.py :823
828### Issue: API Rate Limiting
830**Solution**:
831- Get API key (increases limit to 10/sec)
832- Add delays in scripts
833- Process in batches
834- Use off-peak hours

Issue: API Rate Limiting

Solution:

  • Get API key (increases limit to 10/sec)
  • Add delays in scripts
  • Process in batches
  • Use off-peak hours
Raw lines 828 to 835
836## Summary
838PubMed provides authoritative biomedical literature search:
840✓ **Curated content**: MeSH indexing, quality control
841✓ **Precise search**: Field tags, MeSH terms, filters
842✓ **Programmatic access**: E-utilities API
843✓ **Free access**: No subscription required
844✓ **Comprehensive**: 35M+ citations, daily updates
846Key strategies:
847- Use MeSH terms for precise searching
848- Combine with text words for comprehensive coverage
849- Apply appropriate field tags
850- Filter by publication type and date
851- Use E-utilities API for automation
852- Document search strategy for reproducibility
854For broader coverage across disciplines, complement with Google Scholar.

Summary

PubMed provides authoritative biomedical literature search:

✓ Curated content: MeSH indexing, quality control ✓ Precise search: Field tags, MeSH terms, filters ✓ Programmatic access: E-utilities API ✓ Free access: No subscription required ✓ Comprehensive: 35M+ citations, daily updates

Key strategies:

  • Use MeSH terms for precise searching
  • Combine with text words for comprehensive coverage
  • Apply appropriate field tags
  • Filter by publication type and date
  • Use E-utilities API for automation
  • Document search strategy for reproducibility

For broader coverage across disciplines, complement with Google Scholar.

Raw lines 836 to 855