# ClinicalTrials.gov Scraper - Studies and Sponsors (`s-r/clinicaltrials-scraper`) Actor

Search ClinicalTrials.gov by condition, intervention, sponsor or location, or pull studies by NCT id. Returns status, phase, enrolment with its type, eligibility, interventions, sponsors, locations and dates from the official API v2.

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

## Pricing

from $1.00 / 1,000 run start fees

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

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

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## ClinicalTrials.gov Scraper

Search the **ClinicalTrials.gov** registry by condition, intervention, sponsor
or location, or pull specific studies by NCT id. Status, phase, enrolment,
eligibility, interventions, sponsors, sites and dates.

Reads the registry's **official API v2**. No key, no login.

### Enrolment is often a target, not a fact

This is the field that most quietly produces wrong numbers, so it is worth
knowing before you sum anything.

`enrollment` comes with an `enrollment_type` of either **`ACTUAL`** or
**`ESTIMATED`**. An estimate is a recruitment target the sponsor hopes to hit; a
trial that never finished recruiting still carries it. Add the two together and
you overstate participation across every study still enrolling.

On a test run of 40 recruiting diabetes studies, **all 40** reported an
estimated enrolment — which is correct, because a trial that is still recruiting
has not achieved a number yet. The run summary counts them so the shape of your
data is visible before you aggregate it.

### Why this Actor connects directly

:

| Route | Result |
|---|---|
| Direct | **HTTP 200**, working JSON API |
| Through a residential proxy | `CONNECT tunnel failed, response 491` |

A 491 on the CONNECT is **our proxy refusing to tunnel to the host**, not the
registry refusing us. Both `.gov` targets measured this session behaved the
same way, so a proxy error on a government host says nothing about the site.

ClinicalTrials.gov publishes this API for exactly this use, so the Actor goes
direct and paces itself politely.

### Everything lives in a module

A study is a `protocolSection` containing a dozen modules, each holding a slice
of the record, and several fields are wrapped again inside that:

```
identificationModule nctId, briefTitle, officialTitle
statusModule overallStatus, startDateStruct { date, type }
designModule studyType, phases, designInfo, enrollmentInfo { count, type }
eligibilityModule minimumAge, maximumAge, sex, stdAges
contactsLocationsModule locations [ { country, city, facility } ]
```

Dates are inside `*DateStruct` objects. Enrolment is inside `enrollmentInfo`.
Allocation and masking are inside `designInfo`, and masking is inside
`maskingInfo` inside that. Reading a module and hoping for a flat field returns
nothing and raises nothing, so every extraction here names its full path and the
tests pin them.

### Fields

- **Identity**: `nct_id`, `title`, `official_title`, `url`
- **Status**: `status`, `why_stopped`, `has_results`
- **Design**: `study_type`, `phases`, `allocation`, `masking`,
  `primary_purpose`
- **Scale**: `enrollment`, `enrollment_type`, `location_count`, `countries`
- **Subject**: `conditions`, `keywords`, `interventions`, `intervention_types`,
  `primary_outcomes`
- **Who runs it**: `lead_sponsor`, `lead_sponsor_class`, `collaborators`
- **Who can join**: `minimum_age`, `maximum_age`, `sex`, `healthy_volunteers`,
  `std_ages`
- **When**: `start_date`, `primary_completion_date`, `completion_date`,
  `first_posted`, `last_update_posted`
- **Plain language**: `brief_summary`

`countries` is deduplicated while `location_count` counts sites, so a study with
28 sites across Italy shows 28 and `["Italy"]`. Those are different facts and
both are useful.

`lead_sponsor_class` separates INDUSTRY from NIH, academic and other funders,
which is usually the first cut in any competitive analysis.

### Input reference

| Field | Type | Default |
|---|---|---|
| `condition` | disease or condition | `diabetes` |
| `intervention` | drug or device | — |
| `sponsor` | sponsoring organisation | — |
| `location` | country, state or city | — |
| `search` | any other free-text term | — |
| `status` | one recruitment status | any |
| `nct_ids` | specific studies by id | — |
| `limit` | 1-5000 | 100 |
| `retries` | 1-6 | 3 |

Filters combine. Condition plus status plus sponsor narrows to exactly the
studies you want before pagination, which costs far fewer requests than
filtering afterwards.

### Typical uses

- **Competitive intelligence.** Every trial a sponsor is running, with phase,
  status and enrolment. Filter `lead_sponsor_class: INDUSTRY` to drop academic
  studies.
- **Pipeline tracking.** Filter by `intervention` to follow a drug across
  sponsors and indications.
- **Site selection.** `countries` and `location_count` show where trials for a
  condition actually run.
- **Recruitment monitoring.** `status: RECRUITING` with a condition gives the
  live trials, and `minimum_age` / `sex` / `healthy_volunteers` are the
  eligibility filters patients are matched on.
- **Trial outcome research.** `has_results` flags studies that have posted
  results, and `why_stopped` explains the ones that halted.

### Notes on behaviour

An NCT id that does not exist returns a `not_found` error naming it, never a row
of nulls. A malformed id is rejected as `bad_input` before a request is spent,
and the two are reported separately because they mean different things.

A 400 means the registry rejected the query and is not retried, since retrying
a bad parameter cannot help. A 429 or 500 is retried with backoff.

`totalCount` is reported in the summary, so when the registry matches more
studies than your `limit` you can see it rather than assuming you have
everything. Searching diabetes returns 24,325 studies in total; a `limit` of 100
gets you the first hundred.

# Actor input Schema

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

Disease or condition to search for, for example diabetes or breast cancer.

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

Drug, device or intervention to search for, for example semaglutide.

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

Sponsor organisation, for example Pfizer or Novo Nordisk.

## `location` (type: `string`):

Country, state or city where the study runs.

## `search` (type: `string`):

Any other term to search across the study record.

## `status` (type: `string`):

Restrict to one status. Leave empty for all.

## `nct_ids` (type: `array`):

Look up specific studies by NCT id instead of searching, for example NCT04666987.

## `limit` (type: `integer`):

How many studies to return. The registry returns 100 per page.

## `retries` (type: `integer`):

Retries with backoff before a request is reported as an error.

## Actor input object example

```json
{
  "condition": "diabetes",
  "status": "",
  "limit": 100,
  "retries": 3
}
```

# Actor output Schema

## `studies` (type: `string`):

One row per clinical study.

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

Counts, status breakdown and how many enrolments are estimates.

## `errors` (type: `string`):

Failures with a code and a redacted message.

# 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 = {
    "condition": "diabetes",
    "limit": 100,
    "retries": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("s-r/clinicaltrials-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 = {
    "condition": "diabetes",
    "limit": 100,
    "retries": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("s-r/clinicaltrials-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 '{
  "condition": "diabetes",
  "limit": 100,
  "retries": 3
}' |
apify call s-r/clinicaltrials-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,s-r/clinicaltrials-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/iKpsxxlDAh77pOrWX/builds/MAh6cwZSoSkjlBK7O/openapi.json
