searching-clinicaltrials
What it does
This skill teaches an agent how to search the U.S. clinical trial registry for studies. It is for people who want trials for a diagnosis or drug, or who need a set of trial records.
When to use it
- ✓When a user wants to find recruiting clinical trials for a specific condition.
- ✓When a user has an NCT number and wants the details of that one study.
- ✓When a team is building trial matching and needs candidate studies before checking eligibility.
Skill link
https://github.com/maziyarpanahi/openmed/blob/master/skills/searching-clinicaltrials/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you find recruiting clinical trials for type 2 diabetes that I can review with my team?”
5 new skills a week. 1 minute to read.
How it works
The agent sends a request to the public ClinicalTrials.gov API with the condition, intervention, and status. It reads the results page by page using a cursor, and no login is needed.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Searching ClinicalTrials.gov (v2 REST API)
Query ClinicalTrials.gov — the U.S. registry of clinical studies — for trials
matching a condition, intervention, and recruitment status. This skill uses the
modern v2 REST API (/api/v2/studies), which returns structured JSON and
paginates with an opaque cursor (pageToken), not page numbers.
The v2 API is fully public: no API key, no registration, no license barrier.
The legacy v1/classic API and the older query_term-style endpoints are
deprecated — do not build on them.
When to use
- OpenMed extracted a diagnosis ("metastatic colorectal cancer") or a drug ("pembrolizumab") and you want open trials for it.
- You are building a patient-to-trial matching feature and need candidate studies
before applying eligibility logic (
parsing-trial-eligibility). - You need a corpus of trial records (eligibility text, outcomes) to feed back
into
openmed.analyze_textfor biomedical NER.
If you already have an NCT number, fetch the single study directly
(/api/v2/studies/NCT01234567) instead of searching.
Quick start (real v2 API call)
Base URL: https://clinicaltrials.gov/api/v2. No auth. JSON by default.
import requests
BASE = "https://clinicaltrials.gov/api/v2"
def search_trials(condition: str, intervention: str | None = None,
status: str = "RECRUITING", page_size: int = 50) -> dict:
"""One page of studies for a condition (+ optional intervention)."""
params = {
"query.cond": condition, # condition / disease search
"filter.overallStatus": status, # comma-separated enum values
"pageSize": min(page_size, 1000), # max 1000; default 10
"countTotal": "true", # include totalCount on first page
"format": "json",
}
if intervention:
params["query.intr"] = intervention # drug / intervention search
r = requests.get(f"{BASE}/studies", params=params, timeout=30)
r.raise_for_status()
return r.json()
data = search_trials("breast cancer", intervention="trastuzumab")
print(data["totalCount"]) # total matches (first page only)
for study in data["studies"]:
ps = study["protocolSection"]
nct = ps["identificationModule"]["nctId"]
title = ps["identificationModule"]["briefTitle"]
print(nct, "-", title)
Equivalent cURL:
curl "https://clinicaltrials.gov/api/v2/studies?query.cond=breast+cancer\
&query.intr=trastuzumab&filter.overallStatus=RECRUITING&pageSize=50&format=json"
Response shape
Top level: studies (array), nextPageToken (present only if more results),
and totalCount (only when countTotal=true, on the first page). Each study is
a protocolSection of typed modules:
| Field path | Meaning |
|---|---|
identificationModule.nctId |
NCT........ study id |
identificationModule.briefTitle |
short title |
statusModule.overallStatus |
RECRUITING, COMPLETED, … |
conditionsModule.conditions |
list of condition strings |
armsInterventionsModule.interventions |
drugs / procedures |
eligibilityModule.eligibilityCriteria |
free-text inclusion/exclusion |
eligibilityModule.sex / minimumAge / maximumAge |
demographic gates |
contactsLocationsModule.locations |
recruiting sites |
Cursor pagination
There are no page numbers. Loop until nextPageToken is absent. The token is
opaque — pass it back verbatim. Do not re-send countTotal after page 1.
def iter_all(condition: str, status: str = "RECRUITING"):
params = {"query.cond": condition, "filter.overallStatus": status,
"pageSize": 1000, "format": "json"}
while True:
r = requests.get(f"{BASE}/studies", params=params, timeout=30)
r.raise_for_status()
page = r.json()
yield from page.get("studies", [])
token = page.get("nextPageToken")
if not token:
break
params["pageToken"] = token # cursor for the next page
Trimming payloads
Default responses are large. Restrict to the fields you need with fields (dotted
paths or module names) to cut bandwidth:
params["fields"] = ("NCTId,BriefTitle,OverallStatus,"
"Condition,EligibilityCriteria")
Workflow
- Build the query from OpenMed facts. Map extracted Disease spans →
query.cond; Pharmaceutical spans →query.intr. Free-text keywords go inquery.term. Combine stat
FAQ
Do I need an API key?
No. The skill says the v2 API is fully public and needs no key or registration.
Which version of the API should be used?
The skill says to use the modern v2 API, and calls the older v1 and classic endpoints deprecated.
How do I get one specific study?
Use its NCT number to fetch that single study directly.
Details
Original description by the author
Searches ClinicalTrials.gov for studies by condition, intervention, and recruitment status using the modern v2 REST API with cursor (pageToken) pagination. Use when the user wants to find trials for a diagnosis or drug, screen patients against open studies, build a trial-matching feature, or pull a trial corpus for analysis. Trigger keywords: clinical trial, ClinicalTrials.gov, NCT number, trial search, recruiting studies, eligibility, query.cond, query.intr, pageToken, v2 API. Pairs adjacent to OpenMed: take Disease/Pharmaceutical entities from openmed.analyze_text and turn them into query.co
repo: maziyarpanahi/openmed
Popularity
- GitHub stars
- 5.8k
- Ranking position
- #14731
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
annotating-variants
5.8kHelps your agent predict what a genetic variant does, convert HGVS names to genome positions and attach population frequencies, using free public annotators.
ask-openmed
5.8kHelps your agent pick the right OpenMed workflow for a clinical text request, starting with a privacy check whenever patient data may be present.
assembling-fhir-bundles
5.8kPackages several FHIR health records into one transaction Bundle ready to send to an EHR, with the internal references linked correctly.
auditing-deid-leakage
5.8kScans de-identified clinical text for leftover identifiers such as SSNs, card numbers, emails and dates, and blocks release if any remain.
Similar skills
tavily
394kHelps your agent search the web with Tavily and pull the text from specific web pages, with options for depth, domains, and dates.
blogwatcher
394kLets your agent follow blogs and RSS or Atom feeds, check them for new articles, and mark the ones you have read.
data-scraper-agent
280kHelps your agent automatically collect data from any public source. It can be scheduled, enrich information, and save results. Useful for monitoring or tracking online data.