nba_api
An API Client package to access the APIs for NBA.com
What it is and what it does
nba_api is a Python client library that wraps NBA.com's official statistics and live game data endpoints, letting you fetch player career stats, team information, game scores, and play-by-play data without building HTTP requests from scratch. It requires Python 3.10+ and depends on requests for HTTP calls and numpy for data handling; pandas is optional but needed if you want results as DataFrames. The package maps NBA.com endpoints and provides extensive documentation, though NBA.com itself does not publish endpoint specifications, so the maintainers reverse-engineer and document them as they discover changes.
You use it by importing specific endpoints (like PlayerCareerStats or ScoreBoard), instantiating them with parameters, then calling methods like get_json(), get_dict(), or get_data_frame() to retrieve results. It handles proxy support, custom headers, and timeout settings, and includes static data sets for frequently accessed player and team information to reduce HTTP requests. The package is actively maintained, has no known security vulnerabilities, and is permissively licensed under MIT.
Use it for:
- Fetch historical player career statistics and season totals for analysis or visualization projects.
- Build a live scoreboard or game tracker that updates with current game scores and play-by-play data.
- Collect team rosters and player metadata for a sports analytics or fantasy basketball application.
- Export NBA stats to pandas DataFrames for statistical modeling or data science workflows.
- Reduce API call overhead by using static player and team data sets instead of repeated endpoint queries.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
nba_api provides Python access to NBA.com's official stats and live game data APIs, returning results as JSON, dictionaries, or pandas DataFrames.
Yes. nba_api is actively maintained, has low install friction, no security vulnerabilities, permissive MIT licensing, and a stable API surface. Install it if you need programmatic access to NBA.com data; be aware that NBA.com's own Terms of Use may restrict how you use the data, and endpoint availability depends on NBA.com's infrastructure.
Install
nba-api on PyPI
pip
pip install nba-apiuv
uv add nba-apipoetry
poetry add nba-apiInstalling nba_api
Before you install
Low friction install with three common dependencies (numpy, pandas, requests). Package is actively maintained with recent commits and 3741 GitHub stars, supporting current Python versions.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely as long as you include the license notice.
Quickstart
pip install nba_api
from nba_api.stats.endpoints import playercareerstats
career = playercareerstats.PlayerCareerStats(player_id='203999')
career.get_data_frame()
Requires Python 3.10+; pandas must be installed separately to use get_data_frame().
Verify before relying
- Whether NBA.com's Terms of Use impose restrictions on programmatic access or data usage beyond the package's own licensing.
- Rate limiting or throttling policies that may affect production workloads.
- Endpoint stability and how often NBA.com changes or removes endpoints without notice.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — numpy, pandas, requests |
| Maintenance | actively maintained — 175 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 265,069/month — #8,330 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: nba_api-1.11.4-py3-none-any.whl
Keywords: api, basketball, data, nba, sports, stats
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
MLB-StatsAPIProvides Python access to MLB's Stats API,…
copyleft · top 15,000 on PyPI
nflreadpyDownloads and caches NFL data from nflverse…
permissive · top 15,000 on PyPI
statsbombpyStreams StatsBomb football analytics data into…
unclear · top 15,000 on PyPI
pybaseballScrapes baseball data from Baseball Reference,…
permissive · top 15,000 on PyPI
espn-apiExtracts league, team, and player data from…
permissive · top 15,000 on PyPI
nfl-data-pyImports NFL play-by-play, weekly, seasonal,…
permissive · top 15,000 on PyPI
pypistatsQueries the PyPI Stats API to retrieve download…
permissive · top 15,000 on PyPI
trueskillImplements the TrueSkill rating algorithm to…
permissive · top 15,000 on PyPI
benchling-api-clientA low-level HTTP client for Benchling's API,…
permissive · top 15,000 on PyPI
jsonasobj2Converts JSON data into Python objects with…
permissive · top 15,000 on PyPI