File size: 447 Bytes
c09fa6f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import httpx, asyncio, datetime
_BASE = "https://clinicaltrials.gov/api/v2/studies"
async def search_trials(query: str, max_n: int = 20) -> list[dict]:
async with httpx.AsyncClient(timeout=15) as cli:
r = await cli.get(_BASE, params={
"query": query,
"pageSize": max_n,
"fields": "nctId,briefTitle,phase,status,startDate"
})
r.raise_for_status()
return r.json().get("studies", [])
|