Entrez Text Search
eutils_esearchSearch any Entrez database and return matching UIDs for retrieval pipelines, with optional history handle for paging through results.
Instructions
Search an Entrez database and return matching UIDs.
This is the entry point for a retrieval pipeline. It returns UIDs, never records. By default it also stores the result set on the NCBI History server and returns a history handle, so later calls can page through the whole set without re-searching.
Entrez field tags go in square brackets: gene[tiab], 2008[pdat], mouse[orgn]. Boolean operators AND, OR, NOT must be uppercase.
Args:
db (string): database to search, for example "pubmed".
term (string): Entrez query, for example "breast cancer AND 2008[pdat]".
retmax (number, optional): UIDs to return, 0-10000. Default 20. Use 0 for count only.
retstart (number, optional): index of the first UID. Default 0.
sort (string, optional): "pub_date", "relevance", "first_author", ...
datetype ('pdat' | 'edat' | 'mdat', optional): date field for mindate/maxdate.
mindate, maxdate (string, optional): YYYY, YYYY/MM, or YYYY/MM/DD.
usehistory (boolean, optional): return a History handle. Default true.
response_format ('markdown' | 'json'): output format. Default 'markdown'.
Returns: { database, term, total, count, offset, has_more, next_offset, uids: string[], query_translation, term_translations: [{ from, to }], history? }
Examples:
Use when: "find papers about CRISPR in Nature" -> db="pubmed", term="CRISPR AND nature[journal]"
Use when: "how many records mention this gene?" -> retmax=0
Don't use when: you already have UIDs (use eutils_esummary or eutils_efetch)
Don't use when: you don't know which database (use eutils_egquery first)
Error Handling:
Rejects retmax above 10000 with advice to use the History server
Rejects an unknown database and lists valid ones
Returns an empty result with spelling advice rather than an error
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| db | Yes | Entrez database to search, for example "pubmed" or "protein". | |
| sort | No | Sort order, for example "pub_date", "relevance", or "first_author". Valid values vary by database. | |
| term | Yes | Entrez query. Field tags go in square brackets, for example "breast cancer AND 2008[pdat]" or "mouse[orgn]". | |
| retmax | No | Maximum UIDs to return (default 20). Use 0 to fetch only the count. | |
| maxdate | No | End date, as YYYY, YYYY/MM, or YYYY/MM/DD. Requires datetype. | |
| mindate | No | Start date, as YYYY, YYYY/MM, or YYYY/MM/DD. Requires datetype. | |
| datetype | No | Which date field mindate/maxdate apply to: pdat (publication), edat (Entrez), mdat (modification). | |
| retstart | No | Index of the first UID to return. Use for paging. | |
| usehistory | No | Store the result set on the NCBI History server and return a history handle (default true). Set false to skip it. | |
| response_format | No | Output format: 'markdown' for human-readable text, or 'json' for machine-readable data. Default: 'markdown'. | markdown |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| term | Yes | ||
| uids | Yes | ||
| count | Yes | Records returned on this page. | |
| total | Yes | Records matching the whole query, not just this page. | |
| offset | Yes | ||
| history | No | Present when usehistory is true. | |
| database | Yes | ||
| has_more | Yes | ||
| next_offset | No | ||
| query_translation | Yes | How Entrez rewrote the query. | |
| term_translations | Yes |