# KEGG Pathways, Genes & Compounds Scraper (`ninhothedev/kegg-scraper`) Actor

$0.5/1K 🔥 KEGG Explorer! Fetch pathways, genes & compounds across organisms. No key. JSON, CSV, Excel or API in seconds. Enrich metabolic and disease-pathway analysis ⚡

- **URL**: https://apify.com/ninhothedev/kegg-scraper.md
- **Developed by:** [ninhothedev](https://apify.com/ninhothedev) (community)
- **Categories:** Developer tools, AI
- **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

## KEGG Pathways, Genes & Compounds Scraper

Turn the **KEGG** database (Kyoto Encyclopedia of Genes and Genomes) into clean,
structured JSON. This Apify Actor talks to the free [KEGG REST API](https://rest.kegg.jp)
and parses its plain-text and flat-file responses into ready-to-use records for
**metabolic modelling, pathway analysis, drug research and bioinformatics pipelines**.

Roughly **~$0.50 per 1,000 records** on the Apify platform — no KEGG API key required.

***

### ⚠️ Licensing — please read (this matters)

**KEGG is free for academic and non-commercial use only.** The KEGG REST API
(`https://rest.kegg.jp`) may be used by academic users for non-commercial
purposes. **Commercial use, redistribution of KEGG data, and bulk downloads for
commercial products require a paid license from Pathway Solutions / the KEGG
FTP subscription.** This Actor is a thin, rate-limited client over the public
REST endpoint — it does **not** grant you any rights to KEGG data. You are
responsible for using it within KEGG's terms:

- Non-commercial / academic research: generally fine via the REST API.
- Commercial use or redistribution: obtain a KEGG license first.
- Always cite KEGG (Kanehisa et al.) in academic work.

See <https://www.kegg.jp/kegg/legal.html> and <https://www.pathway.jp/> for the
authoritative terms. When in doubt, contact KEGG. We keep request rates modest
and honest to respect their servers.

***

### What makes this different from our other biology scrapers

This Actor covers **KEGG specifically** — its pathway maps, KEGG gene ids,
KEGG compound (`C…`) / drug (`D…`) / disease (`H…`) / module (`M…`) ids, and
KEGG's own cross-links. If you need a **different** database, use the matching
Actor from the same account instead:

| Need | Use |
| --- | --- |
| Reactome pathways & reactions | [reactome-pathways-scraper](https://apify.com/ninhothedev/reactome-pathways-scraper) |
| UniProt protein records | [uniprot-scraper](https://apify.com/ninhothedev/uniprot-scraper) |
| ChEMBL bioactivity & compounds | [chembl-scraper](https://apify.com/ninhothedev/chembl-scraper) |
| STRING protein–protein interactions | [string-interactions-scraper](https://apify.com/ninhothedev/string-interactions-scraper) |
| **KEGG pathways / genes / compounds** | **this Actor** |

**KEGG vs Reactome specifically:** both are pathway databases, but they are not
interchangeable. KEGG is manually drawn "KEGG PATHWAY maps" with its own gene
and compound identifiers and a strong metabolic-pathway focus; it is licensed
non-commercially. Reactome is an open-source (CC-BY) reaction-level pathway
knowledgebase using Reactome stable ids and UniProt/ChEBI references. If you
need reaction-level detail with an open licence, use the Reactome Actor; if you
need KEGG pathway maps, KO/EC annotations and KEGG compound ids, use this one.

***

### Modes

| Mode | What it does | Key inputs |
| --- | --- | --- |
| `list` | List every entry in a KEGG database | `database`, `organism` (for pathways) |
| `get`  | Fetch full flat-file records by id | `ids` |
| `find` | Keyword search inside a database | `database`, `queries` |
| `link` | Cross-references between databases | `linkTarget`, `linkSource` |

#### Databases

`pathway`, `disease`, `drug`, `compound`, `module`, `enzyme`, `organism`.

> Note: KEGG's `/list/organism` endpoint currently returns HTTP 400 upstream;
> the Actor automatically falls back to `/list/genome`, which carries the same
> organism table (`T-number  code  description`).

***

### Input

```json
{
  "mode": "list",
  "database": "pathway",
  "organism": "hsa",
  "ids": ["hsa00010"],
  "queries": ["glucose"],
  "linkTarget": "pathway",
  "linkSource": "hsa:10458",
  "maxItems": 300
}
```

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | select | `list` | `list` / `get` / `find` / `link` |
| `database` | select | `pathway` | Target DB for `list` / `find` |
| `organism` | string | `hsa` | KEGG organism code for listing pathways (e.g. `hsa`, `mmu`, `eco`) |
| `ids` | array | – | Entry ids for `get`, e.g. `["hsa00010","C00031"]` |
| `queries` | array | – | Keywords for `find`, e.g. `["glucose"]` |
| `linkTarget` | string | – | Target DB for `link`, e.g. `pathway` |
| `linkSource` | string | – | Source id/db for `link`, e.g. `hsa:10458` |
| `maxItems` | integer | `300` | Cap on output records (max 5000) |

***

### Output

**`list` → `list_entry`**

```json
{ "type": "list_entry", "entry_id": "hsa00010", "database": "pathway",
  "name": "Glycolysis / Gluconeogenesis - Homo sapiens (human)",
  "organism": "hsa", "source": "kegg", "scraped_at": "..." }
```

**`get` → `record`** (flat-file parsed, continuation-line aware)

```json
{ "type": "record", "entry_id": "hsa00010", "database": "pathway",
  "name": "Glycolysis / Gluconeogenesis - Homo sapiens (human)",
  "description": "Glycolysis is the process of ...",
  "classes": ["Metabolism", "Carbohydrate metabolism"],
  "pathway_map": "hsa00010  Glycolysis / Gluconeogenesis",
  "gene_count": 67,
  "genes": [{ "id": "10327", "symbol": "AKR1A1" }],
  "compound_count": 31, "compounds": ["C00022", "C00024"],
  "module_ids": ["hsa_M00001"], "disease_ids": [],
  "reference_count": 0,
  "url": "https://www.kegg.jp/entry/hsa00010",
  "source": "kegg", "scraped_at": "..." }
```

**`find` → `search_hit`** · **`link` → `link`** — see the dataset overview view
(`entry_id`, `name`, `database`, `gene_count`).

All fields are nullable; the dataset schema is permissive.

***

### Use cases

- **Metabolic modelling** — pull pathway gene/compound membership for FBA/COBRA models.
- **Pathway analysis** — enrichment against KEGG pathway gene sets.
- **Drug research** — map KEGG DRUG ids, targets and pathway context.
- **Bioinformatics pipelines** — reproducible KEGG id/annotation extraction.

### How it works

KEGG REST returns **tab-separated text** (`list`/`find`/`link`) or **flat-file
records** (`get`) — never JSON. The Actor ships a robust flat-file parser that
respects the 12-character field column and reassembles continuation lines, so
multi-line `GENE` / `COMPOUND` / `DESCRIPTION` fields are never lost. Requests
are rate-limited to respect KEGG's servers.

### Disclaimer

Not affiliated with or endorsed by KEGG, Kanehisa Laboratories or Pathway
Solutions. Data © Kanehisa Laboratories. Use responsibly and within KEGG's
licence terms.

# Actor input Schema

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

What to scrape. 'list' = all entries in a KEGG database; 'get' = full flat-file records for the ids you provide; 'find' = keyword search inside a database; 'link' = cross-references between two databases.

## `database` (type: `string`):

Target KEGG database for 'list' and 'find' modes (ignored for 'get' and 'link').

## `organism` (type: `string`):

KEGG organism code used when listing pathways (mode=list, database=pathway). E.g. 'hsa' (human), 'mmu' (mouse), 'eco' (E. coli).

## `ids` (type: `array`):

KEGG entry ids to fetch full records for in 'get' mode. E.g. \["hsa00010", "C00031", "H00001"].

## `queries` (type: `array`):

Keywords to search inside the selected database in 'find' mode. E.g. \["glucose"].

## `linkTarget` (type: `string`):

Target database for 'link' mode, e.g. 'pathway'. Combined with linkSource as /link/{target}/{source}.

## `linkSource` (type: `string`):

Source id or database for 'link' mode, e.g. 'hsa:10458' (a gene) or 'hsa00010' (a pathway).

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

Maximum number of output records to produce across the whole run.

## Actor input object example

```json
{
  "mode": "list",
  "database": "pathway",
  "organism": "hsa",
  "ids": [
    "hsa00010"
  ],
  "queries": [
    "glucose"
  ],
  "linkTarget": "pathway",
  "linkSource": "hsa:10458",
  "maxItems": 300
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# 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 = {
    "ids": [
        "hsa00010"
    ],
    "queries": [
        "glucose"
    ],
    "linkTarget": "pathway",
    "linkSource": "hsa:10458"
};

// Run the Actor and wait for it to finish
const run = await client.actor("ninhothedev/kegg-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 = {
    "ids": ["hsa00010"],
    "queries": ["glucose"],
    "linkTarget": "pathway",
    "linkSource": "hsa:10458",
}

# Run the Actor and wait for it to finish
run = client.actor("ninhothedev/kegg-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 '{
  "ids": [
    "hsa00010"
  ],
  "queries": [
    "glucose"
  ],
  "linkTarget": "pathway",
  "linkSource": "hsa:10458"
}' |
apify call ninhothedev/kegg-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ninhothedev/kegg-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/tULej4jR9mINtCdWA/builds/U89vUyGJdY2hD7IbK/openapi.json
