Skip to content

[Bug]: Parsing Win Probability PBP endpoint #646

@caseta

Description

@caseta

NBA API Version

v1.11.4

Issue

👋 hello hi - attempted to use this endpoint and was having an issue. Had Cursor give me an analysis / summary below. Maybe the endpoint is just dead / not supported?

WinProbabilityPBP endpoint returns non-JSON payload (JSONDecodeError)

Summary

nba_api fails to parse responses from WinProbabilityPBP because the endpoint is returning a non-JSON error payload instead of expected JSON result sets.

This reproduces across multiple valid game IDs and raises json.decoder.JSONDecodeError.


Environment

  • nba_api version: 1.11.4
  • Python: 3.11.x
  • OS: macOS (darwin)

Endpoint

  • Class: nba_api.stats.endpoints.winprobabilitypbp.WinProbabilityPBP
  • URL shape:
    • https://stats.nba.com/stats/winprobabilitypbp?GameID=<GAME_ID>&RunType=each+second

Reproduction

from nba_api.stats.endpoints import winprobabilitypbp

for gid in ["0022500855", "0022300061", "0021700807"]:
    print("testing", gid)
    endpoint = winprobabilitypbp.WinProbabilityPBP(
        game_id=gid,
        run_type="each second",
    )
    data = endpoint.get_normalized_dict()
    print("ok", list(data.keys()), len(data.get("WinProbPBP", [])))

Actual result

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Expected result

Successful JSON parsing with datasets such as GameInfo and WinProbPBP (or equivalent normalized dict output).


Additional diagnostics

Using nba_api low-level HTTP internals (NBAStatsHTTP) for the same endpoint request shows raw response text that is not JSON. The response begins with:

Sap.Data.Hana.HanaException (0x80004005): Connection failed (RTE:[89013] Socket closed by peer ...

This indicates the failure is upstream/non-JSON response content, not only a JSON parser issue.


Notes

  • Reproduced with multiple game IDs (including a historical example game ID).
  • Other NBA stats endpoints can still work in the same runtime, so this appears endpoint-specific (or endpoint/backend-path specific).
  • Requesting guidance on whether this is:
    • a known upstream issue for winprobabilitypbp,
    • a transient service issue,
    • or something nba_api should handle with clearer error reporting.

Suggested improvement

If possible, nba_api could surface a clearer exception when non-JSON responses are returned (including a short response prefix), rather than only raising JSONDecodeError.

Code

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageResearching into a possible bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions