# /genbank/sequences/search

`POST /api/genbank/sequences/search`

Price: 20 credits

Search GenBank and RefSeq nucleotide records by query and filters

## How to use it

Searches NCBI's nuccore nucleotide corpus. A plain word with no field filter matches anywhere in the record, so anchor it: pass `organism`, `gene` or `definition` rather than putting the word in `term`. A misspelt bracket tag inside `term` is not rejected - it falls through to a free-text match and quietly widens the result set, so prefer the structured fields. `divisions` is GenBank's own filing category and is not a taxonomy: environmental, patent and EST records are divisions of their own rather than members of the organism division they came from. Records carry no nucleotide letters here - fetch one by accession from /genbank/sequences to get those.

## Parameters

- `access-token` (string, required)

## Request body

- `timeout` (integer) — Max scrapping execution timeout (in seconds) (default: 300; min: 20; max: 1500)
- `term` (string, nullable) — Free-text query in Entrez syntax. Supports bracketed field tags (BRCA1[Gene Name], human[Organism], complete genome[Title]), boolean AND/OR/NOT and year ranges (2018:2022[PDAT]). Combined with AND against every structured filter below (examples: "BRCA1 AND human", "SARS-CoV-2 complete genome")
- `count` (integer, required) — Number of sequence records to return (min: 1; max: 5000)
- `offset` (integer) — How many matches to skip before the returned page, for walking past a single call's ceiling (default: 0; min: 0; max: 100000)
- `organism` (string, nullable) — Filter by source organism, scientific or common name (examples: "Homo sapiens", "human")
- `gene` (string, nullable) — Filter by gene name or symbol (examples: "BRCA1", "rpoB")
- `accession` (string, nullable) — Filter by nucleotide accession (examples: "NM_007300", "NC_002695")
- `definition` (string, nullable) — Filter by words in the record definition line, which is what nuccore calls a record title (examples: "complete genome")
- `author` (string, nullable) — Filter by an author of the submitting publication (examples: "Smith J")
- `journal` (string, nullable) — Filter by the journal of the submitting publication (examples: "Nature")
- `strain` (string, nullable) — Filter by source strain (examples: "K-12")
- `isolate` (string, nullable) — Filter by source isolate (examples: "NA12878")
- `bioproject` (string, nullable) — Filter by the BioProject the records belong to (examples: "PRJNA31257")
- `biosample` (string, nullable) — Filter by the BioSample the records were derived from (examples: "SAMN00000002")
- `assembly` (string, nullable) — Filter by the genome assembly the records belong to (examples: "GCF_000001405.40")
- `feature_key` (string, nullable) — Filter by an annotated feature key present on the record (examples: "CDS")
- `divisions` (array, nullable) — Filter by GenBank taxonomic or sequence division (any-of) (one of: "primate", "rodent", "other_mammal", "other_vertebrate", "invertebrate", "plant_fungal", "bacterial", "viral", "phage", "synthetic", "unannotated", "expressed_sequence_tag", "patent", "sequence_tagged_site", "genome_survey_sequence", "high_throughput_genomic", "high_throughput_cdna", "environmental_sample", "contig")
- `biomolecules` (array, nullable) — Filter by the kind of molecule the record represents (any-of) (one of: "genomic", "mrna", "rrna", "trna", "ncrna", "crna", "transcribed_rna", "genomic_mrna", "snrna", "snorna", "other")
- `source_databases` (array, nullable) — Filter by the database the record originates from, and for RefSeq by its curation status (any-of) (one of: "refseq", "genbank", "ddbj", "embl", "pdb", "refseq_reviewed", "refseq_validated", "refseq_provisional", "refseq_predicted", "refseq_model", "refseq_inferred")
- `min_length` (integer, nullable) — Smallest sequence length to return, in bases (examples: 1000; min: 1)
- `max_length` (integer, nullable) — Largest sequence length to return, in bases (examples: 5000; min: 1)
- `mindate` (string, nullable) — Start of the date range (YYYY, YYYY/MM or YYYY/MM/DD); used with maxdate (examples: "2024")
- `maxdate` (string, nullable) — End of the date range (YYYY, YYYY/MM or YYYY/MM/DD); used with mindate (examples: "2024")
- `datetype` (string) — Which date the range applies to (default: "pdat"; one of: "pdat", "mdat")
- `sort` (string) — Result ordering (default: "relevance"; one of: "relevance", "date_released", "date_modified", "organism_name", "accession")

