# ClinicalTrials.gov Scraper (`datamule/clinicaltrials-gov-scraper`) Actor

Scrape clinical-trial records from the official ClinicalTrials.gov v2 REST API. Query by condition, intervention, sponsor, status, phase or free text. One record per study — NCT id, title, status, phase, sponsor, conditions, interventions, enrollment, dates, locations + the raw study. Pay per study.

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

## Pricing

from $0.35 / 1,000 study returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## ClinicalTrials.gov Scraper

Scrape clinical-trial registry records from the **official ClinicalTrials.gov v2 REST API**
(`https://clinicaltrials.gov/api/v2/studies`) — the U.S. NIH registry of clinical studies.
No API key, no login. One clean dataset record per study, with a flat set of normalized
columns plus the complete raw study object so nothing is lost.

### What it does

Query the registry by any combination of filters (the API ANDs them together):

| Input | API field | Example |
|-------|-----------|---------|
| `query` | free-text over the whole record | `GLP-1`, `long COVID` |
| `condition` | condition / disease | `type 2 diabetes` |
| `intervention` | intervention / drug / device | `semaglutide` |
| `sponsor` | lead sponsor / collaborator | `Pfizer` |
| `titles` | words in the study title | `migraine prevention` |
| `nctId` | a specific study id | `NCT03470961` |
| `status` | recruitment status (multi-select) | `RECRUITING`, `COMPLETED` |
| `phase` | trial phase | `PHASE3` |
| `studyType` | interventional / observational | `INTERVENTIONAL` |
| `sort` | result ordering | `LastUpdatePostDate:desc` |

`maxResults` caps how many studies you get; the actor paginates automatically (opaque
`nextPageToken`, up to 1000 studies per request) until it reaches the cap or the result set
is exhausted.

### Output

One dataset record per study. Normalized convenience columns:

`nctId`, `briefTitle`, `officialTitle`, `acronym`, `overallStatus`, `studyType`, `phases`,
`phase`, `conditions`, `interventions`, `interventionTypes`, `leadSponsor`,
`leadSponsorClass`, `collaborators`, `enrollment`, `startDate`, `primaryCompletionDate`,
`completionDate`, `lastUpdatePostDate`, `locations` (facility / city / state / country),
`locationCountries`, `hasResults`, `studyUrl`

…plus **`raw`** — the complete, untouched study object from the API
(`protocolSection`, `derivedSection`, …) so any field not surfaced above is still available.

### Example input

