Skip to main content

ctgforge

Turn ClinicalTrials.gov v2 studies into analytics-ready DataFrames and knowledge graphs.

ClinicalTrials.gov provides one of the most comprehensive public registries of clinical trials — but its modern v2 API exposes data in a deeply nested, regulatory-oriented structure that is difficult to query, flatten, and analyze.

ctgforge bridges that gap.

It gives researchers and developers a clean, opinionated Python toolkit to:

  • 🔍 Query ClinicalTrials.gov v2 with a safe, composable DSL
  • 🧱 Flatten layered study records into canonical trial objects
  • 📊 Export trials as pandas DataFrames for analysis
  • 🕸️ Generate property-graph tables (nodes & edges) for downstream Knowledge-Graph/AI workflows
  • 🧾 Preserve provenance, so every flattened field can be traced back to its original CTG module

ctgforge is designed for people who actually work with clinical trials data — not just for making API calls, but for analysis, modeling, and knowledge integration.

Why ctgforge?

ClinicalTrials.gov is a regulatory registry, not an analytics database.

That means:

  • deeply nested JSON (sections → modules → items)
  • verbose, evolving schemas
  • query syntax that is powerful but easy to misuse

Most users end up writing custom scripts to:

  • flatten the same fields
  • reconcile the same inconsistencies
  • rebuild the same tables and graphs

ctgforge makes those decisions once — and makes them explicit.

Quick taste

from ctgforge import CTG, F
from ctgforge.flatten import flatten_core
from ctgforge.export import to_dataframe, to_property_graph

client = CTG()

q = (
    F.sponsor.eq("pfizer") &
    F.condition.contains("lung cancer") &
    F.phase.in_(["PHASE3", "PHASE4"]) &
    F.status.in_(["RECRUITING", "COMPLETED"])
)

count = client.count(q)
raw = client.search(q, offset=20, limit=100)
trials = [flatten_core(r) for r in raw]

df = to_dataframe(trials)
nodes, edges = to_property_graph(trials)

At this point you have:

  • a wide trial table for analytics
  • node/edge tables ready for graph import
  • a stable, inspectable data model

How to query

  • Single Query: F.{field}.{operator}({value})
  • Available Fields: sponsor, condition, intervention, phase, status, title
  • Available Operators: eq, contains, in_

Logical operators & | ! can be used to combine multiple queries. However, the | (OR) operator across different fields such as F.condition.eq("diabetes") | F.sponsor.eq("Acme Pharma") will raise an error.

You may add extra criteria to count or search, such as
client.count(q, extra={"query.term": "AREA[LastUpdatePostDate]RANGE[2025-01-01,MAX]"})

For the format of raw criteria, please refer to ClinicalTrials.gov API Specification.

Who this is for

  • Clinical researchers working with trial registries
  • Bioinformatics and healthcare data engineers
  • Data scientists building trial-level datasets
  • Teams constructing knowledge graphs or RAG systems from clinical trials

If you just want raw API responses, you don’t need ctgforge.
If you want usable trial data, you probably do.

Project status

ctgforge is under active development and currently in alpha.
The public API is intentionally small and designed to evolve carefully.

Metadata

Release files for ctgforge 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ctgforge 0.2.5
File Size Uploaded Provenance Actions
ctgforge-0.2.5.tar.gz 11.6 kB Without provenance Details for ctgforge-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ctgforge 0.2.5
File Interpreter ABI Platform Actions
ctgforge-0.2.5-py3-none-any.whl Python 3 none any Details for ctgforge-0.2.5-py3-none-any.whl

Total release size: 28.6 kB

Release files / ctgforge-0.2.5.tar.gz

Download URL ctgforge-0.2.5.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
129cbf4f15c4f1dd3335dbc8dcb72fa18b8ba9ea2d24de7d87956346195d0a7e
BLAKE2b-256 checksum
How to use checksums
ae9b840436fb4dcdfa46672bd2c19a965386d3ebf9811174683a8ecde2ac81c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ctgforge-0.2.5-py3-none-any.whl

Download URL ctgforge-0.2.5-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fc93ea9410cf05c1bc6c6f8061396b2977dab57dc73b3d8cd63066e08693096
BLAKE2b-256 checksum
How to use checksums
21c3753296fb4c5d2876993214b0ce43473f9af92159012f835d2767e841977f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for ctgforge 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page