# PubMed

> Search PubMed / NCBI biomedical literature - PMIDs, summaries, abstracts, and related articles. API key optional.

Lets an agent search and read biomedical literature through the NCBI E-utilities that power PubMed: find article IDs (PMIDs), pull document summaries and abstracts, follow links to related or full-text records, and inspect database metadata.

The API key is **optional**. PubMed works without one at a lower request rate; adding an NCBI key raises the rate limit (from 3 to 10 requests per second).

## What it can do

| Method | What it does |
| --- | --- |
| `pubmed_search` | Search for matching record IDs (esearch). Entrez query syntax, with optional date filters and sorting. |
| `pubmed_summary` | Get document summaries for IDs (esummary): titles, authors, journal, dates. |
| `pubmed_fetch` | Fetch full records / abstracts for IDs (efetch). Text or XML - efetch has no JSON output. |
| `pubmed_link` | Find related or linked records (elink), e.g. related articles or PMC full text. |
| `pubmed_info` | Describe an Entrez database, or list all databases (einfo). |
| `pubmed_request` | Generic passthrough to any E-utility for full coverage. |

## How to get your key (optional)

You can skip this entirely - PubMed works keyless.

1. Sign in or create an account at [NCBI](https://www.ncbi.nlm.nih.gov/account/).
2. Open **Account Settings** ([ncbi.nlm.nih.gov/account/settings](https://www.ncbi.nlm.nih.gov/account/settings/)).
3. Find **API Key Management** and create a key.
4. Paste it into FlyMyAI - or leave the field blank to use PubMed at the lower keyless rate.

## Fields to fill

| FlyMyAI field | Where it comes from |
| --- | --- |
| `PUBMED_API_KEY` | Optional - NCBI -> Account Settings -> API Key Management. Leave blank to run keyless. |

## Troubleshooting

- **`429 Too Many Requests`** - you hit the rate limit. Add an NCBI API key to raise it, or slow down the calls.
- **Empty results from `pubmed_search`** - check the Entrez query syntax (e.g. `crispr AND 2023[pdat]`). Field tags like `[au]`, `[ti]`, `[pdat]` are case-sensitive in some contexts.
- **`pubmed_fetch` returns text/XML, not JSON** - efetch has no JSON mode; the content arrives under a `raw` field. Use `pubmed_summary` for structured JSON metadata.
- **No related articles from `pubmed_link`** - set `linkname` to `pubmed_pubmed` for related articles, or `db=pmc` to find free full-text links.

## Links

- [NCBI API Key settings](https://www.ncbi.nlm.nih.gov/account/settings/)
- [E-utilities documentation](https://www.ncbi.nlm.nih.gov/books/NBK25501/)
