File size: 553 Bytes
e83c230 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
"""DrugCentral async wrapper (https://drugcentral.org/api).
Provides drug metadata, approvals, MoA, off‑label, etc.
"""
import httpx, asyncio
from functools import lru_cache
_BASE = "https://drugcentral.org/api/v1/drug"
@lru_cache(maxsize=256)
async def fetch_drugcentral(drug_name: str) -> dict | None:
async with httpx.AsyncClient(timeout=10) as client:
resp = await client.get(_BASE, params={"name": drug_name})
if resp.status_code == 404:
return None
resp.raise_for_status()
return resp.json() |