New report: The state of agentic finance 2026
Valyu
An NIAID clinical-trial volunteer signs an informed-consent form while a staff member points to the study paperwork.
Tutorial

How to Find Recruiting Clinical Trials from ClinicalTrials.gov via API

Prosper
Share this article

Quick Answer

To find recruiting clinical trials from ClinicalTrials.gov, search Valyu with the condition and recruitment goal, targeting valyu/valyu-clinical-trials.

Describe the studies in plain language. With Valyu, an agent can ask for “recruiting interventional clinical trials for melanoma” directly. Humans can write the same request. ClinicalTrials.gov remains the data source; Valyu handles retrieval from the question rather than requiring a registry-specific search expression.

The extra work with the native ClinicalTrials.gov API appears in more complex searches: people and agents must turn a research question into Boolean and field-specific query syntax, for example (cancer OR carcinoma OR neoplasm) in query.cond, plus separate filters for recruitment status and study type. Valyu lets the question stay in plain language. The application then checks the actual fields in the returned records.

Parse the returned records and keep only those with overall_status: "RECRUITING".

ClinicalTrials.gov is the original data source; this tutorial calls the Valyu API rather than the official ClinicalTrials.gov API.

JSON
{
"query": "Recruiting interventional clinical trials for melanoma",
"included_sources": [
"valyu/valyu-clinical-trials"
],
"max_num_results": 5
}

The task is a linked shortlist of recruiting interventional studies for melanoma. Each row keeps the NCT identifier, study title, phase, registry update date and source URL.

If you're an agent: Set up Valyu and make your first search.

If you're a human: Create an account and get an API key.

MCP onboarding: Connect your agent to https://mcp.valyu.ai/mcp and follow the MCP setup guide for authentication.

Why use Valyu instead of calling the ClinicalTrials.gov API directly?

The advantage for both humans and agents is simpler query construction: describe the studies in plain language instead of assembling Boolean operators, field names and separate filter parameters for each research question. The same Valyu Search API can also retrieve supporting PubMed literature, so an agent can move from trial discovery to the evidence behind an intervention.

The official ClinicalTrials.gov API is a public REST API. A direct implementation uses parameters such as query.cond and filter.overallStatus, reads the nested study response, and follows nextPageToken when more results are available. Valyu returns relevant records through its own search interface; it is not a drop-in proxy for those official endpoints.

ClinicalTrials.gov also supports simple condition searches and automatic synonym expansion; manual Boolean expressions are not necessary for every request. Its API v2 reference documents the structured parameters, while its complex-query guide explains AND, OR and NOT. Valyu’s benefit here is keeping a more complex research request in natural language, not replacing the registry’s exact filters or exhaustive exports.

Retrieval taskValyu Search APIOfficial ClinicalTrials.gov API
Describe the research questionNatural-language query plus a dataset identifierCondition fields, Boolean expressions for complex searches, and separate filters
Read recruitment statusParse overall_status in returned trial contentRead protocolSection.statusModule.overallStatus
Find supporting literatureUse the same Search API with the PubMed datasetIntegrate a separate literature source
Export all registry matchesRanked results form a shortlist, not a complete exportUse exact filters and pagination to enumerate matches
AccessValyu API key with clinical-trials dataset accessPublic registry API; no Valyu account required

For an agent answering a focused research question, natural-language retrieval removes provider-specific query-building work. For a complete registry export or exact field-level enumeration, the official API is the better fit. Neither approach removes the need to check the study record before using a recruitment claim.

Figure 1. ClinicalTrials.gov supplies the registry data. Valyu retrieves trial records. Application code checks the requested condition, study type and recruitment status before returning a shortlist.

Which Valyu source contains ClinicalTrials.gov records?

Valyu’s healthcare guide documents this source, and the Datasources API identifies ClinicalTrials.gov as its origin.

In the tested response, each result had source: "valyu/valyu-clinical-trials", data_type: "structured", a registry URL and a JSON-encoded string in content.

The SDK examples parse that content; they also accept an already-decoded object. The trial fields below were present in the observed records.

