Skip to content

Conversation

@brandonhawi
Copy link
Contributor

@brandonhawi brandonhawi commented Dec 3, 2025

Summary

Fixes #602

This PR resolves the issue where get_normailized* methods return empty values.

Notebook Demonstrating Fix

Open In Colab

Root Cause:

  • The normalization logic in NBAStatsResponse.get_normalized_dict() only checked for legacy format keys
  • V3 endpoints don't have these keys - they require custom parsers to extract data
  • When neither resultSets nor resultSet was found, the method returned an empty dictionary
  • This made normalized methods unusable for all V3 endpoints

Solution

Added V3 endpoint support to the normalization pipeline in src/nba_api/stats/library/http.py:

  1. Endpoint tracking: Store the endpoint name in NBAStatsResponse._endpoint when get_data_sets() is called, providing
    context for normalization
  2. V3 normalization logic: Extended get_normalized_dict() to detect V3 endpoints and:
  • Import and use the appropriate custom parser via get_parser_for_endpoint()
  • Extract data sets from the parsed response
  • Convert parsed V3 data into the same normalized format as legacy endpoints (list of dictionaries with header-mapped
    keys)
  • Gracefully fall back to empty dict if parser isn't found
  1. Backward compatibility: Legacy endpoints continue to work exactly as before - the V3 logic only activates when an
    endpoint is stored

Testing

Created new unit tests and all existing tests pass.

Add support for V3 endpoints with custom parsers in get_normalized_dict()
and get_normalized_json() methods. Previously, these methods only handled
legacy format (resultSets/resultSet) and returned empty dictionaries for
V3 endpoints like BoxScoreTraditionalV3.

Changes:
- Store endpoint name in NBAStatsResponse when get_data_sets() is called
- Update get_normalized_dict() to use parser for V3 endpoints
- Convert parsed V3 data to normalized format (list of dicts)
- Add comprehensive unit tests for normalized methods

Fixes swar#602
Remove all inline comments and docstrings from the V3 endpoint normalization
implementation and associated unit tests to improve code readability and
reduce clutter.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._endpoint = None

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the intention behind self._endpoint?

@swar
Copy link
Owner

swar commented Jan 9, 2026

Overall this code seems fine. We'll just want test it out and ensure it's working. I do have a comment in the code as I'm trying to understand the need for adding _endpoint in the instantiation

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.

[Bug]: Endpoint BoxScoreTradtionalv3 & v2 returns a blank value when using the get_normalizied_(x) function.

2 participants