swar / nba_api

An API Client package to access the APIs for NBA.com
MIT License
2.34k stars 515 forks source link

Question: How to find an endpoint that is used to populate a page? #412

Closed msimoni18 closed 7 months ago

msimoni18 commented 7 months ago

I'm trying to find the endpoint that is used to populate https://www.nba.com/stats/players/passing because I'm interested in potential assists. The comment in #151 says that leaguedashptstats is used. That endpoint doesn't seem to give anything close to what is in the table.

What do I need to look for in the Network tab of Chrome to determine what endpoint is being used?

Here's the code and columns that come from that endpoint:

leaguedashptstats = nba.leaguedashptstats.LeagueDashPtStats()
leaguedashptstats_df = leaguedashptstats.get_data_frames()[0]
print(leaguedashptstats_df.columns)
Index(['TEAM_ID', 'TEAM_ABBREVIATION', 'TEAM_NAME', 'GP', 'W', 'L', 'MIN',
       'DIST_FEET', 'DIST_MILES', 'DIST_MILES_OFF', 'DIST_MILES_DEF',
       'AVG_SPEED', 'AVG_SPEED_OFF', 'AVG_SPEED_DEF'],
      dtype='object')
msimoni18 commented 7 months ago

Well, in typical fashion, I was able to figure out my issue shortly after posting. pt_measure_type='Passing' was necessary to get the correct table.

leaguedashptstats = nba.leaguedashptstats.LeagueDashPtStats(last_n_games=0, opponent_team_id=0, per_mode_simple='PerGame', player_or_team='Player', pt_measure_type='Passing')
leaguedashptstats_df = leaguedashptstats.get_data_frames()[0]
print(leaguedashptstats_df.columns)
Index(['PLAYER_ID', 'PLAYER_NAME', 'TEAM_ID', 'TEAM_ABBREVIATION', 'GP', 'W',
       'L', 'MIN', 'PASSES_MADE', 'PASSES_RECEIVED', 'AST', 'FT_AST',
       'SECONDARY_AST', 'POTENTIAL_AST', 'AST_POINTS_CREATED', 'AST_ADJ',
       'AST_TO_PASS_PCT', 'AST_TO_PASS_PCT_ADJ'],
      dtype='object')