A unified Python SDK for public medical APIs (OpenFDA, PubMed, ClinicalTrials.gov)
Project description
๐ฅ MedKit: A Unified Platform for Medical Data APIs
MedKit is a high-performance, unified SDK that transforms fragmented medical data 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.
โจ Quick Example
from medkit import MedKit
with MedKit() as med:
# Query trials directly in plain English
results = med.ask("clinical trials for melanoma")
# Real Output Example:
# Trials:
# โข Phase III Pembrolizumab Trial
# โข Targeted BRAF Therapy Study
print(results.trials[0].title)
๐ค Why MedKit?
| Feature | Without MedKit | With MedKit |
|---|---|---|
| Integrations | 3 separate APIs / SDKs | One unified client |
| Queries | 3 fragmented formats | One schema & ask() engine |
| Logic | Manual data correlation | Native knowledge graphs |
| Speed | Ad-hoc caching | Built-in Disk/Memory Cache |
๐๏ธ Architecture
MedKit abstracts complexity through a multi-layered provider system:
Developer / User
โ
โผ
โโโโโโโโโโโโโโโโโโโโโ
โ MedKit Client โ (Sync / Async)
โโโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโ
โ Intelligence Layer โ
โ โโ Ask Engine (Routing) โ
โ โโ Graph Engine (Context) โ
โ โโ Interaction Engine โ
โโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโ
โ Providers Layer โ
โ โโ OpenFDA (Drug Label) โ
โ โโ PubMed (Research) โ
โ โโ ClinTrials (Studies) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Core Platform Features
- Clinical Interaction Engine: High-fidelity detection of drug-drug contraindications via
med.interactions(). - Capability-Based Routing: Intelligent query routing based on provider capabilities.
- Actionable Research: Native URL generation for all papers and trials with direct CLI opening (
--open). - Natural Language Engine (
med.ask()): Query medical data in plain English with automated query sanitization. - Medical Relationship Graph (
med.graph()): Visualize connections with descriptive, title-based node labeling. - Provider Health Dashboard: Real-time status and latency tracking via
medkit status. - Research Data Export: Native CSV and JSON export for medical researchers.
- Async & Sync Support: High-concurrency support with
AsyncMedKit.
๐ Data Providers
MedKit currently integrates the following foundational medical databases:
- OpenFDA: Official drug labels, safety information, and manufacturing data from the U.S. Food and Drug Administration.
- PubMed: The world's largest biomedical research database, providing access to over 35 million citations.
- ClinicalTrials.gov: A comprehensive database of privately and publicly funded clinical studies conducted around the world.
๐ฆ Installation
pip install medkit-sdk
๐ Quick Start
1. Check Drug Interactions
from medkit import MedKit
with MedKit() as med:
# Check for potential risks
risks = med.interactions(["aspirin", "warfarin"])
for risk in risks:
print(f"Risk: {risk['warning'].risk} (Severity: {risk['warning'].severity})")
2. High-Concurrency Search (Async)
from medkit import AsyncMedKit
import asyncio
async def main():
async with AsyncMedKit() as med:
results = await med.papers("CRISPR gene editing")
print(f"Found {len(results)} recent papers.")
asyncio.run(main())
3. Medical Relationship Graph
MedKit's signature feature: a medical knowledge graph. Map how drugs relate to trials and papers.
graph = med.graph("metformin")
Example Output:
Metformin
โโ treats โ Type 2 Diabetes
โโ trial โ Phase III Study (NCT012345)
โโ research โ Meta-analysis 2026
4. Extending Providers (Plugins)
MedKit is built on a plugin architecture. You can easily add custom data sources.
from medkit.providers.base import BaseProvider
class MyPrivateDB(BaseProvider):
name = "privatedb"
def search_sync(self, query: str):
return {"data": "..."}
with MedKit() as med:
med.register_provider(MyPrivateDB())
๐ฅ๏ธ CLI Power Tools
Provider Status
Check the real-time health and latency of all integrated medical APIs.
$ medkit status
MedKit Provider Health
+-----------------------------------+
| Provider | Status | Latency |
|----------------+--------+---------|
| openfda | ONLINE | 120ms |
| pubmed | ONLINE | 210ms |
| clinicaltrials | ONLINE | 180ms |
+-----------------------------------+
Direct Research Access
Display clickable URLs or open the top result directly in your browser.
$ medkit papers "Alzheimer's" --limit 3 --links --open
Clinical Ask
$ medkit ask "is metformin safe with alcohol?"
๐ค Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Development Setup
- Clone the repository.
- Install dependencies:
pip install -e . - Run tests:
pytest
๐บ๏ธ Roadmap
- Phase 2.0: AI-powered research summaries and evidence strength scoring.
- Phase 2.1: Advanced pharmacogenomics provider integration.
- Phase 3.0: Local GraphQL API to serve the unified medical mesh.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
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 medkit_sdk-0.1.0.tar.gz.
File metadata
- Download URL: medkit_sdk-0.1.0.tar.gz
- Upload date:
- Size: 547.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1722cfaf6a77f0f34955f70e208eb588bb62ac4b9ceba1f53f0fc5e5c49fcf5
|
|
| MD5 |
d785d0b8a614518d5a25e714314ee90d
|
|
| BLAKE2b-256 |
2ce3175d90a84fb047f0c3fafe453079a6409ad2ea243fa661e33920ba38597a
|
File details
Details for the file medkit_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: medkit_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f83cb08869eeacab79a33a14c327557b68ec1b3f1dcdc0cedc3eb7b575c558e
|
|
| MD5 |
b45757c01411eca23e512fc09e081d4f
|
|
| BLAKE2b-256 |
9833484c7b64859e5babef27fe32e977c1c24de407fe92be3b79ac776a986ff1
|