Skip to content

fix: add nba.com Referer header to live endpoint requests#671

Open
OnerInce wants to merge 1 commit into
swar:masterfrom
OnerInce:fix-live-cdn-referer-header
Open

fix: add nba.com Referer header to live endpoint requests#671
OnerInce wants to merge 1 commit into
swar:masterfrom
OnerInce:fix-live-cdn-referer-header

Conversation

@OnerInce
Copy link
Copy Markdown
Contributor

Summary

cdn.nba.com started returning 403 for liveData requests that don't carry an nba.com Referer header, which breaks the live endpoints (ScoreBoard, PlayByPlay, BoxScore, Odds). The stats HTTP client already sends Referer: https://www.nba.com/; this adds the same header to the live client's default headers.

Fixes #670

Change

  • src/nba_api/live/nba/library/http.py: add "Referer": "https://www.nba.com/" to the STATS_HEADERS fallback dict.

Verification

from nba_api.live.nba.endpoints import boxscore
boxscore.BoxScore("0022200720").get_dict()  # 200 again instead of 403

pytest tests/unit/live tests/unit/http passes (the 2 test_get_request_url failures are pre-existing on master — they hit the live CDN with a stale 2021 game id, unrelated to this change).

cdn.nba.com now returns 403 for liveData requests without an nba.com
Referer (ScoreBoard, PlayByPlay, BoxScore, Odds). Add it to the live
HTTP default headers, matching the stats client.

Fixes swar#670
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot get live BoxScore

1 participant