# Clinicaltrials Gov Scraper (`kawsar/clinicaltrials-gov-scraper`) Actor

Scrape ClinicalTrials.gov studies by condition, sponsor, status, or NCT ID. Retrieve comprehensive protocol details, trial sites, and contacts, and easily export your data to CSV, JSON, or Excel.

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

## Pricing

from $2.99 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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: Studies, Sponsors & Sites

<p align="center">
  <img src="https://imgur.com/brpkbOT.png" alt="ClinicalTrials.gov Scraper" style="max-width:100%; border-radius:14px; width:680px;" />
</p>

Easily search and extract clinical trial records from official registries, saving one clean row per trial. Filter studies by condition, intervention, sponsor, and overall status, or pull complete trial details directly using specific NCT IDs. Export your structured datasets to JSON, CSV, or Excel for analysis and research tracking.

Instead of manually browsing through clinical trial databases, you can collect up-to-date recruitment and sponsor information in bulk.

### Use Cases

- **Recruiting lists:** Extract active studies currently recruiting participants for targeted medical conditions.
- **Sponsor research:** Locate trials associated with specific organizations and track lead sponsors.
- **Site & contact discovery:** Access detailed facility locations and contact information embedded within trial protocols.
- **Targeted lookups:** Load complete study records in detail mode using known NCT IDs.
- **Automated archiving:** Set up recurring runs to maintain fresh recruitment datasets over time.

### Extracted Data Points

Each record captures essential trial metadata:

- Unique NCT study ID and brief title
- Overall study status (e.g., Recruiting, Completed)
- Lead sponsor name and organizational classification
- Complete protocol details, including site locations and contacts
- Results availability indicators

### Input Parameters

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | String | `search` | Operation mode (`search` to filter studies, `details` to load records by NCT ID). |
| `condition` | String | `diabetes` | Medical condition or disease search query. |
| `intervention` | String | empty | Treatment or intervention search term. |
| `sponsor` | String | empty | Sponsor name filter. |
| `status` | Array | `["RECRUITING"]` | Overall study status filter. |
| `nctIds` | Array | `NCT03162237` | List of NCT IDs for details mode (one per line). |
| `maxItems` | Integer | `100` | Maximum number of rows to retrieve (up to 1,000). |
| `pageSize` | Integer | `100` | Number of studies per results page (up to 1,000). |
| `timeoutSecs` | Integer | `300` | Overall run limit in seconds. |

#### Example Input (Search Mode)

```json
{
    "mode": "search",
    "condition": "diabetes",
    "intervention": "insulin",
    "sponsor": "Novo Nordisk",
    "status": ["RECRUITING"],
    "maxItems": 100,
    "pageSize": 100,
    "timeoutSecs": 300
}

```

#### Example Input (Details Mode)

```json
{
    "mode": "details",
    "nctIds": ["NCT03162237"],
    "maxItems": 10,
    "timeoutSecs": 300
}

```

### Output Format

```json
{
    "nctId": "NCT03162237",
    "briefTitle": "Safety and Efficacy Study of Islets Xenotransplantation",
    "overallStatus": "COMPLETED",
    "leadSponsorName": "Wei Wang,MD",
    "protocolSection": {
        "identificationModule": {
            "nctId": "NCT03162237",
            "briefTitle": "Safety and Efficacy Study of Islets Xenotransplantation"
        },
        "statusModule": {
            "overallStatus": "COMPLETED"
        },
        "sponsorCollaboratorsModule": {
            "leadSponsor": {
                "name": "Wei Wang,MD",
                "class": "OTHER"
            }
        }
    },
    "derivedSection": {},
    "hasResults": false
}

```

### How It Works

1. Configures search criteria or loads specific trial records based on input mode.
2. Retrieves study records iteratively in structured batches, avoiding duplicates.
3. Manages network hiccups with built-in retry mechanisms to ensure stable execution.
4. Records any unresolvable identifiers as clean error entries while continuing through the rest of the dataset.
5. Generates export-ready datasets available in JSON, CSV, or Excel formats.

### Frequently Asked Questions

**How many clinical trials can I export in a single run?**

