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: one row per game with the date, teams, final score, periods, venue and attendance.
- plays: one row per play, with the period, the clock, the player, the running score and, for shots, the court location and the expected points of the shot.
- player_game_stats: one row per player per game, with minutes, shooting splits, rebounds, assists and plus-minus.
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 column | API field (get_plays) | Meaning |
|---|---|---|
| game_id | game_id | Game key, joins every file |
| seq | seq | Order of the play inside the game |
| play_id | not returned | Source play number |
| period | period | Quarter or overtime period |
| clock_seconds | clock_seconds | Seconds left in the period |
| team | team | Team abbreviation |
| type_id, type_text | type | Play type, such as a jump shot or a rebound |
| shooting_play, scoring_play | shot (object), points | Flags for shots and made baskets |
| score_value, points_attempted | points, shot.points_attempted | Points scored, and 2 or 3 attempted |
| x, y | shot.x, shot.y | Court location in feet, basket at (25, 0) |
| distance_ft | shot.distance_ft | Shot distance in feet |
| athlete_id, athlete2_id | player_id, player2_id | Main player, and the assisting or second player |
| home_score, away_score | home_score, away_score | Running score after the play |
| x_points | shot.expected_points | Our expected points for a shot of that type and location |
| x_points_point_in_time | shot.expected_points_point_in_time | The 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:
| seq | period | clock_seconds | team | player | made | x | y | distance_ft | zone | expected_points |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 700 | BOS | Jrue Holiday | true | 25 | 1 | 1.0 | restricted_area | 1.472 |
| 2 | 1 | 683 | DAL | Luka Doncic | false | 35 | 26 | 27.9 | above_break_3 | 1.040 |
| 5 | 1 | 665 | BOS | Jaylen Brown | false | 27 | 32 | 32.1 | above_break_3 | 0.700 |
| 8 | 1 | 646 | BOS | Jayson Tatum | false | 17 | 4 | 8.9 | paint | 0.899 |
| 10 | 1 | 643 | BOS | Jaylen Brown | false | 4 | 14 | 25.2 | above_break_3 | 1.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.
Checked against the live API on 2026-12-06. Questions: hello@sportsdatahq.com.