Skip to main content

A unified Python SDK for public medical APIs (OpenFDA, PubMed, ClinicalTrials.gov)

Project description

๐Ÿฅ MedKit: A Unified Platform for Medical Data APIs

CI Status Python 3.9+ License: MIT

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.

MedKit CLI Demo

โœจ 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

  1. Clone the repository.
  2. Install dependencies: pip install -e .
  3. 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


Download files

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

Source Distribution

medkit_sdk-0.1.0.tar.gz (547.1 kB view details)

Uploaded Source

Built Distribution

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

medkit_sdk-0.1.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

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

Hashes for medkit_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f1722cfaf6a77f0f34955f70e208eb588bb62ac4b9ceba1f53f0fc5e5c49fcf5
MD5 d785d0b8a614518d5a25e714314ee90d
BLAKE2b-256 2ce3175d90a84fb047f0c3fafe453079a6409ad2ea243fa661e33920ba38597a

See more details on using hashes here.

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

Hashes for medkit_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f83cb08869eeacab79a33a14c327557b68ec1b3f1dcdc0cedc3eb7b575c558e
MD5 b45757c01411eca23e512fc09e081d4f
BLAKE2b-256 9833484c7b64859e5babef27fe32e977c1c24de407fe92be3b79ac776a986ff1

See more details on using hashes here.

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