# ClinicalTrials.gov Protocol Change Monitor (`changewire/clinicaltrials-protocol-diff`) Actor

Purpose-built diff stream for ClinicalTrials.gov v2 — per-NCT status / enrollment / endpoint / sponsor / eligibility / locations changes as JSONL. Replaces Evaluate Pharma + Citeline + general-purpose scrapers like Browse AI for pharma BI, drug-discovery AI agents, biotech reporters. Public runs.

- **URL**: https://apify.com/changewire/clinicaltrials-protocol-diff.md
- **Developed by:** [ChangeWire](https://apify.com/changewire) (community)
- **Categories:** AI, Agents
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN 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/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## actor-1-clinicaltrials-protocol-diff

Apify actor that monitors **ClinicalTrials.gov** protocol-change
events (status updates, enrollment milestones, primary-endpoint
edits, sponsor changes) and emits per-NCT-ID JSONL diff records.

### Who this is for

- **Pharma competitive-intel** analysts at small BI shops
  (buy substitute: Evaluate Pharma $35k/yr, Citeline $50k+/yr,
  Informa BDCI).
- **AI-agent builders** embedding drug-discovery workflows who
  need structured protocol-change streams.
- **Medical journalists** at STAT / Endpoints / FiercePharma
  tracking trial-design changes.

### What it does

1. Accepts a watchlist config (sponsor / indication / phase / NCT
   ID list).
2. Fetches current studies via ClinicalTrials.gov REST API v2.
3. Diffs against the previous snapshot in Apify Dataset
   (`.actor/input_schema.json` picks the key-value store).
4. Emits one dataset record per detected change with:
   - `nct_id`
   - `change_type` (status / enrollment / endpoint / sponsor /
     eligibility / locations)
   - `before` / `after` values
   - `detected_at` timestamp
   - standard `BaseRecord` fields (actor, schema_version,
     extracted_at, source_url)

### Pricing (Apify Store)

Pay-per-result (PPR):
- $0.02 per new diff record emitted.
- Typical buyer: watchlist of ~500 studies, weekly cron → ~50-200
  changes/week → ~$1-4/week Apify charge → $4-16/month.
- Mid-market buyer: watchlist of 5000 studies, daily cron →
  ~100-500 changes/day → $2-10/day → $60-300/month.


### Inputs (see `.actor/input_schema.json`)

| Field | Type | Default | Description |
|---|---|---|---|
| `watchlist` | array of NCT IDs | `[]` | Explicit study list |
| `sponsors` | array of strings | `[]` | Filter by sponsor name (partial match) |
| `conditions` | array of strings | `[]` | MeSH condition terms |
| `phases` | array of strings | `[]` | e.g. `["Phase 2", "Phase 3"]` |
| `statuses` | array of strings | `[]` | e.g. `["Recruiting", "Active, not recruiting"]` |
| `change_types` | array of strings | all six | Which diff types to emit |
| `snapshot_key` | string | auto | Key-value store key for previous snapshot |
| `max_studies` | int | 10000 | Hard cap for cost ceiling |

### Output

JSONL dataset; one record per detected change. Example::

    {
      "actor": "actor-1-clinicaltrials-protocol-diff",
      "schema_version": "1.0.0",
      "extracted_at": "2026-05-11T18:00:00Z",
      "source_url": "https://clinicaltrials.gov/study/NCT01234567",
      "nct_id": "NCT01234567",
      "change_type": "status",
      "before": {"overall_status": "Not yet recruiting"},
      "after":  {"overall_status": "Recruiting"},
      "detected_at": "2026-05-11T18:00:00Z"
    }

### Running locally

```bash
## from repo root after `pip install -e .[dev]`:
cd actors/actor-1-clinicaltrials-protocol-diff
apify run --purge  ## uses .actor/input_schema.json defaults
````

For a targeted run, pass explicit input::

```
apify run --input '{"watchlist": ["NCT01234567"]}'
```

### Known gotchas

- CT.gov v2 API returns `null` for many optional fields where v1
  returned empty strings. `extract.py` normalises both to `None`.
- `conditions` input uses **partial-match on normalized MeSH
  term** — "Alzheimer" will match "Alzheimer Disease" and
  "Alzheimer's Disease". Buyers sometimes assume exact-match;
  README + listing must be explicit.
- Studies in `"Withdrawn"` status are frequently re-activated.
  Treat status transitions as bidirectional, NOT a one-way flow.

### Store listing (draft — edit before publish)

#### Title

ClinicalTrials.gov Protocol Change Monitor

#### Tagline

Daily diff of NIH-registered trial protocols. Drop Evaluate
Pharma and Citeline — get the same change stream for 1/100th the
cost.

#### Features

- ✅ Full ClinicalTrials.gov REST API v2 coverage (500k+ studies)
- ✅ Six change types (status, enrollment, endpoint, sponsor,
  eligibility, locations)
- ✅ Watchlist OR sponsor OR condition OR phase filters
- ✅ JSONL dataset output, ready for your BI pipeline
- ✅ Incremental: first run snapshots, later runs diff

#### Example use cases

1. **Competitive intel:** Track all Phase 2/3 trials by Roche /
   AstraZeneca / Novartis for oncology. Alert on enrollment
   changes.
2. **Indication tracking:** Monitor every NCT study in
   Alzheimer's disease — know when any trial changes primary
   endpoints.
3. **Drug-discovery AI agent:** Feed change events into your
   agent's context as a retrieval-augmented fact stream.

#### Legal

ClinicalTrials.gov data is US government public-domain
(42 USC §282(j)). Actor respects CT.gov rate limits (2 rps
default). No PII in output.

# Actor input Schema

## `watchlist` (type: `array`):

Explicit list of NCT IDs to monitor (e.g. NCT01234567). If empty, use filters below.

## `sponsors` (type: `array`):

Partial-match filter on sponsor name

## `conditions` (type: `array`):

Partial-match filter on MeSH condition terms

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

Phase 1 / Phase 2 / Phase 3 / Phase 4 / Not Applicable / Early Phase 1

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

e.g. Recruiting, Active, not recruiting, Completed

## `change_types` (type: `array`):

Subset of: status, enrollment, endpoint, sponsor, eligibility, locations

## `snapshot_key` (type: `string`):

Key-value store key holding the previous snapshot. Default: 'snapshot-latest'.

## `max_studies` (type: `integer`):

Hard cap on studies fetched per run (cost ceiling)

## `rate_limit_rps` (type: `integer`):

CT.gov soft-caps at ~3 rps. Do not raise.

## Actor input object example

```json
{
  "watchlist": [],
  "sponsors": [],
  "conditions": [],
  "phases": [],
  "statuses": [],
  "change_types": [
    "status",
    "enrollment",
    "endpoint",
    "sponsor",
    "eligibility",
    "locations"
  ],
  "snapshot_key": "snapshot-latest",
  "max_studies": 10000,
  "rate_limit_rps": 2
}
```

# 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("changewire/clinicaltrials-protocol-diff").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("changewire/clinicaltrials-protocol-diff").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 '{}' |
apify call changewire/clinicaltrials-protocol-diff --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=changewire/clinicaltrials-protocol-diff",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "ClinicalTrials.gov Protocol Change Monitor",
        "description": "Purpose-built diff stream for ClinicalTrials.gov v2 — per-NCT status / enrollment / endpoint / sponsor / eligibility / locations changes as JSONL. Replaces Evaluate Pharma + Citeline + general-purpose scrapers like Browse AI for pharma BI, drug-discovery AI agents, biotech reporters. Public runs.",
        "version": "0.1",
        "x-build-id": "6up0ZbkahSNlCfDBD"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/changewire~clinicaltrials-protocol-diff/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-changewire-clinicaltrials-protocol-diff",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/changewire~clinicaltrials-protocol-diff/runs": {
            "post": {
                "operationId": "runs-sync-changewire-clinicaltrials-protocol-diff",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/changewire~clinicaltrials-protocol-diff/run-sync": {
            "post": {
                "operationId": "run-sync-changewire-clinicaltrials-protocol-diff",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "watchlist": {
                        "title": "Watchlist (NCT IDs)",
                        "type": "array",
                        "description": "Explicit list of NCT IDs to monitor (e.g. NCT01234567). If empty, use filters below.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "sponsors": {
                        "title": "Sponsors",
                        "type": "array",
                        "description": "Partial-match filter on sponsor name",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "conditions": {
                        "title": "Conditions",
                        "type": "array",
                        "description": "Partial-match filter on MeSH condition terms",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "phases": {
                        "title": "Phases",
                        "type": "array",
                        "description": "Phase 1 / Phase 2 / Phase 3 / Phase 4 / Not Applicable / Early Phase 1",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "statuses": {
                        "title": "Overall statuses",
                        "type": "array",
                        "description": "e.g. Recruiting, Active, not recruiting, Completed",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "change_types": {
                        "title": "Change types to emit",
                        "type": "array",
                        "description": "Subset of: status, enrollment, endpoint, sponsor, eligibility, locations",
                        "default": [
                            "status",
                            "enrollment",
                            "endpoint",
                            "sponsor",
                            "eligibility",
                            "locations"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "snapshot_key": {
                        "title": "Snapshot key",
                        "type": "string",
                        "description": "Key-value store key holding the previous snapshot. Default: 'snapshot-latest'.",
                        "default": "snapshot-latest"
                    },
                    "max_studies": {
                        "title": "Max studies per run",
                        "minimum": 1,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "Hard cap on studies fetched per run (cost ceiling)",
                        "default": 10000
                    },
                    "rate_limit_rps": {
                        "title": "API rate limit (requests per second)",
                        "minimum": 1,
                        "maximum": 5,
                        "type": "integer",
                        "description": "CT.gov soft-caps at ~3 rps. Do not raise.",
                        "default": 2
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
