
PubMed API
FreeEfficiently search and fetch scientific literature from PubMed.
Free · Opens the source repo
What PubMed API does
The PubMed API skill provides a command-line interface for accessing the NCBI PubMed and PubMed Central APIs, allowing users to search for scientific literature, including clinical trials, and retrieve abstracts and full texts. Utilizing the scripts/pubmed_api.py script, users can execute various functions such as searching, fetching articles, linking to biological databases, and performing citation matching. This skill is particularly useful for researchers, clinicians, and developers who need to integrate scientific literature into their applications or workflows.
The skill supports bulk processing of results, enabling users to cache result sets for efficiency. It also includes features to verify medical spelling and match raw citations, which can help streamline the research process. By interfacing with biological databases, users can discover associations between published research and specific compounds or genes, enhancing their ability to conduct thorough literature reviews and analyses.
To ensure proper usage, users are required to follow specific setup instructions, including the installation of the uv skill and the creation of an .env file for environment variables. The skill also encourages the use of an NCBI API key to increase the rate limit for requests, which is beneficial for users planning to make numerous queries. The provided CLI manages rate limits automatically, ensuring compliance with NCBI's usage policies.
Overall, the PubMed API skill is a powerful tool for anyone involved in academic research or scientific inquiry, offering a structured and efficient way to access a wealth of medical literature and data.
When to use it
Use this skill when you need to programmatically search PubMed for articles, fetch abstracts, or link research to biological databases.
When not to use it
This skill is not suitable for casual browsing of literature; it is designed for structured queries and bulk processing.
What you can build with it
Searching for Clinical Trials
Use the skill to search for specific clinical trials related to a medical condition and retrieve relevant abstracts.
Linking Research to Biological Databases
Fetch articles and link them to gene or compound databases to explore relationships between research findings and biological entities.
Bulk Literature Review
Conduct a comprehensive literature review by caching search results and processing multiple articles in one go.
How to install PubMed API
View source1. Install with the skills CLI
npx skills add google-deepmind/science-skills/pubmed_database --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by google-deepmindPubMed API
Prerequisites
uv: Read theuvskill and follow its Setup instructions to ensureuvis installed and on PATH.- User Notification: If .licenses/pubmed_database_LICENSE.txt does not already exist in the workspace root directory then (1) prominently notify the user to check the terms at https://pubmed.ncbi.nlm.nih.gov/disclaimer/ and https://www.ncbi.nlm.nih.gov/home/about/policies/ and to always check the license of the papers retrieved by the skill for any restrictions, then (2) create the file recording the notification text and timestamp.
.envfile: Make sure the.envfile exists in your home directory. Create one if it does not exist.NCBI_API_KEY(optional): Raises the NCBI E-utilities rate limit from 3 to 10 requests/second. The skill works without it, but a key is recommended if the user plans many queries or encounters a 429 error. You can register for a key for free at https://www.ncbi.nlm.nih.gov/account/settings/. You MUST use the safe credentials protocol in thecredentialsskill to check for and request this key if this skill looks relevant to the user's request.USER_EMAIL(optional): Identifies the caller to NCBI (recommended by their Terms of Use). You MUST use the safe credentials protocol in thecredentialsskill to check for and request this credential if this skill looks relevant to the user's request.
This skill provides CLI access to the NCBI PubMed and PubMed Central APIs via
scripts/pubmed_api.py — a single CLI with 10 functions covering search, fetch,
linking, full text, spelling, discovery, citation matching, and caching.
Core Rules
- API Use: Always use the provided wrapper
scripts/pubmed_api.pywhich manages rate limits automatically and prevents API abuse. Setting theNCBI_API_KEYenvironment variable raises the rate limit from 3 to 10 requests/second. Querying the API any other way (e.g. via curl, wget, or hand-written code) is strictly forbidden. - JSON Processing: Use
jqto filter and transform JSON output (or python equivalents ifjqis not available) to prevent hallucinations and context overflow. - Temporary Files: To avoid polluting the working directory with JSON
files, use a temporary directory inside the current directory. When running
multiple agents or tasks in parallel, ensure each uses a unique subdirectory
name (e.g.,
tmp_$TASK_ID/) to avoid file collisions. - Notification: If this skill is used, ensure this is mentioned in the output AND list the URLs of all papers that were used in producing the output.
Structure of the skill folder
SKILL.md- This filescripts/pubmed_api.py- The skill CLIreferences/- Directory with detailed function specificationsadvanced-linking.mdadvanced-search.mdbulk-workflows.mdcitation-matching.mdcross-database-linking.mdfetch-and-resolve.mdsearch-and-discovery.mdutilities.md
CLI Usage
uv run scripts/pubmed_api.py <output_file> <function_name> <required_args> [--flag value ...]
- Positional Arguments: Arguments are positional; list arguments are
passed as comma-separated strings without spaces (e.g.
"35113657,31234568"). - Flag Options: Optional arguments can be passed as
--flag valueinstead of positional args. - Output Handling: On success, JSON is written to
output_file. On error, the process exits with a non-zero code and no output file is written.
Example Usage
uv run scripts/pubmed_api.py ./search_results.json search_pubmed "BRCA1" --max_results 5
cat ./search_results.json | jq '.[]' -r
uv run scripts/pubmed_api.py ./abstracts.json fetch_article_abstracts "35113657"
cat ./abstracts.json | jq '.[0].title' -r
Essential Recipes
Join PMIDs for the next call (most common chaining pattern):
cat ./search_results.json | jq -r 'join(",")'
Slim abstracts to essential fields and truncate long abstracts:
cat ./abstracts.json | jq '[.[] | {pmid, title, snippet: (.abstract // "")[:500]}]'
Filter by keyword (null-safe):
cat ./abstracts.json | jq '[.[] | select((.title // "") | contains("Review"))]'
Context Management & Accuracy
When processing larger result sets (>10 abstracts):
- Filter Early: Use
jqto verify keywords in abstracts before reading the full JSON into context. - Slimming: Extract only
titleandabstractfields unless explicitly instructed otherwise. Author lists and metadata contribute to noise. - Bulk Operations (N > 10): Avoid fetching or processing IDs one-by-one. The API and History Server are designed for bulk retrieval. Fetch all data in a single turn and use shell pipelines to slim the results before reading into context. This prevents turn exhaustion and context overflow.
- Grounding: Never use internal knowledge to provide specific identifiers (PMIDs, CIDs, Gene IDs) if no results are found. Report the tool's output accurately to ensure results are grounded in the current database state.
- Search Termination: When asked to find papers that may not exist, limit exploration to 3–5 high-quality, varied search queries. If no results match after these attempts, conclude that no papers meet the criteria rather than continuing to iterate — unless explicitly instructed to be thorough.
Functions
⚠️ MANDATORY: You MUST read the linked reference file for a function group before calling any function in that group. The tables below only describe what each function does — not how to call it. Argument names, argument order, flags, and output schemas are only documented in the reference files. Do NOT guess or infer arguments from function names. If you call a function without first reading its reference, you will produce incorrect invocations.
Search
search_pubmed: Find PMIDs matching a free-text or structured NCBI query.global_database_discovery: Count how many records match a query across every NCBI database.
Fetch & Resolve
fetch_article_abstracts: Retrieve metadata and abstracts for a batch of PMIDs.get_full_text_pmc: Retrieve open-access full text from PMC.fetch_database_summary: Resolve opaque UIDs from any NCBI database into human-readable metadata.
Cross-Database Linking
find_linked_biological_data: Find records in other NCBI databases linked to a source record.discover_available_links: List all available ELink linknames for a given record.
Bulk Workflows
When working with more than ~10 PMIDs, avoid processing IDs one-by-one.
Upload them to the NCBI History Server via cache_results_history to get a
session handle (webenv + query_key), then pass that handle to
fetch_article_abstracts or find_linked_biological_data for a single bulk
call. Chain with jq shell pipelines to slim results before reading into
context. This prevents turn exhaustion and context overflow. See the reference
for complete workflow recipes (search→fetch, cross-db exploration, citation
resolution, and bulk retrieval with data slimming).
cache_results_history: Upload PMIDs to the NCBI History Server for bulk retrieval.
Utilities
verify_medical_spelling: Spell-check biomedical terms before searching.match_raw_citations: Resolve incomplete bibliographic citations to PMIDs.
Frequently asked questions about PubMed API
Similar skills
Build Evidence Map
Create auditable maps for technical decisions and research.
Systematic Literature Review
Automate your systematic literature reviews with ease.
Nature Reference Verifier
Cross-verify academic references efficiently.
Nature Paper Card
Create evidence-grounded research cards for scientific papers.
Nature Literature Pipeline
Automate daily literature discovery and delivery.
Paperclip CLI
Efficiently search and read biomedical literature and regulatory documents.
