Dataset

NBA play-by-play in Parquet, with shot locations

Short answer: the NBA History package is every NBA game, every play and every player game line we hold since 2003-04, as files you download once for $199. Plays are Parquet only, one file per season, with shot coordinates and our expected points. The API serves the same plays for new games.

What you are buying

The NBA History package (id nba-history, $199 one time) contains three tables, all joined on game_id:

Games and player game stats ship as CSV and Parquet. The plays table is Parquet only, one file per season. Unknown values are blank, never 0. A README, a manifest with row counts per file and a checksum list come in the same download, so you can confirm every file before you load it.

Two larger tiers exist if you also want market history. NBA History + Odds ($499) adds game odds by sportsbook, with opening and closing lines per book from July 2020, plus a consensus closing line. NBA Complete ($799) adds graded player props from May 2023 and the full intraday line history from 2020. Odds are sold as market history: what each book posted and when. If you buy History first, you can upgrade for the price difference within 90 days.

Coverage and updates

Plays start with the 2003-04 season. Seasons are named by the year they end in the API (2025 means 2024-25), and the package manifest lists every file with its row count, so you can check coverage before you start. The catalog does not state a total row count for the plays table, so we do not quote one here. The manifest.json in your download has the exact count for every file.

Every package includes all finished seasons and the current season as of our latest monthly update on the day you buy. While you hold an API plan of Pro or higher, we refresh the current season's files every month at no extra charge. Without a plan, an end-of-season update costs a quarter of the package price. Fixes to past seasons are free for a year, and you can re-download what you bought for 365 days.

Schema

These are the real column names from the free sample of the package. The right column shows the matching field in the live API, because the two use different names in places.

Package columnAPI field (get_plays)Meaning
game_idgame_idGame key, joins every file
seqseqOrder of the play inside the game
play_idnot returnedSource play number
periodperiodQuarter or overtime period
clock_secondsclock_secondsSeconds left in the period
teamteamTeam abbreviation
type_id, type_texttypePlay type, such as a jump shot or a rebound
shooting_play, scoring_playshot (object), pointsFlags for shots and made baskets
score_value, points_attemptedpoints, shot.points_attemptedPoints scored, and 2 or 3 attempted
x, yshot.x, shot.yCourt location in feet, basket at (25, 0)
distance_ftshot.distance_ftShot distance in feet
athlete_id, athlete2_idplayer_id, player2_idMain player, and the assisting or second player
home_score, away_scorehome_score, away_scoreRunning score after the play
x_pointsshot.expected_pointsOur expected points for a shot of that type and location
x_points_point_in_timeshot.expected_points_point_in_timeThe same model fitted only on earlier data, for backtests

The API adds two things the sample file does not list: a shot.zone label (restricted area, paint, midrange, corner three, above the break three, free throw) and home_win_prob, our win probability after each play. Check the README in your download for the exact column list of your files.

A real sample

Five shots from game 401656363 (2024 Finals, game 5), taken from the live API on December 6, 2026:

seqperiodclock_secondsteamplayermadexydistance_ftzoneexpected_points
11700BOSJrue Holidaytrue2511.0restricted_area1.472
21683DALLuka Doncicfalse352627.9above_break_31.040
51665BOSJaylen Brownfalse273232.1above_break_30.700
81646BOSJayson Tatumfalse1748.9paint0.899
101643BOSJaylen Brownfalse41425.2above_break_31.082

Expected points is the model's value of a shot from its type and location, fitted on every shot in the league's history. A layup at the rim is worth about 1.47 points. A 28-foot step-back is worth about 1.04. Summing the gap between points scored and expected points per shooter gives you shot-making above expectation without building a model.

Load the Parquet files

DuckDB reads a whole directory of season files in one query. Run this from the folder you unzipped into:

import duckdb

duckdb.sql("""
    SELECT g.season,
           count(*)        AS shots,
           avg(p.x_points) AS avg_expected_points
    FROM read_parquet('plays_*.parquet') AS p
    JOIN read_parquet('games.parquet')  AS g USING (game_id)
    WHERE p.x_points IS NOT NULL
    GROUP BY g.season
    ORDER BY g.season
""").show()

The same job in Polars, lazily, so the full archive never has to fit in memory:

import polars as pl

plays = pl.scan_parquet("plays_*.parquet")
games = pl.scan_parquet("games.parquet").select("game_id", "season")

by_season = (
    plays.filter(pl.col("x_points").is_not_null())
    .join(games, on="game_id")
    .group_by("season")
    .agg(pl.len().alias("shots"), pl.col("x_points").mean().alias("avg_expected_points"))
    .sort("season")
    .collect()
)
print(by_season)

Same data through the API

For one game, one player or the current week, call the API. Set SDHQ_API_KEY to a key from your account first.

import json
import os
import urllib.request

payload = {"game_id": "401656363", "shots_only": True, "limit": 5}
req = urllib.request.Request(
    "https://api.sportsdatahq.com/v1/nba/get_plays",
    data=json.dumps(payload).encode(),
    headers={"Content-Type": "application/json", "x-api-key": os.environ["SDHQ_API_KEY"]},
)
with urllib.request.urlopen(req, timeout=30) as resp:
    print("HTTP", resp.status)
    body = json.load(resp)["data"]
    for p in body["plays"]:
        s = p["shot"]
        print(p["period"], p["player"], s["zone"], s["made"], s["expected_points"])
curl -s -X POST https://api.sportsdatahq.com/v1/nba/get_plays \
  -H "Content-Type: application/json" -H "x-api-key: $SDHQ_API_KEY" \
  -d '{"game_id": "401656363", "shots_only": true, "limit": 5}'

One call costs 10 credits and returns a page with a next_offset to follow. The hub plan gives 1,000 free credits a month. The basketball brand, DunkAPI, has its own docs and gives 500.

Get a free key

Checked against the live API on 2026-12-06. Questions: hello@sportsdatahq.com.