# ClinicalTrials.gov Search (Official API) (`kdhan/clinicaltrials-gov-search`) Actor

Search and export clinical trials from the official ClinicalTrials.gov API v2. No API key needed. Public domain U.S. government data. Filter by condition, intervention, sponsor, location, status, and phase.

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

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 Search (Official API)

Search and export clinical trials from **ClinicalTrials.gov**, the U.S. government registry of
clinical studies. This Actor uses the **official API v2** — no scraping, no API key.

### Why this Actor

- **Official API only.** Calls `https://clinicaltrials.gov/api/v2/studies`. No page scraping.
- **No API key required.** Verified 2026-09-27: the endpoint returns HTTP 200 without any credentials.
- **Public domain data.** ClinicalTrials.gov is operated by the U.S. National Library of Medicine.
- **Flat output.** The API returns deeply nested JSON; this Actor flattens it into one row per study.
- **Polite.** Requests are paced (default 5/second) and retried with backoff on 429/5xx.

### What you get

One row per study:

| Field | Description |
|---|---|
| `nctId` | Registry identifier, e.g. `NCT00690963` |
| `url` | Link to the study page |
| `briefTitle` / `officialTitle` | Study titles |
| `overallStatus` | `RECRUITING`, `COMPLETED`, `TERMINATED`, … |
| `studyType` | `INTERVENTIONAL`, `OBSERVATIONAL`, `EXPANDED_ACCESS` |
| `phases` | e.g. `["PHASE1","PHASE2"]` |
| `enrollmentCount` | Target or actual enrollment |
| `conditions` | Conditions studied |
| `leadSponsor` | Lead sponsor name |
| `startDate` / `primaryCompletionDate` / `completionDate` | Key dates |
| `lastUpdatePostDate` | When the record was last updated |
| `countries` | Distinct countries across all study locations |
| `locationCount` | Number of study locations |
| `interventions` | Intervention names |

### Input

All fields are optional — combine what you need.

| Input | Maps to | Example |
|---|---|---|
| `searchTerm` | `query.term` | `lung cancer` |
| `condition` | `query.cond` | `breast cancer` |
| `intervention` | `query.intr` | `pembrolizumab` |
| `sponsor` | `query.spons` | `Pfizer` |
| `location` | `query.locn` | `Korea` |
| `statuses` | `filter.overallStatus` | `["RECRUITING"]` |
| `phases` | advanced filter | `["PHASE2","PHASE3"]` |
| `studyType` | advanced filter | `INTERVENTIONAL` |
| `maxResults` | — | `100` |

### Pricing

Pay per event: **one charge per returned study** (`result-item`). Nothing is charged for
studies you do not receive. The Actor also checks your run budget before starting and
reduces the result count to fit, instead of stopping partway.

### Use cases

- **Pharma — competitor pipeline monitoring.** Track competitor trial activity, study phases
  and endpoints across a therapeutic area.
- **Biotech — protocol planning and feasibility.** Benchmark active study designs, enrollment
  targets and comparator interventions.
- **Investment — clinical catalysts and due diligence.** Watch milestone dates, completion
  timelines and recruitment status changes for portfolio or target companies.
- **Academic research — evidence synthesis.** Pull registry records, geographic distribution
  and historical studies for systematic reviews.
- **Regulatory and market intelligence — landscape mapping.** Analyze global trial footprints,
  sponsor types and progression across indications.

### What makes this different

1. **Official API, not scraping.** Queries the ClinicalTrials.gov REST API v2 directly, so it
   does not break when the website layout changes, and there is no terms-of-service gray area.
2. **No credentials.** Public-domain government data, no API key, no account approval.
3. **Flat, ready-to-use output.** Deeply nested government JSON becomes clean rows you can open
   in Excel or feed straight into a pipeline.

### Running locally

```bash
pip install -r requirements.txt

## Verify the client against the live API (no key, no Apify account needed)
python -m tests.test_ctgov

## Run the Actor locally with charging in test mode (nothing is billed)
ACTOR_TEST_PAY_PER_EVENT=true python -m src.main
```

### Layout

```
src/ctgov.py   API client + flattening. Pure Python, testable on its own.
src/main.py    Apify wiring only (input, dataset, charging).
tests/         Live checks against the real API.
```

### Data source and attribution

Data comes from ClinicalTrials.gov, a service of the U.S. National Library of Medicine.
This Actor is not affiliated with or endorsed by the NIH, NLM, or ClinicalTrials.gov.
Study records are provided by study sponsors and investigators; ClinicalTrials.gov does not
verify their scientific validity. Always confirm details against the study record itself.

### What this Actor does not do

- It does not scrape web pages.
- It does not provide medical advice or interpret study results.
- It does not store or resell data — each run fetches fresh records from the official API.

# Actor input Schema

## `searchTerm` (type: `string`):

Free-text search across the study record (maps to query.term). Example: lung cancer

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

Condition or disease to search for (maps to query.cond). Example: breast cancer

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

Intervention or treatment to search for (maps to query.intr). Example: pembrolizumab

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

Lead sponsor or collaborator name (maps to query.spons). Example: Pfizer

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

Study location, such as a country or city (maps to query.locn). Example: Korea

## `statuses` (type: `array`):

Keep only studies with these statuses. Leave empty for all statuses.

## `phases` (type: `array`):

Keep only studies in these phases. Leave empty for all phases.

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

Keep only this study type. Leave empty for all types.

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

Maximum number of studies to return. You are charged per returned study.

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

How many studies to request per API call. Larger is faster, 1000 is the API maximum.

## `requestsPerSecond` (type: `integer`):

Politeness limit for calls to the public ClinicalTrials.gov API.

## `userAgent` (type: `string`):

Optional contact string sent with each request, as a courtesy to the public API.

## Actor input object example

```json
{
  "searchTerm": "lung cancer",
  "statuses": [],
  "phases": [],
  "maxResults": 100,
  "pageSize": 100,
  "requestsPerSecond": 5
}
```

# Actor output Schema

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

All matching studies, one row each: NCT id, titles, status, phase, sponsor, conditions, countries, interventions, enrollment and key dates.

# 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 = {
    "searchTerm": "lung cancer"
};

// Run the Actor and wait for it to finish
const run = await client.actor("kdhan/clinicaltrials-gov-search").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 = { "searchTerm": "lung cancer" }

# Run the Actor and wait for it to finish
run = client.actor("kdhan/clinicaltrials-gov-search").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 '{
  "searchTerm": "lung cancer"
}' |
apify call kdhan/clinicaltrials-gov-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kdhan/clinicaltrials-gov-search"
        }
    }
}
```

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/wQgwXLmnVJWCB1ue9/builds/2yyeehkeQCXf8cT8U/openapi.json
