# Clinical Trials Search (`clinicaltrials.search`)

Search ClinicalTrials.gov studies by condition, intervention, sponsor or keywords with status, phase, type and update filters: status, phases, sponsor, dates and enrollment, most recently updated first.

Docs: https://primaryapi.com/docs/api-reference/clinicaltrials/search

- Endpoint: `POST https://api.primaryapi.com/v1/run/clinicaltrials.search`
- Category: Knowledge & Data · Platform: `clinicaltrials` · Kind: search · Status: live
- Price: 1 credit per call. Every call costs the same, including calls that were retried automatically.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=clinicaltrials.search`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `condition` | string | no |  | max 300 chars | Condition or disease, e.g. "lung cancer" (ClinicalTrials.gov search syntax allowed). |
| `intervention` | string | no |  | max 300 chars | Intervention or treatment, e.g. "pembrolizumab". |
| `sponsor` | string | no |  | max 300 chars | Lead sponsor or collaborator, e.g. "Pfizer". |
| `term` | string | no |  | max 300 chars | Other words anywhere in the record, e.g. a drug code or keyword. |
| `status` | enum[] | no |  | min 1 items; max 14 items | Only these overall statuses, e.g. ["RECRUITING","NOT_YET_RECRUITING"]. |
| `phase` | enum[] | no |  | min 1 items; max 6 items | Only studies in any of these phases, e.g. ["PHASE3"]. |
| `studyType` | enum | no |  | one of: INTERVENTIONAL, OBSERVATIONAL, EXPANDED_ACCESS | Only this study type. |
| `updatedFrom` | string | no |  | pattern: ^\d{4}-(0[1-9]\|1[0-2])-(0[1-9]\|[12]\d\|3[01])$ | Only studies whose latest update was posted on or after this date (YYYY-MM-DD). |
| `sort` | enum | no | "last_updated" | one of: last_updated, first_posted | last_updated (default): most recently updated first; first_posted: newest registrations first (use this to watch for new trials). |
| `limit` | integer | no | 20 | 1–100 | Maximum number of results to return (1-100, default 20). |
| `cursor` | string | no |  |  | Opaque pagination cursor: pass the previous response's nextCursor. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `studies` | object[] | Matching studies, sorted as requested |
| `studies[].nctId` | string | ClinicalTrials.gov identifier, e.g. "NCT04368728" |
| `studies[].title` | string \| null | Brief title |
| `studies[].officialTitle` | string \| null |  |
| `studies[].acronym` | string \| null |  |
| `studies[].status` | string \| null | Overall recruitment status, e.g. RECRUITING, COMPLETED, TERMINATED |
| `studies[].whyStopped` | string \| null | Reason given when a study stopped early |
| `studies[].phases` | string[] | e.g. ["PHASE2","PHASE3"]; empty for observational studies |
| `studies[].studyType` | string \| null | INTERVENTIONAL, OBSERVATIONAL or EXPANDED_ACCESS |
| `studies[].leadSponsor` | string \| null |  |
| `studies[].leadSponsorClass` | string \| null | INDUSTRY, NIH, FED, OTHER_GOV, NETWORK, OTHER … |
| `studies[].collaborators` | string[] |  |
| `studies[].conditions` | string[] |  |
| `studies[].interventions` | object[] |  |
| `studies[].interventions[].type` | string \| null |  |
| `studies[].interventions[].name` | string \| null |  |
| `studies[].enrollment` | integer \| null |  |
| `studies[].enrollmentType` | string \| null | ACTUAL or ESTIMATED |
| `studies[].startDate` | string \| null | YYYY-MM-DD or YYYY-MM as registered |
| `studies[].primaryCompletionDate` | string \| null |  |
| `studies[].completionDate` | string \| null |  |
| `studies[].firstPostedDate` | string \| null | Date the record was first posted |
| `studies[].lastUpdatePostedDate` | string \| null | Date the latest update was posted (the record version) |
| `studies[].resultsFirstPostedDate` | string \| null |  |
| `studies[].hasResults` | boolean \| null |  |
| `studies[].countries` | string[] | Countries with a study location, sorted |
| `studies[].locationCount` | integer | Number of study locations |
| `studies[].url` | string | Study page on clinicaltrials.gov |
| `totalCount` | integer \| null | Studies matching the query (first page only; null after) |
| `nextCursor` | string \| null |  |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

Pagination: pass the previous response’s `nextCursor` as `cursor` to get the next page; `nextCursor: null` means there are no more results.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/clinicaltrials.search" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sponsor":"Pfizer","condition":"lung cancer","status":["RECRUITING"],"limit":5}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "studies": [
        {
          "nctId": "string",
          "title": "string",
          "officialTitle": "string",
          "acronym": "string",
          "status": "string",
          "whyStopped": "string",
          "phases": [
            "string"
          ],
          "studyType": "string",
          "leadSponsor": "string",
          "leadSponsorClass": "string",
          "collaborators": [
            "string"
          ],
          "conditions": [
            "string"
          ],
          "interventions": [
            {
              "type": "string",
              "name": "string"
            }
          ],
          "enrollment": 0,
          "enrollmentType": "string",
          "startDate": "string",
          "primaryCompletionDate": "string",
          "completionDate": "string",
          "firstPostedDate": "string",
          "lastUpdatePostedDate": "string",
          "resultsFirstPostedDate": "string",
          "hasResults": true,
          "countries": [
            "string"
          ],
          "locationCount": 0,
          "url": "https://example.com"
        }
      ],
      "totalCount": 0,
      "nextCursor": null
    }
  },
  "provider": "PrimaryAPI",
  "credits": 1,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
  "nextCursor": null
}
```

## Pricing and reliability

- Usual price: 1 credit per call
- Price ceiling: the usual price, even when a call is retried. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=clinicaltrials.search`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Searches the ClinicalTrials.gov registry. Query fields accept ClinicalTrials.gov search syntax (AND, OR, NOT, quotes). Within a page, ties on the sort date are ordered by NCT id (descending). To watch for new trials of a sponsor, monitor with sort first_posted; to watch status changes of one trial, monitor clinicaltrials.study. Empty results are free.

## Legal

Source: ClinicalTrials.gov, U.S. National Library of Medicine (https://clinicaltrials.gov), as processed by ClinicalTrials.gov on the dates shown in each record (lastUpdatePostedDate); PrimaryAPI reshapes the record (field selection and renaming) and does not change its content. No endorsement by NLM is implied. Not medical advice.

