# ClinicalTrials.gov Scraper — Pharma Trials & Sponsors API (`perceptive_city_af7/clinical-trials-scraper`) Actor

Official ClinicalTrials.gov v2 API scraper extracting recruiting studies, Phase 1-4 drug pipelines, sponsors, conditions, enrollment & NCT IDs. Clean JSON for biotech intelligence & AI agents. No API key.

- **URL**: https://apify.com/perceptive_city_af7/clinical-trials-scraper.md
- **Developed by:** [fall Rainy](https://apify.com/perceptive_city_af7) (community)
- **Categories:** AI, Automation, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.50 / 1,000 clinical trial records

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 — Pharma Trials & Sponsors API

> **Free Integration Kits:** Download ready-to-use Google Sheets, Excel Power Query, Postman/Bruno, n8n CSV workflows, Python/JS SDKs & MCP configs in [Open Data Kits](https://github.com/Rainy-fall-end/open-data-kits) · Prefer a direct REST API? [Try ClinicalTrials.gov API on RapidAPI](https://rapidapi.com/fallRainy/api/clinicaltrials-gov-studies-trials) · Need 4-source cross-linked drug intelligence (ClinicalTrials + openFDA + ChEMBL + Europe PMC)? Check our **Pharma and Biotech Pipeline Intelligence** Actor!

Extract structured clinical study records from **ClinicalTrials.gov** — the world's largest registry of clinical trials — using the official **REST API v2** (`https://clinicaltrials.gov/api/v2/studies`). No browser, no Playwright, no proxies required.

***

### Overview

This Actor talks directly to the ClinicalTrials.gov REST API v2 and normalizes each study into a flat, 17-field record that is ready for analytics, enrichment, or retrieval-augmented generation (RAG) pipelines.

- **Zero-Playwright, direct REST API v2 extraction** — every run is a handful of plain HTTPS calls to `https://clinicaltrials.gov/api/v2/studies`. No headless browser, no DOM parsing, no fingerprinting risk.
- **Fast** — typical runs finish in **sub-second to a few seconds**, even when paging through results. Compute cost is negligible; you pay for the records you keep.
- **Zero PII** — the dataset contains **institutional study metadata only** (titles, sponsors, phases, conditions, countries, dates). No patient-level data, no investigator contact details, no personal information of any kind.
- **US Government Public Domain** — ClinicalTrials.gov content is published by the U.S. National Library of Medicine (NIH) and is in the **public domain**. Reuse it freely in commercial and non-commercial products.
- **Normalized output** — raw API responses are flattened into a stable, typed schema (`nctId`, `phases`, `enrollmentCount`, …) so downstream code never has to walk nested protocol modules.

***

### Input Parameters

All parameters are optional; an empty input returns the 10 most recently updated studies.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `condition` | string | — | Disease / condition search term (疾病 / 适应症关键词). Maps to the API `query.cond` field. Example: `"type 2 diabetes"` |
| `intervention` | string | — | Drug, device, biologic or procedure name (干预措施关键词). Maps to `query.intr`. Example: `"semaglutide"` |
| `status` | string | — | Overall recruitment status (招募状态). Accepts a single status enum string or empty `""` for any status (NOT comma-separated): `RECRUITING`, `NOT_YET_RECRUITING`, `ACTIVE_NOT_RECRUITING`, `COMPLETED`, `ENROLLING_BY_INVITATION`, `SUSPENDED`, `TERMINATED`, `WITHDRAWN`, `UNKNOWN`. Example: `"RECRUITING"` |
| `sponsor` | string | — | Lead sponsor / institution name (申办方 / 机构名称). Maps to `query.spons`. Example: `"Novo Nordisk"` |
| `queryTerm` | string | — | Free-text search across the whole study record (全文关键词检索). Maps to `query.term`. Example: `"GLP-1"` |
| `maxItems` | integer | `10` | Maximum number of study records to save to the dataset (最大抓取条数). Integer range `1` to `5000`. |

#### Example input

```json
{
  "condition": "type 2 diabetes",
  "intervention": "semaglutide",
  "status": "RECRUITING",
  "sponsor": "Novo Nordisk",
  "queryTerm": "GLP-1",
  "maxItems": 25
}
```

***

### Output

Each run saves one dataset item per study, flattened into the following 17 normalized fields:

| Field | Type | Description |
|---|---|---|
| `nctId` | string | Unique ClinicalTrials.gov identifier (NCT 编号), e.g. `NCT05912345` |
| `briefTitle` | string | Short public title (简短标题) |
| `officialTitle` | string | null | Full official study title (正式标题) |
| `overallStatus` | string | null | Current overall recruitment status (总体招募状态) |
| `phases` | array\[string] | Study phases, e.g. `["PHASE2", "PHASE3"]` (试验分期) |
| `studyType` | string | null | `INTERVENTIONAL`, `OBSERVATIONAL`, or `EXPANDED_ACCESS` (研究类型) |
| `conditions` | array\[string] | Conditions / diseases studied (适应症) |
| `interventions` | array\[string] | Intervention names (干预措施), e.g. `["Semaglutide", "Placebo"]` |
| `sponsorName` | string | null | Lead sponsor name (申办方名称) |
| `sponsorClass` | string | null | Sponsor class, e.g. `INDUSTRY`, `NIH`, `OTHER` (申办方类型) |
| `enrollmentCount` | integer | null | Target or actual enrollment (计划/实际入组人数) |
| `startDate` | string | null | Study start date, `YYYY-MM-DD` (开始日期) |
| `primaryCompletionDate` | string | null | Primary completion date, `YYYY-MM-DD` (主要完成日期) |
| `lastUpdatePostDate` | string | null | Last update post date, `YYYY-MM-DD` (最后更新日期) |
| `locationsCountries` | array\[string] | Unique countries of study sites (试验国家/地区) |
| `studyUrl` | string | Canonical record URL on ClinicalTrials.gov (官方详情页链接) |
| `attribution` | string | Source & license string in the exact format `"Source: ClinicalTrials.gov (U.S. National Library of Medicine, NIH) — US Government Public Domain, accessed YYYY-MM-DD (https://clinicaltrials.gov/study/NCT...)."` |

#### Sample output item

```json
{
  "nctId": "NCT05912345",
  "briefTitle": "A Study of Semaglutide in Adults With Type 2 Diabetes",
  "officialTitle": "A Randomised, Double-blind, Placebo-controlled Trial of Once-weekly Semaglutide in Adults With Type 2 Diabetes Mellitus",
  "overallStatus": "RECRUITING",
  "phases": ["PHASE2", "PHASE3"],
  "studyType": "INTERVENTIONAL",
  "conditions": ["Type 2 Diabetes Mellitus"],
  "interventions": ["Semaglutide", "Placebo"],
  "sponsorName": "Novo Nordisk A/S",
  "sponsorClass": "INDUSTRY",
  "enrollmentCount": 480,
  "startDate": "2024-03-11",
  "primaryCompletionDate": "2026-09-30",
  "lastUpdatePostDate": "2025-01-17",
  "locationsCountries": ["United States", "Denmark", "Japan"],
  "studyUrl": "https://clinicaltrials.gov/study/NCT05912345",
  "attribution": "Source: ClinicalTrials.gov (U.S. National Library of Medicine, NIH) — US Government Public Domain, accessed 2025-01-17 (https://clinicaltrials.gov/study/NCT05912345)."
}
```

***

### Pricing — Pay-per-event (PPE)

This Actor uses Apify's **pay-per-event** model. You are charged only for what the run actually uses — there is no monthly rental.

| Event | Key | Price | Notes |
|---|---|---|---|
| Actor start | `apify-actor-start` | **$0.00005** | Charged once per run; **includes the first 5 seconds of compute** |
| Saved clinical trial record | `apify-default-dataset-item` | **$0.0035** per record | **$3.50 per 1,000 records** — charged per item pushed to the default dataset |

**Cost examples**

- 10 records → `$0.00005 + 10 × $0.0035` = **$0.03505**
- 1,000 records → `$0.00005 + 1,000 × $0.0035` = **$3.50005**
- 10,000 records → **≈ $35.00**

Because extraction is pure REST API (no browser overhead), the compute portion stays inside the free 5 seconds for virtually every run — you essentially pay only for records.

***

### MCP Quick Start

AI agents can call this Actor over the **Apify MCP server** at `https://mcp.apify.com` — no SDK, no custom integration.

#### 1. Connect your client

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com",
      "headers": {
        "Authorization": "Bearer <YOUR_APIFY_API_TOKEN>"
      }
    }
  }
}
```

#### 2. Let the agent invoke the Actor

The agent discovers the `call-actor` tool and passes the Actor ID plus a standard input object:

```json
{
  "actorId": "YOUR_USERNAME/clinical-trials-scraper",
  "input": {
    "condition": "melanoma",
    "status": "RECRUITING",
    "maxItems": 10
  }
}
```

The tool returns the run ID and dataset ID; the agent can then read the normalized records straight from the dataset and cite each `studyUrl`.

**Example prompts**

- "Find recruiting melanoma trials sponsored by Merck and summarize the phases."
- "List the last 20 completed semaglutide studies with enrollment above 100."
- "Which countries host recruiting GLP-1 trials for type 2 diabetes?"

***

### Source & Public Domain Attribution

Data is retrieved live from **ClinicalTrials.gov**, a service of the **U.S. National Library of Medicine (NLM)** at the **National Institutes of Health (NIH)**.

- API endpoint: `https://clinicaltrials.gov/api/v2/studies`
- Content is a work of the **U.S. Federal Government** and is therefore in the **public domain** — no license restrictions on reuse.
- Every output record carries an `attribution` field identifying the source, so downstream consumers retain provenance automatically.
- This Actor is an independent client of the public API and is not endorsed by or affiliated with NLM/NIH.

