Skip to content

Compare

The NBA API: free endpoints, nba_api and DunkAPI

The NBA has no documented public API. stats.nba.com, cdn.nba.com and ESPN's endpoints are free but unofficial. Where each fits, and how DunkAPI differs.

Comparison facts checked October 14, 2026. DunkAPI data last refreshed 2026-10-14 10:01 UTC, newest data through 2026-10-13. Changelog

There is no documented public NBA API. The NBA's own sites use two hosts, stats.nba.com for stats tables and cdn.nba.com for live game JSON, and neither is documented by the NBA. What is known about them comes from swar/nba_api, a Python package that maps them. ESPN's unofficial endpoints are a separate, free route to scores, box scores and play-by-play with shot coordinates. On 2026-10-14 ESPN's endpoints answered from our machine, while cdn.nba.com returned 403 Access Denied and stats.nba.com did not respond.

DunkAPI is a documented basketball data API and MCP server, with every tool described, a live example for each, and 500 free credits every month. It covers the NBA, the WNBA and Division I college basketball, and adds shot zones with expected points, per-sportsbook lines and Elo ratings. For a notebook on your own machine, nba_api reaches more NBA fields. For live scores, the NBA's and ESPN's feeds are the right source. For a server, a backtest or an AI agent, a documented API that runs anywhere saves the clean-up work.

The options

  • stats.nba.com

    The NBA's stats host behind nba.com: box scores, shot charts, league leaders, tracking-style tables and more. nba_api documents 135 of its endpoints.

    Not documented by the NBA. No response within 25 seconds from our machine on 2026-10-14.

  • cdn.nba.com live data

    Static JSON for live games: scoreboard, box score, play-by-play and an odds file for today's games, as documented by nba_api.

    Not documented by the NBA. All 6 requests from our machine on 2026-10-14 returned 403 Access Denied.

  • swar/nba_api

    A Python client for both hosts, with documentation for each endpoint, static player and team lists, and example notebooks. It links the NBA.com terms of use.

    MIT. Version 1.11.4 released 2026-02-20; last pushed 2026-08-16. An open issue (#678, 2026-05-27) says the live module hides 403 responses behind a misleading JSON error.

  • ESPN site API

    The endpoints ESPN's apps use: scoreboards, teams and a per-game summary with box score, plays, a win probability series and odds.

    Live. Free, no key. The summary for a 2026-04-22 game held 525 plays, each with a score and an x/y coordinate. No ESPN documentation or published terms.

  • pseudo-r/Public-ESPN-API

    Community documentation of ESPN's site and core endpoints across sports.

    MIT. Last pushed 2026-09-30. It says it is not affiliated with ESPN and that an endpoint being reachable is not permission to reuse the data.

  • BALLDONTLIE

    A paid multi-sport API with NBA, WNBA, men's and women's college basketball and many European leagues, a free tier, SDKs and an official MCP server.

    On 2026-10-14 its site listed Free at $0 a month per sport (5 requests a minute), All-Star at $9.99 (60), GOAT at $39.99 (600), and All-Access for every sport at $299.99.

Side by side

DunkAPIthe unofficial NBA endpoints
Price and key500 free credits a month, then from $19/mo; a free keyFree, no key
DocumentationEvery tool documented with parameters, response fields and a live exampleNone from the NBA. nba_api documents the endpoints it wraps; ESPN has community write-ups
Running on a serverWorks from any server, over HTTP or MCPOn 2026-10-14, cdn.nba.com returned 403 and stats.nba.com did not respond from our machine; ESPN's endpoints answered
Schema stabilityA fixed tool list, catalogued at /v1/toolsNo versioned contract. nba_api says the NBA does not announce new, changed or removed endpoints
Play-by-play and shot locationsget_plays and get_shot_chart: NBA since 2003-04, x/y for every field goal attempt, zone profiles with expected pointsESPN: plays with x/y coordinates per game, one request each. The NBA hosts: play-by-play and shot charts as documented by nba_api
Sportsbook lines4 to 12 books per regular-season game from 2013-14 to 2023-24 (10 to 12 from 2020-21), plus opening and closing lines from 6 to 8 books since July 2020An odds file for today's games on cdn.nba.com and odds in ESPN's game summary; no history seen
Ratings and modelsOur Elo and expected points per shot returned directlyRaw stats; models are yours to build
Other leaguesWNBA since 2006, Division I men's (2013-14) and women's (2014-15) college basketball, on the same toolsnba_api is built around NBA.com; check its documentation for WNBA and G League endpoints
AI assistantsMCP server for Claude, ChatGPT and CursorNone from the NBA or ESPN
Live in-game dataNo: games land the morning after, odds hourlyYes, as the NBA's and ESPN's own apps use it

Example call

Nikola Jokic's regular-season shot profile for 2025-26 (season is the year it ends), by zone with expected points. The same view from the free sources means fetching and binning shot coordinates yourself. search_players finds the player id.

bash
curl -X POST https://mcp.dunkapi.com/v1/get_shot_chart \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
  "player_id": "3112335",
  "season": 2026
}'
json
{"data": {"season": 2026, "zones": [{"zone": "restricted_area", "attempts": 288, "made": 215, "pct": 0.747, "points_per_shot": 1.493, "expected_points_per_shot": 1.141}, {"zone": "paint", "attempts": 440, "made": 255, "pct": 0.58, "points_per_shot": 1.159, "expected_points_per_shot": 0.85}, {"zone": "midrange", "attempts": 109, "made": 62, "pct": 0.569, "points_per_shot": 1.138, "expected_points_per_shot": 0.807}, {"zone": "corner_3", "attempts": 19, "made": 11, "pct": 0.579, "points_per_shot": 1.737, "expected_points_per_shot": 1.141}, {"zone": "above_break_3", "attempts": 289, "made": 102, "pct": 0.353, "points_per_shot": 1.059, "expected_points_per_shot": 1.018}, {"zone": "free_throw", "attempts": 480, "made": 399, "pct": 0.831, "points_per_shot": 0.831, "expected_points_per_shot": null}], "field_goal_attempts": 1145, "share": {"restricted_area": 0.252, "paint": 0.384, "midrange": 0.095, "corner_3": 0.017, "above_break_3": 0.252}}}

