A modern, fully-typed Python SDK for the ClinicalTrials.gov API v2.
Project description
pytrials-v2
A modern, fully-typed Python SDK for the ClinicalTrials.gov API v2.
Status: early development. See PROJECT_PLAN.md for the full design and roadmap.
Why
The ClinicalTrials.gov API v2 (JSON, token pagination, OpenAPI 3.0) launched in 2024, and the old XML v1 API was retired. There is still no well-designed Python SDK for v2. pytrials-v2 aims to be the default: Pydantic-modeled, async-capable, with the ergonomic helpers clinical-trial data consumers actually need.
What it offers
- Full Pydantic v2 models for every API response (real autocomplete, no dict-digging)
- A validating QueryBuilder that catches bad status, phase, and sort values before the request
- Async auto-pagination over
pageToken - DataFrame integration that flattens the nested study structure for analysis
- Date normalization across the API's inconsistent formats
- Built-in rate limiting (50 req/min) and retry with backoff
Quickstart (planned API)
from pytrials import ClinicalTrials
ctg = ClinicalTrials()
results = ctg.studies.search(condition="breast cancer", status=["RECRUITING"], phase=["PHASE3"])
study = ctg.studies.get("NCT04852770")
df = ctg.studies.search(condition="diabetes", status=["RECRUITING"]).to_dataframe()
Roadmap
- v0.1.0 Core: client, search/get, core models, error handling, PyPI publish
- v0.2.0 Ergonomics: QueryBuilder, async paginator, stats endpoints, rate limiting
- v0.3.0 Data science: DataFrame integration, docs site, 90%+ coverage
- v1.0.0 Stable: full results-section models, CLI, notebook examples
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytrials_v2-0.1.0.tar.gz.
File metadata
- Download URL: pytrials_v2-0.1.0.tar.gz
- Upload date:
- Size: 56.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4506e3d187281f0a97fea745876988e924382880470dd240958ebddb01b75ce0
|
|
| MD5 |
992db7ab8a59e0294d5d013e262d9440
|
|
| BLAKE2b-256 |
5a1a414f6048667d0985c2615762d38c05cc01fbfbf504e559b7970c44040045
|
Provenance
The following attestation bundles were made for pytrials_v2-0.1.0.tar.gz:
Publisher:
publish.yml on prahlaadr/pytrials-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytrials_v2-0.1.0.tar.gz -
Subject digest:
4506e3d187281f0a97fea745876988e924382880470dd240958ebddb01b75ce0 - Sigstore transparency entry: 1935281218
- Sigstore integration time:
-
Permalink:
prahlaadr/pytrials-v2@24c5b676bf208accb85c8f1a69341d953284b14e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/prahlaadr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@24c5b676bf208accb85c8f1a69341d953284b14e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytrials_v2-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytrials_v2-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f9de6a04619e07ab9e708a560ad883dd678e033d0693fd97610b78c03946ef9
|
|
| MD5 |
26376a12e1513b041a865b7ab3f21e21
|
|
| BLAKE2b-256 |
49343b36746401418b72d07e4e88ca20414ee39f2a290fe040abba54d40a0bca
|
Provenance
The following attestation bundles were made for pytrials_v2-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on prahlaadr/pytrials-v2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytrials_v2-0.1.0-py3-none-any.whl -
Subject digest:
6f9de6a04619e07ab9e708a560ad883dd678e033d0693fd97610b78c03946ef9 - Sigstore transparency entry: 1935281277
- Sigstore integration time:
-
Permalink:
prahlaadr/pytrials-v2@24c5b676bf208accb85c8f1a69341d953284b14e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/prahlaadr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@24c5b676bf208accb85c8f1a69341d953284b14e -
Trigger Event:
push
-
Statement type: