File size: 363 Bytes
b1bf985
563f401
b1bf985
 
 
563f401
b1bf985
563f401
b1bf985
 
1
2
3
4
5
6
7
8
9
10
11
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 {}