NBAStatPy
Overview
A simple, easy-to-use wrapper for the nba_api package to access NBA data for players, games, teams, and seasons.
Quick Start
from nbastatpy.player import Player
# Create a player object
player = Player("Giannis", season="2023", playoffs=True)
# Get data
awards = player.get_awards()
stats = player.get_career_stats()
Main Classes
- Player - Access player stats, career data, and awards
- Game - Get boxscores, play-by-play, and game details
- League - Query league-wide stats, lineups, and tracking data
- Team - Retrieve team rosters, stats, and splits
WNBA Support
NBAStatPy supports WNBA data out of the box. Player and Team classes automatically detect whether a player or team belongs to the NBA or WNBA:
from nbastatpy.player import Player
from nbastatpy.team import Team
# WNBA players are auto-detected
player = Player("A'ja Wilson")
print(player.league) # "WNBA"
stats = player.get_career_stats()
# WNBA teams are auto-detected by abbreviation
team = Team("LVA") # Las Vegas Aces
print(team.league) # "WNBA"
roster = team.get_roster()
For league-wide WNBA data, pass the league parameter:
from nbastatpy.league import League
wnba_season = League(2024, league="WNBA")
leaders = wnba_season.get_league_leaders(stat_category="PTS")
Standalone Usage
from nbastatpy.standardize import standardize_dataframe
df = standardize_dataframe(df, data_type='player')
MCP Server
NBAStatPy includes a Model Context Protocol (MCP) server that allows AI assistants like Claude to access NBA statistics data.
Quick Start (No Installation Required)
Using uvx, you can run the MCP server directly without installing:
uvx nbastatpy
Adding to Claude Code
Option 1: CLI Command (Recommended)
claude mcp add nbastatpy -- uvx nbastatpy
Option 2: Manual Configuration
Add to your ~/.claude.json (user-level) or .mcp.json (project-level):
{
"mcpServers": {
"nbastatpy": {
"type": "stdio",
"command": "uvx",
"args": ["nbastatpy"]
}
}
}
Option 3: With pip install
{
"mcpServers": {
"nbastatpy": {
"command": "python",
"args": ["-m", "nbastatpy.mcp.server"]
}
}
}
Available Tools
The MCP server provides tools for accessing NBA data:
| Tool | Description |
|---|---|
get_player_game_logs |
Get recent game logs for a player |
get_player_career_stats |
Get season-by-season career statistics |
get_player_play_type_stats |
Get play type (synergy) stats for a player |
get_player_tracking_stats |
Get tracking stats (drives, touches, etc.) |
get_player_info |
Get player biographical and career info |
get_league_leaders |
Get league leaders for any stat category |
get_league_player_stats |
Get league-wide player statistics |
get_league_team_stats |
Get league-wide team statistics |
get_team_recent_games |
Get recent games for a team |
get_team_play_type_stats |
Get play type stats for a team |
get_team_tracking_stats |
Get tracking stats for a team |
get_team_roster |
Get current team roster |
get_recent_games_summary |
Get summary of recent NBA games |
get_recent_games_player_stats |
Get player stats from recent games |
get_live_games |
Get currently live game data |
get_game_boxscore |
Get box score for a specific game |
get_game_playbyplay |
Get play-by-play data for a game |
Installation
Pip
pip install nbastatpy
UV
uv add nbastatpy
Metadata
Release files for nbastatpy 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nbastatpy-0.5.1.tar.gz | 258.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nbastatpy-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 304.1 kB
Release files / nbastatpy-0.5.1.tar.gz
| Download URL | nbastatpy-0.5.1.tar.gz |
|---|---|
| Size | 258.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edf5f2a56a7cb7a49e1127317f28f39266dcea664358c6dc8ab9482aa6c1b3ee
|
|
BLAKE2b-256 checksum How to use checksums |
2a7714e08bb211efd7d24e5b366145d4f74a74330519b7a31ea9447155e9e17b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 4, 2026.
Transparency logRelease files / nbastatpy-0.5.1-py3-none-any.whl
| Download URL | nbastatpy-0.5.1-py3-none-any.whl |
|---|---|
| Size | 45.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6af559b018d4ff6eee954bcbc3743879d9b8d00850e0696920c8241d0e05da5
|
|
BLAKE2b-256 checksum How to use checksums |
14067d9862dc2d6cbbc2adee89971714ce4472f3c51b8c7a177afd7f43e124d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 4, 2026.
Transparency log