Trial fieldWhat to retain
nct_idThe stable registry identifier used to deduplicate records
brief_titleThe study’s brief title
overall_statusThe exact study-level recruitment status
study_typeWhether the study is INTERVENTIONAL or another type
conditionsThe conditions listed in the returned record
phasesThe phase or phases, where applicable
last_update_postedThe date the registry update was posted
locationsSite details, including a site-level status when provided

Use result.url as the source link. last_update_posted is the registry record’s update date, not the time of the Valyu request. The examples add an application-generated retrieved_at timestamp so those two dates remain separate.

Retrieve recruiting clinical trials via Valyu SDK

Choose either SDK. Set VALYU_API_KEY on the server before running the file.

Run Python with python search_trials.py; run TypeScript with pnpm dlx tsx search_trials.ts.

Both examples make one Valyu search, parse the returned content, and check the recruiting status, interventional study type and melanoma condition. They verify that the NCT identifier matches the registry link and deduplicate by that identifier.

import json
import re
from datetime import datetime, timezone
from urllib.parse import urlparse
 
from valyu import Valyu
 
SOURCE = "valyu/valyu-clinical-trials"
response = Valyu().search(
"Recruiting interventional clinical trials for melanoma",
included_sources=[SOURCE],
max_num_results=5,
)
if not response.success:
raise RuntimeError("Clinical trial search failed; check dataset access")
 
retrieved_at = datetime.now(timezone.utc).isoformat()
trials = {}
for result in response.results:
if result.source != SOURCE:
continue
try:
record = json.loads(result.content) if isinstance(result.content, str) else result.content
except (TypeError, json.JSONDecodeError):
continue
if not isinstance(record, dict):
continue
nct_id = record.get("nct_id", "")
if not isinstance(nct_id, str) or not re.fullmatch(r"NCT\d{8}", nct_id):
continue
try:
url = urlparse(result.url)
except ValueError:
continue
if url.hostname != "clinicaltrials.gov" or url.path != f"/study/{nct_id}":
continue
if record.get("overall_status") != "RECRUITING":
continue
if record.get("study_type") != "INTERVENTIONAL":
continue
conditions = record.get("conditions")
if not isinstance(conditions, str) or "melanoma" not in conditions.lower():
continue
trials[nct_id] = {
"nct_id": nct_id,
"title": record.get("brief_title"),
"status": record["overall_status"],
"phases": record.get("phases"),
"last_update_posted": record.get("last_update_posted"),
"source_url": result.url,
"retrieved_at": retrieved_at,
}
 
print(json.dumps(list(trials.values()), indent=2))

The condition check is deliberately scoped to this example: the returned conditions text must contain “melanoma”. For another condition, change both the query and that check. Complex synonyms, disease subtypes or eligibility rules need more specific validation than a substring match.

What did the tested recruiting-trials query return?

Today (October 8 , 2026), the examples returned these interventional records with overall_status: "RECRUITING".

The study-level status and last-update date were also cross-checked against the original registry records.

This is a dated retrieval example; later runs can return different records or statuses.

ClinicalTrials.gov recordPhase in returned contentLast update posted
Phase 1 / Phase 22026-08-20
Phase 12026-04-20
Phase 12026-02-13
Phase 22026-01-05
Phase 32026-07-15

One returned row looked like this. The fields form the application’s shortlist format, not the complete Valyu response:

JSON
{
"nct_id": "NCT04903119",
"title": "Nilotinib Plus Dabrafenib/Trametinib or Encorafenib/Binimetinib in Metastatic Melanoma",
"status": "RECRUITING",
"phases": "PHASE1",
"last_update_posted": "2026-02-13",
"source_url": "https://clinicaltrials.gov/study/NCT04903119",
"retrieved_at": "2026-10-08T13:47:41.438261+00:00"
}

A ranked search is not a census of every recruiting melanoma trial. max_num_results: 5 requests up to five results before the application checks. Fewer than five rows can survive the checks, and an empty output does not establish that no recruiting studies exist.

How do you check whether a clinical trial is recruiting?

Check the exact overall_status field in the returned record. Searching for the word “recruiting” alone is insufficient: a record may mention previous recruitment, planned recruitment, or a site that has a different status from the overall study.

