# Ensembl Gene Scraper - Gene IDs, Biotype & Location (`ninhothedev/ensembl-scraper`) Actor

$0.5/1K 🔥 Ensembl gene scraper! Gene IDs, biotype, chromosome location & description across species. No key. JSON, CSV, Excel or API in seconds. Power genomics pipelines ⚡

- **URL**: https://apify.com/ninhothedev/ensembl-scraper.md
- **Developed by:** [ninhothedev](https://apify.com/ninhothedev) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Ensembl Gene Scraper - Gene IDs, Biotype, Location & Descriptions

Turn a plain list of **gene symbols** (BRCA2, TP53, EGFR) or **Ensembl gene IDs** (ENSG00000139618) into a clean, structured dataset: stable Ensembl ID, gene symbol, description, biotype, chromosome, start/end coordinates, strand, gene length, genome assembly and a direct link to the Ensembl gene page.

No API key. No login. No cookies. Works on Apify's shared datacenter proxies out of the box, and covers **every species in Ensembl** - human, mouse, rat, zebrafish, fruit fly, yeast, plants and more.

***

### What this actor does

The Ensembl REST API is the reference source for genome annotation, but it returns raw JSON one gene at a time and is easy to get wrong (species-scoped symbol lookups, 400s instead of 404s, a ~15 requests/second rate limit). This actor wraps it into a batch-friendly scraper:

- **Batch lookups** - up to 50 genes per request via Ensembl's POST endpoints, with automatic per-gene fallback if a batch fails.
- **Two input modes** - start from gene symbols + a species, or from stable Ensembl gene IDs.
- **Any species** - `homo_sapiens`, `mus_musculus`, `danio_rerio`, `drosophila_melanogaster`, `saccharomyces_cerevisiae`, and everything else Ensembl annotates.
- **Rate-limit aware** - paced requests with retries and backoff so long lists finish instead of getting throttled.
- **Clean, flat output** - one row per gene, ready for CSV, Excel, JSON, or a direct API pull into your pipeline.

### Use cases

- **Genomics** - annotate a gene list from a screen, a panel, or a variant caller with coordinates, biotype and assembly.
- **Bioinformatics** - map gene symbols to stable Ensembl IDs before a join with expression matrices, GTF files, or another database.
- **Gene research** - pull descriptions, biotypes and locations for a target list without clicking through the Ensembl website.
- **Datasets** - build reusable reference tables of genes per species for dashboards, teaching material, or internal tooling.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `mode` | select | `symbols` | `symbols` = look up gene symbols within a species. `ids` = look up Ensembl gene IDs directly. |
| `symbols` | array | `["BRCA2","TP53"]` | Gene symbols to resolve. Used in `symbols` mode. |
| `species` | string | `homo_sapiens` | Ensembl species name in snake\_case. Used in `symbols` mode. |
| `geneIds` | array | - | Stable Ensembl gene IDs, e.g. `ENSG00000139618`. Used in `ids` mode. |
| `maxItems` | integer | `100` | Maximum number of gene records to push (max 1000). |

#### Example - symbols mode

```json
{
  "mode": "symbols",
  "symbols": ["BRCA2", "TP53", "EGFR", "MYC"],
  "species": "homo_sapiens",
  "maxItems": 100
}
```

#### Example - IDs mode

```json
{
  "mode": "ids",
  "geneIds": ["ENSG00000139618", "ENSG00000141510", "ENSMUSG00000041147"],
  "maxItems": 100
}
```

### Output

One dataset item per gene:

```json
{
  "ensembl_id": "ENSG00000139618",
  "symbol": "BRCA2",
  "description": "BRCA2 DNA repair associated [Source:HGNC Symbol;Acc:HGNC:1101]",
  "biotype": "protein_coding",
  "species": "homo_sapiens",
  "chromosome": "13",
  "start": 32315086,
  "end": 32400268,
  "strand": 1,
  "length": 85182,
  "assembly": "GRCh38",
  "object_type": "Gene",
  "version": 19,
  "source_db": "ensembl_havana",
  "url": "https://www.ensembl.org/homo_sapiens/Gene/Summary?g=ENSG00000139618",
  "source": "ensembl",
  "scraped_at": "2026-07-28T11:36:45.521715+00:00"
}
```

Every field is nullable - upstream annotation is uneven across species, and the actor never invents data.

### Pricing

Roughly **$0.5 per 1,000 genes** on the Apify platform, depending on your plan's compute-unit rate. The actor runs on 512 MB and batches 50 genes per request, so a 1,000-gene list finishes in well under a minute.

### Tips

- Symbol lookups are **species-specific**. `BRCA2` resolves in `homo_sapiens`; the mouse ortholog is `Brca2` in `mus_musculus`.
- Not sure about a symbol? Use `ids` mode with the stable Ensembl ID - it is unambiguous and version-safe.
- Mixing species in one run is easy in `ids` mode: Ensembl IDs carry their own species prefix (`ENSG`, `ENSMUSG`, `ENSDARG`, ...).
- `length` is `end - start` in base pairs on the reference assembly.

### Related actors

Building a life-sciences data pipeline? These pair well with this one:

- [UniProt Scraper](https://apify.com/ninhothedev/uniprot-scraper) - protein entries, sequences, functions and cross-references.
- [RCSB PDB Scraper](https://apify.com/ninhothedev/rcsb-pdb-scraper) - 3D protein structures and experimental metadata.
- [ChEMBL Scraper](https://apify.com/ninhothedev/chembl-scraper) - bioactive molecules, targets and assay data.
- [PubMed Scraper](https://apify.com/ninhothedev/pubmed-scraper) - biomedical literature, abstracts and metadata.

### Data source & attribution

Data comes from the public [Ensembl REST API](https://rest.ensembl.org) (EMBL-EBI / Wellcome Sanger Institute), which is free to use without an API key. Please cite Ensembl in publications and respect their fair-use policy (~15 requests/second) - this actor already paces itself accordingly.

### Local development

```bash
pip install -r requirements.txt
python -m src.main
python tests/test_smoke.py   # offline smoke tests, no network needed
```

# Actor input Schema

## `mode` (type: `string`):

How genes are resolved. 'symbols' looks up gene symbols (e.g. BRCA2) within the selected species. 'ids' looks up Ensembl gene IDs (e.g. ENSG00000139618) directly, in which case the species field is ignored.

## `symbols` (type: `array`):

Gene symbols to look up in the selected species, for example BRCA2, TP53 or EGFR. Only used when mode is 'symbols'. Symbols are case-insensitive and de-duplicated automatically.

## `species` (type: `string`):

Ensembl species name in snake\_case, for example homo\_sapiens, mus\_musculus, danio\_rerio or drosophila\_melanogaster. Only used when mode is 'symbols'.

## `geneIds` (type: `array`):

Stable Ensembl gene IDs to look up, for example ENSG00000139618 (human BRCA2) or ENSMUSG00000041147 (mouse Brca2). Only used when mode is 'ids'.

## `maxItems` (type: `integer`):

Maximum number of gene records to push to the dataset. Use it to cap runtime and cost on large symbol or ID lists.

## Actor input object example

```json
{
  "mode": "symbols",
  "symbols": [
    "BRCA2",
    "TP53"
  ],
  "species": "homo_sapiens",
  "geneIds": [
    "ENSG00000139618"
  ],
  "maxItems": 100
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "symbols": [
        "BRCA2",
        "TP53"
    ],
    "species": "homo_sapiens",
    "geneIds": [
        "ENSG00000139618"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ninhothedev/ensembl-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "symbols": [
        "BRCA2",
        "TP53",
    ],
    "species": "homo_sapiens",
    "geneIds": ["ENSG00000139618"],
}

# Run the Actor and wait for it to finish
run = client.actor("ninhothedev/ensembl-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "symbols": [
    "BRCA2",
    "TP53"
  ],
  "species": "homo_sapiens",
  "geneIds": [
    "ENSG00000139618"
  ]
}' |
apify call ninhothedev/ensembl-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ninhothedev/ensembl-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/BHkhK8BePLsJhvV4V/builds/zNRoTYoudgQ1qx5KY/openapi.json
