Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: OppTeamID parameter should be changed to OpponentTeamID for the playerGameLogs endpoint #310

Closed
FarhanSajid1 opened this issue Nov 16, 2022 · 0 comments · Fixed by #311
Labels
bug Something isn't working triage Researching into a possible bug

Comments

@FarhanSajid1
Copy link
Contributor

NBA API Version

v1.1.13

Issue

When trying to use the PlayerGameLogs api, when the opp_team_id_nullable parameter is passed in it is ignored by the nba api.

Example: Try finding all matches played for Steph Curry against the Portland Trailblazers in the 2022-23 seasons.

Currently this will output all the matches and ignore the OppTeamID parameter which is being set incorrectly.
https://github.com/swar/nba_api/blob/master/src/nba_api/stats/endpoints/playergamelogs.py#L55

This incorrect parameter roughly translates to this api request:

url = "https://stats.nba.com/stats/playergamelogs?DateFrom=&DateTo=&GameSegment=&LastNGames=&LeagueID=&Location=&MeasureType=&Month=&OppTeamID=1610612757&Outcome=&PORound=&PerMode=&Period=&PlayerID=201939&Season=2021-22&SeasonSegment=&SeasonType=&ShotClockRange=&TeamID=&VsConference=&VsDivision="

which returns 
{'parameters': {'DateFrom': None,
                'DateTo': None,
                'GameSegment': None,
                'LastNGames': None,
                'LeagueID': None,
                'Location': None,
                'MeasureType': None,
                'Month': None,
                'OppTeamID': None, <- note this is not being set
                'Outcome': None,
                'PORound': None,
                'PerMode': None,
                'Period': None,
                'PlayerID': 201939,
                'SeasonSegment': None,
                'SeasonType': None,
                'SeasonYear': '2021-22',
                'ShotClockRange': None,
                'TeamID': None,
                'VsConference': None,
                'VsDivision': None},

The correct api call is, which filters the games and returns the correct id and data

url = "https://stats.nba.com/stats/playergamelogs?DateFrom=&DateTo=&GameSegment=&LastNGames=&LeagueID=&Location=&MeasureType=&Month=&OppTeamID=1610612757&Outcome=&PORound=&PerMode=&Period=&PlayerID=201939&Season=2021-22&SeasonSegment=&SeasonType=&ShotClockRange=&TeamID=&VsConference=&VsDivision="

response

{'parameters': {'DateFrom': None,
                'DateTo': None,
                'GameSegment': None,
                'LastNGames': None,
                'LeagueID': None,
                'Location': None,
                'MeasureType': None,
                'Month': None,
                'OppTeamID': 1610612757,
                'Outcome': None,
                'PORound': None,
                'PerMode': None,
                'Period': None,
                'PlayerID': 201939,
                'SeasonSegment': None,
                'SeasonType': None,
                'SeasonYear': '2021-22',
                'ShotClockRange': None,
                'TeamID': None,
                'VsConference': None,
                'VsDivision': None},
 'resource': 'gamelogs',
 'resultSets': [{'headers': ['SEASON_YEAR',
                             'PLAYER_ID',
                             'PLAYER_NAME',
                             'NICKNAME',
                             'TEAM_ID',
                             'TEAM_ABBREVIATION',
                             'TEAM_NAME',
                             'GAME_ID',
                             'GAME_DATE',
                             'MATCHUP',
                             'WL',
                             'MIN',
                             'FGM',
                             'FGA',
                             'FG_PCT',
                             'FG3M',
                             'FG3A',
                             'FG3_PCT',
                             'FTM',
                             'FTA',
                             'FT_PCT',
                             'OREB',
                             'DREB',
                             'REB',
                             'AST',
                             'TOV',
                             'STL',
                             'BLK',
                             'BLKA',
                             'PF',
                             'PFD',
                             'PTS',
                             'PLUS_MINUS',
                             'NBA_FANTASY_PTS',
                             'DD2',
                             'TD3',
                             'WNBA_FANTASY_PTS',
                             'GP_RANK',
                             'W_RANK',
                             'L_RANK',
                             'W_PCT_RANK',
                             'MIN_RANK',
                             'FGM_RANK',
                             'FGA_RANK',
                             'FG_PCT_RANK',
                             'FG3M_RANK',
                             'FG3A_RANK',
                             'FG3_PCT_RANK',
                             'FTM_RANK',
                             'FTA_RANK',
                             'FT_PCT_RANK',
                             'OREB_RANK',
                             'DREB_RANK',
                             'REB_RANK',
                             'AST_RANK',
                             'TOV_RANK',
                             'STL_RANK',
                             'BLK_RANK',
                             'BLKA_RANK',
                             'PF_RANK',
                             'PFD_RANK',
                             'PTS_RANK',
                             'PLUS_MINUS_RANK',
                             'NBA_FANTASY_PTS_RANK',
                             'DD2_RANK',
                             'TD3_RANK',
                             'WNBA_FANTASY_PTS_RANK',
                             'VIDEO_AVAILABLE_FLAG'],
                 'name': 'PlayerGameLogs',
                 'rowSet': [['2021-22',
                             201939,
                             'Stephen Curry',
                             'Stephen',
                             1610612744,
                             'GSW',
                             'Golden State Warriors',
                             '0022100894',
                             '2022-02-24T00:00:00',
                             'GSW @ POR',
                             'W',
                             27.45,
                             5,
                             11,
                             0.455,
                             2,
                             7,
                             0.286,
                             6,
                             6,
                             1.0,
                             0,
                             5,
                             5,
                             14,
                             3,
                             1,
                             1,
                             0,
                             3,
                             3,
                             18,
                             19,
                             48.0,
                             1,
                             0,
                             43.0,
                             1,
                             1,
                             1,
                             1,
                             3,
                             3,
                             3,
                             2,
                             3,
                             3,
                             3,
                             1,
                             1,
                             1,
                             2,
                             2,
                             2,
                             1,
                             2,
                             1,
                             1,
                             1,
                             2,
                             1,
                             3,
                             1,
                             2,
                             1,
                             1,
                             2,
                             1],
                            ['2021-22',
                             201939,
                             'Stephen Curry',
                             'Stephen',
                             1610612744,
                             'GSW',
                             'Golden State Warriors',
                             '0022100376',
                             '2021-12-08T00:00:00',
                             'GSW vs. POR',
                             'W',
                             33.35,
                             8,
                             19,
                             0.421,
                             6,
                             17,
                             0.353,
                             0,
                             0,
                             0.0,
                             2,
                             0,
                             2,
                             2,
                             4,
                             1,
                             0,
                             0,
                             3,
                             2,
                             22,
                             16,
                             26.4,
                             0,
                             0,
                             34.0,
                             1,
                             1,
                             1,
                             1,
                             2,
                             2,
                             2,
                             3,
                             1,
                             1,
                             2,
                             3,
                             3,
                             3,
                             1,
                             3,
                             3,
                             3,
                             1,
                             1,
                             2,
                             1,
                             2,
                             2,
                             2,
                             3,
                             3,
                             2,
                             1,
                             3,
                             1],
                            ['2021-22',
                             201939,
                             'Stephen Curry',
                             'Stephen',
                             1610612744,
                             'GSW',
                             'Golden State Warriors',
                             '0022100290',
                             '2021-11-26T00:00:00',
                             'GSW vs. POR',
                             'W',
                             38.06666666666667,
                             12,
                             25,
                             0.48,
                             6,
                             15,
                             0.4,
                             2,
                             3,
                             0.667,
                             0,
                             7,
                             7,
                             8,
                             3,
                             1,
                             0,
                             0,
                             2,
                             1,
                             32,
                             18,
                             52.4,
                             0,
                             0,
                             55.0,
                             1,
                             1,
                             1,
                             1,
                             1,
                             1,
                             1,
                             1,
                             1,
                             2,
                             1,
                             2,
                             2,
                             2,
                             2,
                             1,
                             1,
                             2,
                             2,
                             1,
                             2,
                             1,
                             1,
                             3,
                             1,
                             2,
                             1,
                             2,
                             1,
                             1,
                             1]]}]}

Code

res = playergamelogs.PlayerGameLogs(player_id_nullable=201939, last_n_games_nullable = 5, season_nullable = "2022-23", opp_team_id_nullable=1610612757)
pprint.pprint(res.get_dict())
@FarhanSajid1 FarhanSajid1 added bug Something isn't working triage Researching into a possible bug labels Nov 16, 2022
@rsforbes rsforbes linked a pull request Nov 16, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Researching into a possible bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant