explaingit

swar/nba_api

Analysis updated 2026-05-18

3,623PythonAudience · dataComplexity · 2/5LicenseSetup · easy

TLDR

A Python package that wraps NBA.com's internal data feeds so you can pull player stats, team records, and live scores with simple Python calls.

Mindmap

mindmap
  root((nba_api))
    What it does
      Wraps NBA.com data endpoints
      No manual HTTP requests needed
    Tech stack
      Python
      requests
      pandas
      numpy
    Use cases
      Player career stats
      Team box scores
      Live scoreboard
    Audience
      Data analysts and developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Pull a specific player's career stats into a pandas DataFrame

USE CASE 2

Fetch today's live NBA scoreboard for a stats dashboard

USE CASE 3

Look up team box scores for historical game analysis

USE CASE 4

Look up a player's ID by name using the bundled static data files

What is it built with?

Pythonpandasnumpy

How does it compare?

swar/nba_apiseatgeek/thefuzzcity96/comfyui-gguf
Stars3,6233,6233,624
LanguagePythonPythonPython
Setup difficultyeasyeasymoderate
Complexity2/52/53/5
Audiencedatadevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Requires Python 3.10+, check NBA.com's Terms of Use before building a public-facing product.

MIT license: use, modify, and distribute freely, including commercially, as long as you keep the copyright notice.

In plain English

nba_api is a Python package that gives developers a way to pull data from NBA.com without having to reverse-engineer the site's data endpoints themselves. The NBA's website exposes various data feeds that power its stats pages, and this library wraps those feeds so you can call them with simple Python code instead of manually constructing HTTP requests. There are two main categories of data. The stats section covers historical records: career stats for a player, game logs, team records, box scores, and more. The live section covers in-progress games and today's scoreboard. Both sections return data that you can work with as raw JSON, as a Python dictionary, or as a pandas DataFrame if you have that library installed. Installing the package takes one command: pip install nba_api. It requires Python 3.10 or newer and depends on the requests and numpy libraries. Once installed, you import whichever endpoint class you need, create an instance of it with the relevant parameters (such as a player ID), and then call a method to get your data back in the format you prefer. The README includes working code examples showing how to fetch a specific player's career stats and how to get the current day's scoreboard. The package also includes static data files for players and teams. These are bundled locally so that common lookups, like finding a player's ID by name, do not require a network request every time. The project is open source under the MIT license. It includes community support via Slack and Stack Overflow. One note from the README: NBA.com has its own Terms of Use that govern how you may use data retrieved through the site, so checking those before building a public-facing product is worth doing.

Copy-paste prompts

Prompt 1
Show me how to install nba_api and fetch a player's career stats as a pandas DataFrame
Prompt 2
Write Python code using nba_api to get today's live NBA scoreboard
Prompt 3
Explain how to look up a player's NBA.com ID by name using nba_api's static data
Prompt 4
Build a simple script with nba_api that compares two players' career stats side by side

Frequently asked questions

What is nba_api?

A Python package that wraps NBA.com's internal data feeds so you can pull player stats, team records, and live scores with simple Python calls.

What language is nba_api written in?

Mainly Python. The stack also includes Python, pandas, numpy.

What license does nba_api use?

MIT license: use, modify, and distribute freely, including commercially, as long as you keep the copyright notice.

How hard is nba_api to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is nba_api for?

Mainly data.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.