Responses are wrapped in a data object. get_shot_chart costs 10 credits; set include_shots to add each shot's x, y and result.

Use the unofficial NBA endpoints instead if

  • You are running a notebook on your own machine and want the widest set of NBA fields at no cost. nba_api reaches tracking-style tables that DunkAPI does not carry.
  • You need live, in-game scores, box scores or play-by-play. DunkAPI publishes each game the morning after it is played.
  • You are building a scoreboard or a bot and can live with endpoints that change or block you.
  • You want one vendor and one key across many sports. BALLDONTLIE is built for that; check its documentation for the fields you need.

Questions

Is there an official NBA API?

The NBA runs endpoints at stats.nba.com and cdn.nba.com that its own site uses, but it does not document them or announce changes. nba_api, a community Python package, maps them and links the NBA.com terms of use.

Is there a free NBA API?

ESPN's endpoints at site.api.espn.com are free with no key. nba_api is a free Python wrapper over the NBA's own hosts, which can block or time out. BALLDONTLIE has a free tier of 5 requests a minute for one sport. DunkAPI gives 500 free credits every month.

Where is the NBA API documentation?

The NBA publishes none. The most complete reference is the nba_api repository, which documents 135 stats endpoints and the live scoreboard, box score, play-by-play and odds files. DunkAPI's own tools are documented at /docs.

Why does the NBA API fail on a server?

Developers report that the NBA's hosts throttle or block some networks. On 2026-10-14, cdn.nba.com returned 403 Access Denied on all 6 requests from our machine and stats.nba.com did not respond. nba_api has an open issue about its live module hiding those 403s.

Where do I get NBA play-by-play with shot locations?

ESPN's game summary returns each play with a score and an x/y coordinate, one game per request. nba_api documents the NBA's own play-by-play and shot chart endpoints. DunkAPI's get_plays and get_shot_chart cover the NBA since 2003-04.

Does the NBA API have betting odds?

nba_api documents an odds file on cdn.nba.com for today's games, and ESPN's game summary carries odds. We saw no history. DunkAPI keeps sportsbook lines for NBA games from 2013-14, with opening and closing lines from 6 to 8 books since July 2020.

How much does BALLDONTLIE cost?

On 2026-10-14 its site listed a free tier at 5 requests a minute, All-Star at $9.99 a month and GOAT at $39.99 a month, each for one sport, and All-Access for all sports at $299.99 a month. Check its pricing page before you rely on those.

Can Claude or ChatGPT use DunkAPI?

Yes. DunkAPI runs an MCP server at mcp.dunkapi.com, so Claude, ChatGPT and Cursor can call the same tools as the REST API.

Sources

Checked October 14, 2026.

See the data

Try it with 500 free credits every month

No card. REST or MCP.