import httpx from functools import lru_cache _URL = "https://rest.ensembl.org/xrefs/symbol/homo_sapiens/{}?content-type=application/json" @lru_cache(maxsize=512) async def fetch_ensembl(sym: str): async with httpx.AsyncClient(timeout=8) as c: r = await c.get(_URL.format(sym)) return r.json()[0] if r.status_code == 200 and r.json() else {}