Query Ensembl's REST API for gene/transcript/protein lookup, sequence retrieval, Compara orthologs, VEP variant annotation, regulatory features, and LD. Encodes: the 15 req/sec rate limit (55K/hour); version-pinned archive endpoints (https://e110.rest.ensembl.org) for reproducibility; symbol-vs-Ensembl-ID stability (resolve symbol to ID once, then query by ID); Ensembl divisions (vertebrates main host vs Ensembl Genomes for plants/fungi/metazoa/bacteria); and the defection rules (BioMart for >5K queries; local VEP for bulk variant annotation).
pip install requests
No API key required. Respect Retry-After on 429.
"Don't use gene symbols in downstream queries -- HGNC renames break workflows (MARCH1 -> MARCHF1 in 2020). Resolve via /lookup/symbol/human/BRCA1 once, persist the Ensembl Gene ID (ENSG...), and use ID-based endpoints from then on."
"I'm writing a paper. Pin all Ensembl REST calls to https://e110.rest.ensembl.org so re-running in 2030 returns the same gene models. Live https://rest.ensembl.org follows the current release and drifts."
"Annotate this single variant (chr17:41276135 T>G) with VEP. Use /vep/human/region/17:41276135-41276135:1/G. For bulk (>1K variants), download VEP and run locally -- REST rate limit makes bulk infeasible."
"Get all Compara orthologs of human BRCA1 across mouse and zebrafish. Use /homology/symbol/human/BRCA1?type=orthologues. Filter by target_species and ortholog_one2one for high-confidence calls."
"What genes are in chr17:43000000-43200000? Use /overlap/region/human/{region}?feature=gene. For multiple feature types, repeat with feature=transcript, feature=regulatory, etc."
"For Arabidopsis or fungi, switch to rest.ensemblgenomes.org -- the main rest.ensembl.org host is vertebrates only."
e110, e111, etc.) for any reproducible analysis.rest.ensemblgenomes.org host.Accept: application/json header is the canonical request; the REST API also supports XML and other formats but JSON is the default.biomart-queries.homo_sapiens or human); see /info/species to enumerate./lookup/id POST with {"ids": [...]}); use POST for batches of <500 IDs to reduce request count.https://grch37.rest.ensembl.org.