The default limit is set to 100 rows per run, with a hard cap of 1,000 items.

**What happens if an NCT ID is invalid?**

Invalid or unrecognized identifiers generate an error entry explaining the issue, allowing the rest of your list to complete successfully.

**Can I export datasets to CSV or Excel?**

Yes. Completed datasets can be downloaded instantly in JSON, CSV, or Excel formats from your run overview.

***

### Legal & Compliance

#### Trademark Notice

ClinicalTrials.gov and related names, logos, and trademarks belong to their respective owners. Their mention in this documentation is strictly to identify compatibility and data utility, and does not imply affiliation, sponsorship, or endorsement.

#### Disclaimer

This tool is an independent utility and is not affiliated with, endorsed by, or officially connected to third-party medical registry providers. Users are responsible for ensuring their usage complies with relevant terms of service, attribution requirements, and local regulations.

#### Is web scraping legal?

This tool collects publicly available clinical trial records without bypassing access controls. Collecting public data is standard practice, but proper compliance requires considering how the data is used:

- **Personal data:** Ensure that dataset usage respects regional privacy regulations such as the GDPR or CCPA when combining outputs with personal user records.
- **Copyright & Terms:** Respect the terms of use, usage limits, and licensing terms set by data sources.
- **Legal advice:** This summary is provided for general informational purposes and does not constitute formal legal counsel.

# Actor input Schema

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

search lists studies that match the filters. details loads one full study record per NCT ID.

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

Condition or disease query sent as query.cond. Used in search mode. Example: diabetes.

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

Drug, device, or other intervention sent as query.intr. Leave blank to skip this filter.

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

Lead sponsor or collaborator name sent as query.spons. Leave blank to skip this filter.

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

Overall status values sent as filter.overallStatus. One value per line. Common values: RECRUITING, NOT_YET_RECRUITING, ACTIVE_NOT_RECRUITING, ENROLLING_BY_INVITATION, COMPLETED, SUSPENDED, TERMINATED, WITHDRAWN. Leave empty to skip the status filter.

## `nctIds` (type: `array`):

NCT IDs to load in details mode, one per line. Example: NCT03162237. Ignored in search mode.

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

Maximum study rows to save this run. Values above 1000 are clamped to 1000.

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

Studies requested per search page. The public API allows at most 1000. The run stops early once maxItems is reached.

## `timeoutSecs` (type: `integer`):

Soft limit for the whole run, in seconds. The actor stops fetching when this time is reached and keeps rows already saved.

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

Timeout for a single HTTP request, in seconds.

## `proxyConfiguration` (type: `object`):

Optional proxy for requests. Leave Apify Proxy off. The public studies API does not require a proxy, and a proxy must not be used to get around source limits.

## Actor input object example

```json
{
  "mode": "search",
  "condition": "diabetes",
  "intervention": "insulin",
  "sponsor": "Novo Nordisk",
  "status": [
    "RECRUITING"
  ],
  "nctIds": [
    "NCT03162237"
  ],
  "maxItems": 100,
  "pageSize": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Dataset items as JSON.

## `overview` (type: `string`):

Dataset items for the overview table.

# 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 = {
    "mode": "search",
    "condition": "diabetes",
    "intervention": "",
    "sponsor": "",
    "status": [
        "RECRUITING"
    ],
    "nctIds": [
        "NCT03162237"
    ],
    "maxItems": 100,
    "pageSize": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("kawsar/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 = {
    "mode": "search",
    "condition": "diabetes",
    "intervention": "",
    "sponsor": "",
    "status": ["RECRUITING"],
    "nctIds": ["NCT03162237"],
    "maxItems": 100,
    "pageSize": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("kawsar/clinicaltrials-gov-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 '{
  "mode": "search",
  "condition": "diabetes",
  "intervention": "",
  "sponsor": "",
  "status": [
    "RECRUITING"
  ],
  "nctIds": [
    "NCT03162237"
  ],
  "maxItems": 100,
  "pageSize": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call kawsar/clinicaltrials-gov-scraper --silent --output-dataset

```

## MCP server setup

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