published fresh until

Why do my nba_api calls time out or return an HTML error page?

Summary If stats.nba.com calls time out or return an HTML error page with HTTP 200, note that cdn.nba.com live JSON kept working in the reported cases. Header changes, browser-like TLS with a warm-up, and other IPs had mixed results.

Not for Stripe or other API timeouts; fantasy platform league data

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

You build an NBA stats or fantasy-basketball tool with an agent and the data layer is nba_api. Requests hang until Read timed out, or fail with JSONDecodeError: Expecting value, often right after working fine. Agents then guess: longer timeouts, retries, new versions.

What users reported in the issue tracker

Project: swar/nba_api (MIT). It wraps NBA.com's unofficial stats endpoints, which are undocumented and can change; one commenter notes they were not meant for public developer use.

  • March 2026, issue "NBA Api timeout" (open, checked 2026-11-14): all stats requests started timing out on 12 March. One user said adding browser-like headers fixed it (Host, Connection, Accept, User-Agent, Referer: https://www.nba.com/, Origin: https://www.nba.com, x-nba-stats-origin: stats, the x-nba-stats-token header set to true, Accept-Language) and passed them via the endpoint's headers= argument; another confirmed it worked, others said it did not. Reports from 19 March and 7 April say the headers did not help them, and a 13 May commenter says the header workaround had stopped working; a 4 June commenter said the headers did work for them.
  • May 2026, same issue: one commenter wrote that NBA's bot protection now also checks the TLS fingerprint, so plain Python requests times out even with the right headers. Their fix: curl_cffi with impersonate="chrome120", a warm-up request to https://www.nba.com/stats/ for cookies, and replacing the session nba_api uses. A later user said that did not work for them but the header approach did. So: neither fix is reliable.
  • Older pattern (issue from 2022 to 2023, still open, checked 2026-11-14): /stats endpoints time out in production on AWS while working locally, and /live endpoints on cdn.nba.com work. A project contributor wrote that AWS, GCP and Heroku IP addresses are blocked by NBA, that headers cannot fix that, and that routing requests through a paid proxy (a VPN provider's proxy endpoint) let them use /stats from AWS Lambda; free proxies did not work for another user. One user said their home IP got blocked after a while and a VPN restored access.
  • 8 October 2026 (closed): a user reported every stats.nba.com/stats/* request returning HTTP 200 with Content-Type: text/html and an "unable to process your request" page from the CDN, surfacing as JSONDecodeError. Other IPs did the same. They noted cdn.nba.com liveData and staticData JSON still worked, and two days later wrote it seemed fixed.
  • Why the confusing error: another issue notes nba_api.live swallows a 403 and raises JSONDecodeError, so the real status is hidden; a pull request adding a Referer header to live requests (said to be enough for the CDN at the time) was closed in October without merging, as far as I can tell.
  • Rate limits: a commenter says cut-offs came after roughly 100 to 600 calls, with waits of an hour or more.
  • A contributor in the older issue 176 (2020) asks people to log timeouts in a shared sheet for documentation.

What to put in your agent's rules

NBA data comes from unofficial endpoints that block, throttle and change. Rules: (1) check HTTP status and content type before parsing JSON and log both; (2) set an explicit timeout and a small retry with backoff; (3) cache every response in our database and never call the API per page view; (4) run the data refresh as a scheduled job, not in the request path; (5) prefer the cdn.nba.com live and static JSON for schedules and box scores when they are enough; test from the machine where it will run, since cloud IPs may be blocked; (6) if stats.nba.com fails, serve the cached data and show its age.

Mistakes to check

  • Raising the timeout to minutes: it hides a block.
  • Hammering the API in a notebook loop; add pauses.
  • Assuming a header recipe from one month still works.
  • Deploying to a cloud host without testing a real call from that host.

Limits

This is a summary of public issue threads, not a test. I did not run any of the fixes. If you need dependable data, a licensed or documented sports-data API may be safer than these unofficial endpoints.

Sources

  • swar/nba_api issue 652, NBA Api timeout, read through the GitHub API on 19 Oct 2026. Checked: opened 12 Mar 2026 and still open on 2026-11-14; the header list and the March and April reports that it worked or did not; the 13 May comment about TLS fingerprinting, curl_cffi with chrome120, the nba.com warm-up and the session replacement (one commenter's unconfirmed explanation, which a 4 June commenter says did not work for them); the 100 to 600 call cut-off comment.
  • Issue 696, stats endpoints return an Akamai HTML error page. Checked: opened 8 Oct 2026, closed 10 Oct; HTTP 200 with text/html, JSONDecodeError, other IPs behaving the same, cdn.nba.com liveData and staticData still working, reporter later says it seems fixed.
  • Issue 320, NBA API: timeout for /stats endpoints (opened 28 Dec 2022, still open, checked 2026-11-14), issue 176, issue 678 and pull request 671. Checked: AWS timeouts with working /live endpoints, a contributor saying AWS, GCP and Heroku IPs are blocked and that a paid VPN proxy worked from Lambda, free proxies failing; live client raising JSONDecodeError on a 403 (678, open, checked 2026-11-14); the Referer-header pull request closed unmerged on 15 Oct 2026; the contributor's timeout-log request (176); a commenter saying the endpoint is undocumented and not meant for public developer use (in 678). Repo metadata: MIT.
  • Not checked: that the headers, curl_cffi or proxy fixes work today, the "Referer was enough at the time" statement in the pull request, whether NBA.com blocks the IP ranges named (contributors' statements, not NBA's), and the agent-rules prompt (the author's own). I ran nothing against NBA endpoints and did not read the other timeout issues in the tracker.

Started from a post by @swar/nba_api issue thread, packaged by the editor. Original post

Subjects

More in code review

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Why do my nba_api calls time out or return an HTML error page?
Summary: If `stats.nba.com` calls time out or return an HTML error page with HTTP 200, note that `cdn.nba.com` live JSON kept working in the reported cases. Header changes, browser-like TLS with a warm-up, and other IPs had mixed results.
Copy for agent
get the whatworks thread nba-api-stats-endpoints-time-out-or-return-html and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread nba-api-stats-endpoints-time-out-or-return-html
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp