Python SDK

Official Python client. Sync and async, full type hints, retry and rate-limit handling.

Installation

pip install sportapi
# or
poetry add sportapi

Quick start

from sportapi import Client

client = Client(api_key=os.environ["SPORTAPI_KEY"])
games = client.nba.scores.live()
print(games)

Async client

from sportapi import AsyncClient

async with AsyncClient(api_key=os.environ["SPORTAPI_KEY"]) as client:
    games = await client.nba.scores.live()
    async for update in client.stream.subscribe("nba.scores.live"):
        print(update)

API coverage

Full coverage across NBA, NFL, MLB, NHL, soccer, news, WebSocket, and webhooks.

Error handling

from sportapi import RateLimitError, AuthError

try:
    games = client.nba.scores.live()
except RateLimitError as e:
    time.sleep(e.retry_after)
except AuthError:
    sys.exit("Bad API key")