# Open Targets Platform Scraper (`muhammadafzal/open-targets-platform-scraper`) Actor

Search Open Targets for targets, diseases, drugs, variants, studies, credible sets, and API metadata through its public GraphQL API.

- **URL**: https://apify.com/muhammadafzal/open-targets-platform-scraper.md
- **Developed by:** [Muhammad Afzal](https://apify.com/muhammadafzal) (community)
- **Categories:** AI, Automation, MCP servers
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 open targets record returneds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Open Targets Platform Scraper

Search the Open Targets Platform or fetch concise annotations for a single target, disease/phenotype, drug, variant, GWAS study, credible set, or the live API metadata. The actor uses the public Open Targets GraphQL endpoint, so it does not require cookies, an API key, or a browser session.

### Deployment status

The Actor is deployed privately on Apify as `muhammadafzal/open-targets-platform-scraper` (Actor ID `nYgkNd8nC6MuGWTZG`), with build `1.0.3` tagged `latest`. It has been cloud-validated across 21 diverse runs and intentionally remains unpublished.

### What it returns

Every dataset item has the same outer shape, which makes the actor suitable for pipelines and AI agents:

| Field | Meaning |
| --- | --- |
| `queryMode`, `entityType` | The requested mode and returned entity category. |
| `entityId`, `name`, `description` | Stable identifier and human-readable identity fields. |
| `score`, `categories` | Search relevance fields; detail modes use `null` and `[]`. |
| `query`, `sourceUrl` | Input and traceable Open Targets provenance. |
| `data` | Concise mode-specific annotations, not the unbounded raw GraphQL response. |
| `scrapedAt`, `warnings` | UTC collection time and record-level diagnostics. |

Target records include approved symbol/name, biotype, target classes, tractability, genetic constraint, and genomic coordinates. Disease records include therapeutic-area status, direct location IDs, and ancestors. Drug records include clinical stage, type, trade names, and synonyms. Variant, study, and credible-set modes return stable identifier and annotation fields from their current GraphQL types.

### When to use it

Use `search` to find identifiers from natural-language terms such as `cancer`, `asthma`, or `BRCA1`. Use a detail mode when you already have an identifier and need annotations. Use `metadata` to record the current API/data release before a reproducible analysis.

This actor is not a bulk data-download replacement. Open Targets recommends data downloads or BigQuery for systematic, multi-million-row analyses; this actor is bounded to 100 search records per run and one detail record per detail request.

### Input examples

Search the current entity index:

```json
{
  "queryMode": "search",
  "query": "cancer",
  "entityTypes": ["target", "disease", "drug"],
  "pageSize": 25,
  "maxResults": 25
}
```

Fetch a target annotation:

```json
{
  "queryMode": "target",
  "query": "ENSG00000169083"
}
```

Fetch a drug annotation:

```json
{
  "queryMode": "drug",
  "query": "CHEMBL1201580"
}
```

For `disease`, pass an Open Targets disease/phenotype identifier such as an EFO or MONDO ID. For `variant`, pass the identifier accepted by the current Platform API. For `study`, pass a study ID such as `GCST90002359`. For `credibleSet`, pass its `studyLocusId`. Detail identifiers are not silently searched or converted: an unmatched identifier produces an empty result with a warning.

### Example output

```json
{
  "queryMode": "search",
  "entityType": "disease",
  "entityId": "MONDO_0004992",
  "name": "cancer",
  "description": "A tumor composed of atypical neoplastic cells...",
  "score": 5508.947,
  "categories": ["cancer or benign tumor"],
  "query": "cancer",
  "sourceUrl": "https://platform.opentargets.org/search?q=cancer",
  "data": {
    "entity": "disease",
    "highlights": ["<em>cancer</em>"]
  },
  "scrapedAt": "2026-08-01T00:00:00.000Z",
  "warnings": []
}
```

The named key-value record `OUTPUT` contains `recordsCollected`, `chargedResults`, API request count, search totals, warnings, source URL, and API version when available. Valid empty searches and unmatched detail identifiers finish with a warning rather than fabricated dataset rows. Invalid GraphQL requests or upstream failures are reported as failed runs with an actionable message.

### Pricing

The intended pay-per-event configuration is:

| Event | Price |
| --- | ---: |
| `apify-actor-start` | $0.00005 once per run |
| `result-extracted` | $0.003 per validated dataset record |

The actor prints the maximum result-event cost before the request. A run with `maxResults: 25` can charge at most $0.075 in result events, plus the one-time start event and normal Apify platform usage. The runtime charges only after a validated record is successfully written. Set `ACTOR_CHARGE_RESULTS=false` only for local smoke tests; deployed PPE runs should leave charging enabled.

### Data access and limitations

The access path is the public GraphQL API at `https://api.platform.opentargets.org/api/v4/graphql`. The actor retries transient HTTP failures up to two times, bounds the request timeout, and does not use a proxy because the endpoint is a first-party public API. API fields and data releases can change; use metadata mode and preserve `OUTPUT.apiVersion` for reproducibility.

Open Targets documents the GraphQL API at [platform-docs.opentargets.org/data-access/graphql-api](https://platform-docs.opentargets.org/data-access/graphql-api), recommends downloads or BigQuery for systematic queries, and marks its data as CC0 in its [licence documentation](https://platform-docs.opentargets.org/licence). You remain responsible for validating scientific, clinical, and commercial decisions against the source and applicable policies. This independent actor is not affiliated with or endorsed by Open Targets.

### API and MCP use

Run the actor through the standard Apify Actor API and fetch the default dataset. Through Apify MCP, route natural-language entity discovery to `queryMode: search`, then use a returned `entityId` with the appropriate detail mode. The tool returns one stable record per entity and exposes the result-event cost in the run summary.

### Local development

```bash
npm install
npm test
npm run validate:schema
```

For a local request smoke test without PPE charging, set `ACTOR_CHARGE_RESULTS=false` and provide an Apify local input using the Apify CLI or runtime. No Open Targets credentials are needed.

# Actor input Schema

## `queryMode` (type: `string`):

Use 'search' to find platform entities, or choose a detail mode for one identifier. Examples: search, target, disease, drug, variant, study, credibleSet, metadata.

## `query` (type: `string`):

Use this when queryMode is search for text such as 'cancer', or in a detail mode for its identifier such as 'ENSG00000169083' or 'CHEMBL1201580'. Ignored in metadata mode.

## `entityTypes` (type: `array`):

Use this with search mode to narrow results. Pass lowercase Open Targets entity names such as \['target', 'disease', 'drug']; detail modes ignore this field.

## `pageIndex` (type: `integer`):

Use this with search mode for pagination. The first page is 0; for example, pageIndex 1 with pageSize 25 requests the second page.

## `pageSize` (type: `integer`):

Use this with search mode to control the Open Targets page size. It must be between 1 and 100; maxResults still caps returned records.

## `maxResults` (type: `integer`):

Maximum homogeneous dataset records to write and charge. Search results are capped at 100; detail and metadata modes return at most one record.

## `requestTimeoutSecs` (type: `integer`):

Maximum seconds for each public GraphQL request. The actor retries transient failures up to two times and accepts values from 10 to 60 seconds.

## Actor input object example

```json
{
  "queryMode": "search",
  "query": "cancer",
  "entityTypes": [
    "target",
    "disease",
    "drug"
  ],
  "pageIndex": 0,
  "pageSize": 25,
  "maxResults": 25,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

## `records` (type: `string`):

Validated homogeneous records returned by the search or detail query.

## `summary` (type: `string`):

Counts, warnings, billing information, source URL, and API version for the completed run.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("muhammadafzal/open-targets-platform-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("muhammadafzal/open-targets-platform-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call muhammadafzal/open-targets-platform-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=muhammadafzal/open-targets-platform-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/nYgkNd8nC6MuGWTZG/builds/JBed0wVCr3bTxZgde/openapi.json
