Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytrials_v2-0.1.0.tar.gz (56.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytrials_v2-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

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

Hashes for pytrials_v2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4506e3d187281f0a97fea745876988e924382880470dd240958ebddb01b75ce0
MD5 992db7ab8a59e0294d5d013e262d9440
BLAKE2b-256 5a1a414f6048667d0985c2615762d38c05cc01fbfbf504e559b7970c44040045

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrials_v2-0.1.0.tar.gz:

Publisher: publish.yml on prahlaadr/pytrials-v2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pytrials_v2-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f9de6a04619e07ab9e708a560ad883dd678e033d0693fd97610b78c03946ef9
MD5 26376a12e1513b041a865b7ab3f21e21
BLAKE2b-256 49343b36746401418b72d07e4e88ca20414ee39f2a290fe040abba54d40a0bca

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrials_v2-0.1.0-py3-none-any.whl:

Publisher: publish.yml on prahlaadr/pytrials-v2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page