Skip to main content

stat-api-client

Official Python client for the stat-api sports data API — a single, typed surface over NBA, NFL, MLB, NHL, and PGA data.

Zero runtime dependencies (stdlib only). Python 3.10+.

Install

pip install stat-api-client

Authenticate

The client reads your API key from the STAT_API_KEY environment variable, or you can pass it directly:

from statapi import StatApi

api = StatApi()                      # reads STAT_API_KEY
api = StatApi(api_key="sdb_...")     # or pass it in

Point at a different host with base_url= or STAT_API_BASE_URL (default https://api.stat-api.com).

List, get, and iterate

# One page (returns a Page[Row]).
page = api.nba.players.list(limit=25)
for player in page.rows:
    print(player["full_name"])

# Fetch one row by id.
player = api.nba.players.get(201939)

# Auto-paginate the whole result set (walks next_from_id for you).
for player in api.nba.players.iter(team_id=1):
    print(player["full_name"])

Rows are TypedDicts — access fields by subscript (player["team_id"]). High-precision columns (dates, timestamps, decimals) arrive as strings so no precision is lost on the wire.

Errors

Every non-2xx response raises a typed exception; the raw server envelope is on .body.

from statapi import (
    StatApi,
    AuthenticationError,
    NotFoundError,
    QuotaExceededError,
    ValidationError,
    StatApiError,
)

try:
    api.nba.players.get(-1)
except NotFoundError:
    ...
except QuotaExceededError as err:
    print("quota resets at", err.resets_at, "→", err.upgrade_url)
except StatApiError as err:
    print(err.status, err.body)
Status Exception
400 ValidationError
401 AuthenticationError
402 PlanRequiredError
404 NotFoundError
429 QuotaExceededError
other StatApiError

NFL sim (beta)

The Python client has the core calls of the NFL play-by-play simulator. Game 43418 (2026 Week 1 DEN @ KC) is free. Other games need a Pro or Elite plan, or the DFS add-on.

  • api.nfl.weeks(season=...)
  • api.sim.nfl.run(game_id=..., n_draws=..., seed=..., include=..., home_spread=...)

The tutorial has 5 recipes. Each one runs on the free game and prints real output. Start with Run your first NFL game simulation, or read the whole tutorial at https://stat-api.com/docs/cookbook/sim/.

The API reference: https://stat-api.com/docs/api/sim/

Quota

Every response carries your monthly record quota. It's on each Page and on QuotaExceededError:

page = api.nba.players.list(limit=1)
if page.quota:
    print(page.quota.remaining, "of", page.quota.limit, "records left")

License

MIT. See LICENSE.

Metadata

Release files for stat-api-client 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stat-api-client 0.3.1
File Size Uploaded Provenance Actions
stat_api_client-0.3.1.tar.gz 83.8 kB Without provenance Details for stat_api_client-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stat-api-client 0.3.1
File Interpreter ABI Platform Actions
stat_api_client-0.3.1-py3-none-any.whl Python 3 none any Details for stat_api_client-0.3.1-py3-none-any.whl

Total release size: 328.9 kB

Release files / stat_api_client-0.3.1.tar.gz

Download URL stat_api_client-0.3.1.tar.gz
Size 83.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0e82ee9b30ea70ef421355c41fa8f0d43a35366079f399c2c7723c61407e961a
BLAKE2b-256 checksum
How to use checksums
f01580793679e73d4afb32b63dd8de4d08375b0d70de650fd8ddb4ddc38cbb6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / stat_api_client-0.3.1-py3-none-any.whl

Download URL stat_api_client-0.3.1-py3-none-any.whl
Size 245.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5abe42264de74be34474148f2f8e7a2d4c0ac62b14da93c2081a625c50a44731
BLAKE2b-256 checksum
How to use checksums
ff599947418c3d59e901f556a45efc8fe611e45a0ddb0e890623ddf5ba7fd0fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for stat-api-client 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page