Metadata-Version: 2.4
Name: pytrials-v2
Version: 0.1.0
Summary: A modern, fully-typed Python SDK for the ClinicalTrials.gov API v2.
Project-URL: Homepage, https://github.com/raami/pytrials-v2
Project-URL: Repository, https://github.com/raami/pytrials-v2
Author: Prahlaad Ram
License: MIT License
        
        Copyright (c) 2026 Prahlaad R.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: api,clinical-trials,clinicaltrials,healthcare,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2
Description-Content-Type: text/markdown

# pytrials-v2

A modern, fully-typed Python SDK for the [ClinicalTrials.gov API v2](https://clinicaltrials.gov/data-api/api).

> Status: early development. See [PROJECT_PLAN.md](./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)

```python
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
