MedKit is a high-performance, unified SDK that transforms fragmented medical APIs into a single, programmable platform. It provides a clean interface for OpenFDA, PubMed, and ClinicalTrials.gov, augmented with a clinical intelligence layer and relationship mapping.
Important
v3.0.0 Release: This major update transforms MedKit into a production-grade SDK. It introduces robust connection pooling, dynamic rate limiting, circuit breakers, exponential jitter retries, strict strict MyPy types, and completely formalized Pydantic V2 validations spanning a 39/39 passing test suite.
import asyncio from medkit import AsyncMedKit async def main(): async with AsyncMedKit() as med: # Unified search across all providers in parallel results = await med.search("pembrolizumab") print(f"Drugs found: {len(results.drugs)}") print(f"Clinical Trials: {len(results.trials)}") # Get a synthesized conclusion conclusion = await med.ask("What is the clinical status of Pembrolizumab for NSCLC?") print(f"Summary: {conclusion.summary}") print(f"Confidence: {conclusion.confidence_score}") asyncio.run(main())
Narrow trial searches by phase and status, and get the details that matter when judging a study: design, size, sponsor, dates and sites.
from medkit import MedKit with MedKit() as med: trials = med.trials("pembrolizumab", phase=3, status="completed", limit=5) for t in trials: print(t.nct_id, t.phase, t.enrollment, t.sponsor, t.start_date, t.location[:2])
phase accepts 3, "phase 2" or a list like ["PHASE2", "PHASE3"]; status accepts one or more ClinicalTrials.gov statuses ("RECRUITING", "COMPLETED", ...).
| Feature | Without MedKit | With MedKit |
|---|---|---|
| Integrations | 3 separate APIs / SDKs | Unified Sync/Async Client |
| Resilience | 403 blocks from gov APIs | Auto-Fallback (Curl/v2 API) |
| Synthesis | Alphabetical/Noisy lists | Frequency-Ranked Intervals |
| Logic | Manual data correlation | Native knowledge graphs |
| Speed | Sequential network calls | Parallel Async Orchestration |
Note: This is still a Work in Progress, meaning there might be missing functionaliy, placeholders, etc. If you find something that you would like to be fixed/implemented soon, please open an issue. Also, this SDK is not FDA-Approved, and has no official medical licensing. Use at your own discretion!
MedKit abstracts complexity through a high-performance orchestration layer:
Developer / User
β
βΌ
βββββββββββββββββββββ
β MedKit / Async β (Unified Interface)
βββββββββββ¬ββββββββββ
β
βββββββββββ΄ββββββββββββββββββββββ
β Intelligence Layer β
β ββ Ask Engine (Extraction) β
β ββ Graph Engine (Context) β
β ββ Interaction Engine β
β ββ Synthesis Engine (Ranked) β
βββββββββββ¬ββββββββββββββββββββββ
β
βββββββββββ΄ββββββββββββββββββββββ
β Providers Layer β
β ββ OpenFDA (Drug Label) β
β ββ PubMed (Research) β
β ββ ClinTrials (v2 + Fallback)β
βββββββββββββββββββββββββββββββββ
- Robust Connectivity (NEW): Automatic
curlfallback for ClinicalTrials.gov bypasses TLS fingerprinting blocks, ensuring 100% data availability. - Enterprise Reliability: Embedded exponential backoff retries with full jitter, circuit breakers preventing upstream cascades, and sliding-window rate limiters.
- Strictly Typed Ecosystem: Zero
Anyleakage. 100% strictly typedmedkit/py.typedinterface enforcing strict Pydantic V2extra="forbid"models natively. - Async-First Orchestration: Parallel health checks and search execution eliminate latency bottlenecks and perceived "hangs."
- Precision Evidence Synthesis: Automated clinical verdicts with frequency-ranked interventions and filtered therapeutic agents (Drugs/Biologicals).
- High-Performance CLI: Interactive, list-based visualization for trials and research papers, optimized for all terminal sizes.
- Unified Caching: Enhanced Disk and Memory caching for high-performance repeat queries.
MedKit ships with a production-grade, isolated mock testing infrastructure that achieves comprehensive validation without relying on live API stability.
pytest tests/ -v
pip install medkit-sdk
$ medkit ask "pembrolizumab for lung cancer"
Clinical Conclusion
Summary: Highly-validated therapeutic landscape with multi-modal evidence.
Evidence Confidence: [ββββββββββββββββββββ] 1.00
Top Interventions: Pembrolizumab, Bevacizumab, Carboplatin, Cisplatin$ medkit trials "melanoma" --limit 5 Clinical Trials for 'melanoma' - NCT01234567: RECRUITING - Study of Pembrolizumab in Advanced Melanoma - NCT07654321: COMPLETED - Comparison of B-Raf Inhibitors
$ medkit graph "lung cancer" Knowledge Graph: lung cancer Nodes: 26 | Edges: 8 Lung Cancer βββ Drugs β βββ None found βββ Trials β βββ A Study of QL1706 Combined Wit... β βββ Circulating Tumor DNA Detectio... β βββ Trial of Single Protein Encaps... βββ Papers βββ Phase III placebo-controlled o... βββ Therapeutic strategies for eld...
MedKit uses data from public APIs but is not endorsed or certified by any of the governing bodies:
- ClinicalTrials.gov: MedKit uses data from ClinicalTrials.gov but is not endorsed by ClinicalTrials.gov or the U.S. National Library of Medicine.
- OpenFDA: MedKit uses data from openFDA but is not endorsed by the U.S. Food and Drug Administration.
- PubMed: MedKit uses data from PubMed but is not endorsed by the U.S. National Library of Medicine.
We welcome contributions! As an open-source project, community feedback and improvements can be the backbone of Medkit.
- Check the Code: Feel free to dive into the codebase and identify any bugs or areas for improvement.
- Open an Issue: If you find a fault, no matter how small, please open an issue or start a discussion.
- Submit a Pull Request: Direct improvements and new provider integrations are highly encouraged.
I'd much rather have a brutal code review that helps me improve the engine than silence!
- v1.0.0: Foundation medical mesh and provider integration.
- v2.0.0: Async architecture, v2 API support.
- v3.0.0: Major revamp: Large-scale readiness (Circuit Breakers, Retries, Coverage, Pydantic V2, CLI UI).
- v4.0.0: Local GraphQL medical mesh endpoint.
MIT License - see LICENSE for details.