StatusMeaning for this task
RECRUITINGKeep: the study is accepting participants
ACTIVE_NOT_RECRUITINGExclude: the study continues but is not accepting new participants
NOT_YET_RECRUITINGExclude: the study has not started accepting participants

Figure 2. Keep the exact RECRUITING status for a recruiting-only shortlist. Active and planned studies answer different questions. Overall study status and individual-site status must be checked separately.

For a location-specific task, inspect the matching item in locations, including its country, facility and status. A study can be recruiting overall while one site is not yet recruiting or has stopped recruiting. Also read the eligibility criteria and current source record before treating a study as a candidate for a particular participant.

How to adapt the search to another clinical-trial task

Keep the condition and recruitment goal explicit, then add the phase, intervention or location that matters. These are query patterns to adapt, not additional tested results:

  • A different condition: “Recruiting interventional clinical trials for heart failure”. Change the application’s condition check as well.
  • A phase requirement: “Recruiting phase 3 clinical trials for melanoma”. Check that phases actually includes PHASE3.
  • A location requirement: “Recruiting melanoma clinical trials with study sites in the United Kingdom”. Check the matching site’s country and recruitment status.
  • A known study: Include its NCT identifier in the query, then confirm that the returned nct_id matches.

A natural-language constraint guides retrieval; it is not an exact registry filter. Enforce any required phase, location, status or identifier against the returned fields. Keep the source link and update date with the resulting shortlist.


What agents can you build with these trial records?

The same retrieval pattern can power focused research agents:

  • Trial-scouting agent. Turn a plain-language research brief into a shortlist by condition, phase or intervention. Keep the NCT ID, recruitment status, update date and registry link attached to each candidate.
  • Research-landscape agent. Compare the sponsors, phases and interventions in retrieved studies, then retrieve supporting PubMed literature through Valyu. Present a source-linked view of the retrieved trials rather than claiming complete registry coverage.
  • Trial-monitoring agent. Periodically retrieve saved NCT identifiers, compare the returned records with stored snapshots, and flag changes in recruitment status, locations or posted update dates. Link each alert to the original registry record.

Valyu supplies the retrieval layer. Scheduling, snapshot storage, comparison logic and alerts are built in the application. Each agent should check the returned fields and retain the source links, as the examples do.

FAQ

Does this tutorial call the ClinicalTrials.gov API directly?

No. The executable examples call the Valyu Search API and target valyu/valyu-clinical-trials. ClinicalTrials.gov is the original data source, and returned records link back to the registry. The official API is described for comparison.

Why is Valyu easier for retrieving clinical trials?

Valyu accepts a natural-language research question and a dataset identifier. That reduces the query-building work needed to retrieve relevant candidates, and supporting literature can use the same Search API. The application still parses the records and verifies the required status and other constraints.

Do I need a ClinicalTrials.gov API key?

The examples need a Valyu API key with clinical-trials dataset access. They do not require a separate ClinicalTrials.gov API key. The official ClinicalTrials.gov API is public.

Can I get every recruiting study for a condition?

The demonstrated Valyu request returns a ranked shortlist, not every registry match. Use the official ClinicalTrials.gov API with exact filters and pagination when the requirement is an exhaustive registry export.

Does RECRUITING mean every trial site is open?

No. Overall study status and individual-site status are separate fields. Check the relevant location entry and the current registry record before describing a particular site as recruiting.

How current are the returned recruitment statuses?

Retain last_update_posted from the record and add the request time separately. The example’s status and update date were checked against the original registry on 8 October 2026. That verification does not guarantee that a later response or cached record remains current.

What if the trial search fails or returns no rows?

Check that the key has clinical-trials dataset access and that the request succeeds. Distinguish an access error from an empty search. If results exist but none pass the application checks, review the condition and returned fields rather than treating that as proof that no studies exist.

Related retrieval tasks

For supporting literature, see How to Integrate Research Papers into Your AI Agents. For broader trial-data integration, see the ClinicalTrials.gov integration guide.

Give your agents access to Valyu, enable the dataset access needed, and retrieve a source-linked clinical-trial shortlist.




Valyu Add

Join 12,000+ professionals and knowledge workers.

Valyu Add is a free weekly research briefing for builders, investors and operators. Every issue is sourced, cited and verified with Valyu DeepResearch.