# 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, 0 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 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

## 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

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