#### Verify locally

Run the bundled test suite (live API smoke test + unit tests):

```bash
python tests/test_live_and_unit.py
```

Probe the live API from the client module:

```bash
python src/client.py --probe
```

***

### 中文说明

**ClinicalTrials.gov Scraper（美国临床试验数据库）** 直接调用 ClinicalTrials.gov 官方 **REST API v2**（`https://clinicaltrials.gov/api/v2/studies`）抓取临床试验数据，**完全不使用 Playwright 或无头浏览器**，因此运行速度极快，通常在**不到一秒到数秒**内完成；成本极低。

**数据特性**

- **零个人隐私（Zero PII）**：仅包含机构级研究元数据，不包含任何患者、受试者或研究者个人信息。
- **美国政府公有领域数据**：由美国国家医学图书馆（NLM）/ 美国国立卫生研究院（NIH）发布，属 **Public Domain**，可自由商用与二次分发。

**输入参数**：`condition`（适应症）、`intervention`（干预措施）、`status`（招募状态）、`sponsor`（申办方）、`queryTerm`（全文关键词）、`maxItems`（最大条数，默认 `10`）。

**输出字段**：共 17 个标准化字段，包括 `nctId`、`briefTitle`、`officialTitle`、`overallStatus`、`phases`、`studyType`、`conditions`、`interventions`、`sponsorName`、`sponsorClass`、`enrollmentCount`、`startDate`、`primaryCompletionDate`、`lastUpdatePostDate`、`locationsCountries`、`studyUrl`、`attribution`。