## Response

### 200 — Successful Response

- `@type` (string) (default: "GenbankSequence")
- `id` (string, required)
- `accession` (string) (default: "")
- `gi` (string) (default: "")
- `definition` (string) (default: "")
- `organism` (string) (default: "")
- `taxid` (string) (default: "")
- `sequence_length` (integer, nullable)
- `molecule_type` (string) (default: "")
- `strandedness` (string) (default: "")
- `biomolecule` (string) (default: "")
- `topology` (string) (default: "")
- `completeness` (string) (default: "")
- `genome` (string) (default: "")
- `genetic_code` (string) (default: "")
- `source_database` (string) (default: "")
- `sequencing_technique` (string) (default: "")
- `strain` (string) (default: "")
- `biosample_accession` (string) (default: "")
- `bioproject_id` (string) (default: "")
- `assembly_accession` (string) (default: "")
- `assembly_gi` (string) (default: "")
- `qualifiers` (array) (default: [])
  - `@type` (string) (default: "GenbankSequenceQualifier")
  - `name` (string, required)
  - `value` (string, required)
- `is_indexed` (boolean) (default: false)
- `created_date` (string) (default: "")
- `updated_date` (string) (default: "")
- `sequence` (string) (default: "")
- `url` (string) (default: "")

## Errors

### 422 — Validation Error

The request body did not validate

What to do: Check the fields against this schema. A URN with the wrong prefix is the most common cause.

- `detail` (array)
  - `loc` (array, required)
  - `msg` (string, required)
  - `type` (string, required)
  - `input` (any)
  - `ctx` (object)

### 408

The request ran past its time limit

What to do: Raise `timeout` in the request body, up to the maximum this endpoint documents. Lowering `count` or turning off the `with_*` flags also helps, because less work finishes sooner.

### 412

The entity was not found, or a precondition failed

What to do: Retrying will not help: either the entity does not exist, or the input points at a different one.

### 429

Too many requests: a rate limit or a usage window is exhausted

What to do: When the response carries an X-Retry-After header, wait that many seconds and retry: the same number is in the body as `detail.retry_after`, and the limit clears once that window passes. The message in the body names the limit that was hit.

### 500

Something broke on our side

What to do: Retrying will not help. If it keeps happening, send us the X-Request-ID from the response headers.

### 529

Rate limit reached, or the endpoint is overloaded

What to do: Wait at least 30 seconds, then retry.

## Response envelope

Success: Array of objects (may be empty if no results)

Error: Error may coexist with partial results if it occurs mid-execution. Check X-Error header and status code.

Every response carries these headers:

- `X-Error` — Error message text (present only on error)
- `X-Request-ID` — Unique request identifier
- `X-Execution-Time` — Execution time in seconds
- `X-Result-Count` — How many records the body carries. 0 means an empty result, which is a normal answer and not by itself an error. A non-zero count can come back together with X-Error when the failure happened partway through — read this header and X-Error independently.
- `X-Total-Available-Results` — How many records exist for this query, when the endpoint can say. On a `dry_run` request this is the answer and the body is empty. It saturates: the endpoint's documented maximum means 'at least that many', any smaller number is exact.
- `X-Warning` — Present when the request body carried keys this endpoint does not document. They were ignored, so any filter you meant to apply through them did not apply. Check the spelling against this schema and retry.
- `X-Retry-After` — Seconds to wait before retrying. Present only on 429.