```json
{
  "condition": "diabetes",
  "intervention": "metformin",
  "status": ["RECRUITING"],
  "phase": "PHASE3",
  "maxResults": 200,
  "sort": "LastUpdatePostDate:desc"
}
````

A query that matches nothing returns **0 records and succeeds** (never an error).

### Pricing

Pay-per-event: charged per study returned.

### Source

Data comes from the U.S. National Library of Medicine's ClinicalTrials.gov v2 API
(<https://clinicaltrials.gov/data-api/api>). ClinicalTrials.gov data is in the public domain.
This actor is an independent tool and is not affiliated with or endorsed by NIH / NLM.

# Actor input Schema

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

Free-text search across the whole study record (maps to the API's query.term). e.g. "GLP-1", "long COVID", "CAR-T". Combine with the field-specific filters below — the API ANDs them together. Leave everything empty to return the most recent studies.

## `condition` (type: `string`):

Condition or disease being studied (query.cond). e.g. "type 2 diabetes", "breast cancer", "alzheimer".

## `intervention` (type: `string`):

Intervention, drug, device or treatment (query.intr). e.g. "metformin", "semaglutide", "pacemaker".

## `sponsor` (type: `string`):

Lead sponsor or collaborator organisation (query.spons). e.g. "Pfizer", "Mayo Clinic", "National Cancer Institute".

## `titles` (type: `string`):

Words that must appear in the brief or official study title (query.titles). e.g. "migraine prevention".

## `nctId` (type: `string`):

Look up a specific study by its ClinicalTrials.gov identifier or org study id (query.id). e.g. "NCT03470961".

## `status` (type: `array`):

Filter to one or more overall recruitment statuses (filter.overallStatus). Leave empty for any status.

## `phase` (type: `string`):

Filter to a single clinical-trial phase (aggFilters phase). Leave empty for any phase.

## `studyType` (type: `string`):

Filter to interventional or observational studies (aggFilters studyType). Leave empty for any type.

## `sort` (type: `string`):

Sort results by a field. e.g. LastUpdatePostDate:desc (most recently updated first), EnrollmentCount:desc, StartDate:desc. Leave empty for the API's default relevance order.

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

Maximum number of studies to return. The actor paginates automatically at up to 1000 per request until this many are collected or the result set is exhausted.

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

Studies fetched per API request (1–1000). Larger pages = fewer requests. Usually leave at the default.

## Actor input object example

```json
{
  "query": "diabetes",
  "status": [],
  "phase": "",
  "studyType": "",
  "maxResults": 100,
  "pageSize": 100
}
```

# 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 = {
    "query": "diabetes",
    "condition": "",
    "intervention": "",
    "sponsor": "",
    "titles": "",
    "nctId": "",
    "sort": "",
    "maxResults": 100,
    "pageSize": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("datamule/clinicaltrials-gov-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 = {
    "query": "diabetes",
    "condition": "",
    "intervention": "",
    "sponsor": "",
    "titles": "",
    "nctId": "",
    "sort": "",
    "maxResults": 100,
    "pageSize": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("datamule/clinicaltrials-gov-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 '{
  "query": "diabetes",
  "condition": "",
  "intervention": "",
  "sponsor": "",
  "titles": "",
  "nctId": "",
  "sort": "",
  "maxResults": 100,
  "pageSize": 100
}' |
apify call datamule/clinicaltrials-gov-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "ClinicalTrials.gov Scraper",
        "description": "Scrape clinical-trial records from the official ClinicalTrials.gov v2 REST API. Query by condition, intervention, sponsor, status, phase or free text. One record per study — NCT id, title, status, phase, sponsor, conditions, interventions, enrollment, dates, locations + the raw study. Pay per study.",
        "version": "0.1",
        "x-build-id": "IhRwnK3JIb1hLdh2J"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/datamule~clinicaltrials-gov-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-datamule-clinicaltrials-gov-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/datamule~clinicaltrials-gov-scraper/runs": {
            "post": {
                "operationId": "runs-sync-datamule-clinicaltrials-gov-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/datamule~clinicaltrials-gov-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-datamule-clinicaltrials-gov-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "query": {
                        "title": "Search term (free text)",
                        "type": "string",
                        "description": "Free-text search across the whole study record (maps to the API's query.term). e.g. \"GLP-1\", \"long COVID\", \"CAR-T\". Combine with the field-specific filters below — the API ANDs them together. Leave everything empty to return the most recent studies."
                    },
                    "condition": {
                        "title": "Condition / disease",
                        "type": "string",
                        "description": "Condition or disease being studied (query.cond). e.g. \"type 2 diabetes\", \"breast cancer\", \"alzheimer\"."
                    },
                    "intervention": {
                        "title": "Intervention / treatment",
                        "type": "string",
                        "description": "Intervention, drug, device or treatment (query.intr). e.g. \"metformin\", \"semaglutide\", \"pacemaker\"."
                    },
                    "sponsor": {
                        "title": "Sponsor / collaborator",
                        "type": "string",
                        "description": "Lead sponsor or collaborator organisation (query.spons). e.g. \"Pfizer\", \"Mayo Clinic\", \"National Cancer Institute\"."
                    },
                    "titles": {
                        "title": "Words in title",
                        "type": "string",
                        "description": "Words that must appear in the brief or official study title (query.titles). e.g. \"migraine prevention\"."
                    },
                    "nctId": {
                        "title": "NCT id",
                        "type": "string",
                        "description": "Look up a specific study by its ClinicalTrials.gov identifier or org study id (query.id). e.g. \"NCT03470961\"."
                    },
                    "status": {
                        "title": "Recruitment status",
                        "type": "array",
                        "description": "Filter to one or more overall recruitment statuses (filter.overallStatus). Leave empty for any status.",
                        "items": {
                            "type": "string",
                            "enum": [
                                "RECRUITING",
                                "NOT_YET_RECRUITING",
                                "ENROLLING_BY_INVITATION",
                                "ACTIVE_NOT_RECRUITING",
                                "COMPLETED",
                                "SUSPENDED",
                                "TERMINATED",
                                "WITHDRAWN",
                                "UNKNOWN",
                                "AVAILABLE",
                                "NO_LONGER_AVAILABLE",
                                "TEMPORARILY_NOT_AVAILABLE",
                                "APPROVED_FOR_MARKETING",
                                "WITHHELD"
                            ],
                            "enumTitles": [
                                "Recruiting",
                                "Not yet recruiting",
                                "Enrolling by invitation",
                                "Active, not recruiting",
                                "Completed",
                                "Suspended",
                                "Terminated",
                                "Withdrawn",
                                "Unknown",
                                "Available (expanded access)",
                                "No longer available",
                                "Temporarily not available",
                                "Approved for marketing",
                                "Withheld"
                            ]
                        },
                        "default": []
                    },
                    "phase": {
                        "title": "Trial phase",
                        "enum": [
                            "",
                            "EARLY_PHASE1",
                            "PHASE1",
                            "PHASE2",
                            "PHASE3",
                            "PHASE4"
                        ],
                        "type": "string",
                        "description": "Filter to a single clinical-trial phase (aggFilters phase). Leave empty for any phase.",
                        "default": ""
                    },
                    "studyType": {
                        "title": "Study type",
                        "enum": [
                            "",
                            "INTERVENTIONAL",
                            "OBSERVATIONAL"
                        ],
                        "type": "string",
                        "description": "Filter to interventional or observational studies (aggFilters studyType). Leave empty for any type.",
                        "default": ""
                    },
                    "sort": {
                        "title": "Sort",
                        "type": "string",
                        "description": "Sort results by a field. e.g. LastUpdatePostDate:desc (most recently updated first), EnrollmentCount:desc, StartDate:desc. Leave empty for the API's default relevance order."
                    },
                    "maxResults": {
                        "title": "Max results",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of studies to return. The actor paginates automatically at up to 1000 per request until this many are collected or the result set is exhausted.",
                        "default": 100
                    },
                    "pageSize": {
                        "title": "Page size",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Studies fetched per API request (1–1000). Larger pages = fewer requests. Usually leave at the default.",
                        "default": 100
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