**计费（按事件付费 PPE）**

| 事件 | 价格 |
|---|---|
| Actor 启动 `apify-actor-start` | `$0.00005`（含前 5 秒计算资源） |
| 每条保存的试验记录 `apify-default-dataset-item` | `$0.0035` / 条（即 `$3.50` / 1,000 条） |

**智能体调用**：通过 Apify MCP 服务器 `https://mcp.apify.com`，AI Agent 可直接以标准输入 JSON 调用本 Actor，读取数据集并引用 `studyUrl` 溯源。

**本地验证**：`python tests/test_live_and_unit.py` 运行测试，`python src/client.py --probe` 探测实时 API。

# Actor input Schema

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

Medical condition or disease to search for (e.g., diabetes 糖尿病, non-small cell lung cancer 非小细胞肺癌).

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

Intervention or treatment to search for (e.g., pembrolizumab 帕博利珠单抗, metformin 二甲双胍).

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

Filter by overall recruitment status.

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

Lead sponsor or collaborator name to filter by (e.g., Pfizer 辉瑞, National Cancer Institute 美国国家癌症研究所).

## `queryTerm` (type: `string`):

General keyword query across study fields (e.g., immunotherapy 免疫治疗).

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

Maximum number of clinical trial studies to scrape (1-5000).

## Actor input object example

```json
{
  "condition": "",
  "intervention": "",
  "status": "",
  "sponsor": "",
  "queryTerm": "",
  "maxItems": 10
}
```

# Actor output Schema

## `results` (type: `string`):

API endpoint to fetch scraped ClinicalTrials.gov studies as JSON.

# 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("perceptive_city_af7/clinical-trials-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("perceptive_city_af7/clinical-trials-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 '{}' |
apify call perceptive_city_af7/clinical-trials-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,perceptive_city_af7/clinical-trials-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/KchE3qKKrwU0rCe9f/builds/3zcGUzYnTa7zHvFcl/openapi.json
