nba_api is a free, open source api development & testing project written in Python and released under MIT. It has 3,777 GitHub stars, 721 forks and 111 open issues, and was last pushed 1 months ago. On this registry it ranks #58 of 103 tracked projects in API Development & Testing, with 5 head-to-head comparisons available. It gained 2 stars over the last 3 tracked days.

What is nba_api?

What it is

nba_api is a Python package that acts as an API client for the web APIs used by NBA.com. It lives in the Python developer tools ecosystem and is distributed as an open-source project under the MIT license. The package is designed to make official NBA.com data accessible through Python code, while also documenting the endpoints and parameters that the site exposes.

The concrete problem it solves is the difficulty of calling NBA.com data endpoints directly. Without this package, a developer or analyst must discover endpoint URLs, construct parameters, send HTTP requests, and parse raw responses. nba_api wraps that work in Python classes for official stats and live data, and it provides examples and documentation so users can retrieve player, game, team, scoreboard, and play-by-play information more quickly.

Key capabilities

  • Accesses NBA.com official stats endpoints through Python classes, including player career statistics.
  • Accesses NBA.com live data endpoints, including the current scoreboard.
  • Returns data as JSON, Python dictionaries, or optional Pandas DataFrames when pandas is installed.
  • Supports proxy configuration, custom headers, and timeout settings for HTTP requests.
  • Provides static data sets for players and teams to reduce repeated HTTP requests for common identifiers.
  • Maintains detailed endpoint documentation and analysis for many NBA.com API endpoints.
  • Includes practical Jupyter Notebook examples for basic calls, game lookup, play-by-play data, and live game data.

Who uses it and how

  • Python analysts use it to pull official NBA.com stats into notebooks or scripts for basketball analysis.
  • Developers use it to integrate scoreboard and live game data into applications without hand-writing HTTP calls.
  • Researchers and fans use it to retrieve player career data, team data, and play-by-play records for further processing.
  • Contributors use the project to report new, changed, or deprecated endpoints because NBA.com does not publish a stable API change feed.

Getting started

Install the package with pip install nba_api. It requires Python 3.10 or newer, plus the requests and numpy packages; pandas is optional unless you want DataFrame output.

When to use it — and when not to

Use nba_api when you need a Python client for NBA.com stats and live endpoints and you value endpoint documentation, examples, and community help. Avoid it if you need a guaranteed stable external API, because NBA.com can change or remove endpoints without notice and users must report broken endpoints through GitHub issues. It is not a hosted database or storage service, so users must run their own Python environment and handle any data storage, transformation, or production scheduling themselves.

project readme (upstream, from github) — read inline

Version: PyPI Downloads per Month: PyPY Build: CircleCI License: MIT Slack

nba_api

An API Client Package to Access the APIs of NBA.com

nba_api is an API Client for www.nba.com. This package intends to make the APIs of NBA.com easily accessible and provide extensive documentation about them.

Getting Started

nba_api requires Python 3.10+ along with the requests and numpy packages. While pandas is not required, it is required to work with Pandas DataFrames.

pip install nba_api

NBA Official Stats

from nba_api.stats.endpoints import playercareerstats

# Nikola Jokić
career = playercareerstats.PlayerCareerStats(player_id='203999')

# pandas data frames (optional: pip install pandas)
career.season_totals_regular_season.get_data_frame()

# json
career.get_json()

# dictionary
career.get_dict()

NBA Live Data

from nba_api.live.nba.endpoints import scoreboard

# Today's Score Board
games = scoreboard.ScoreBoard()

# json
games.get_json()

# dictionary
games.get_dict()

Additional Examples

  • Requests/Response Options
    • Proxy Support, Custom Headers, and Timeout Settings
    • Return Types and Raw Responses
  • Static Data Sets
    • Reduce HTTP requests for common and frequently accessed player and team data.
  • Jupyter Notebooks
    • Practical examples in Jupyter Notebook format, including making basic calls, finding games, working with play-by-play data, and interacting with live game data.

Documentation

Join the Community

Slack

Join Slack to get help, help others, provide feedback, see amazing projects, participate in discussions, and collaborate with others from around the world.

Stack Overflow

Not a Slack fan? No problem. Head over to StackOverflow. Be sure to tag your post with nba-api.

Contributing

See Contributing to the NBA_API for complete details.

Endpoints

A significant purpose of this package is to continuously map and analyze as many endpoints on NBA.com as possible. The documentation and analysis of the endpoints and parameters in this package are some of the most extensive information available. At the same time, NBA.com does not provide information regarding new, changed, or removed endpoints.

If you find a new, changed, or deprecated endpoint, open a GitHub Issue

Bugs

Encounter a bug, report a bug.

License & Terms of Use

API Client Package

The nba_api package is Open Source with an MIT License.

NBA.com

NBA.com has a Terms of Use regarding the use of the NBA’s digital platforms.

Frequently asked questions

Is nba_api free to use?

nba_api is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does nba_api do?

An API Client package to access the APIs for NBA.com

What is nba_api written in?

nba_api is primarily written in Python. Its source is publicly available at https://github.com/swar/nba_api, and it has 3,777 GitHub stars.