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

Get season averages for player #5

Open
gabrielfior opened this issue Nov 27, 2019 · 4 comments
Open

Get season averages for player #5

gabrielfior opened this issue Nov 27, 2019 · 4 comments

Comments

@gabrielfior
Copy link

Is it possible to get the season averages for a player (like here) through a function call? My concrete use-case would be to get season averages (points per game, if possible also shot percentage from each area of floor).

@dblackrun
Copy link
Owner

No, it would be pretty inefficient to get season totals through here (parsing the play-by-play of every game every time) rather than storing the possession and game data produced here in a database and using that for whatever you need.

@gabrielfior
Copy link
Author

Sure, to compute the averages from each player/team every time would be inefficient.
My question was if there is an automated way to get the player averages from each season, for instance from here.

Thanks!

@dblackrun
Copy link
Owner

No, this package just handles play-by-play data, if you are looking to handle some of the other api endpoints you should try one of the other python nba packages. I don't use any of them so I can't offer advice on which one is best, but I know there are multiple.

@pauldevos
Copy link

here

Gabrielfior, to do the page you listed would require n number of player API calls. You can get ALL the players season averages (or per100, totals, etc) with a single API call from this endpoint:

https://stats.nba.com/stats/leaguedashplayerstats

Provided you have a header with a referrer (now explicitly required by the stats.nba.com site) you can easily just pull this data with requests and Python.

r = requests.get(URL, header=your_header).json()

https://stats.nba.com/stats/leaguedashplayerstats?College=&Conference=&Country=&DateFrom=&DateTo=&Division=&DraftPick=&DraftYear=&GameScope=&GameSegment=&Height=&LastNGames=0&LeagueID=00&Location=&MeasureType=Base&Month=0&OpponentTeamID=0&Outcome=&PORound=0&PaceAdjust=N&PerMode=PerGame&Period=0&PlayerExperience=&PlayerPosition=&PlusMinus=N&Rank=N&Season=2019-20&SeasonSegment=&SeasonType=Regular+Season&ShotClockRange=&StarterBench=&TeamID=0&TwoWay=0&VsConference=&VsDivision=&Weight=

However, if you want someone else's API wrapper, it looks like nba_api is the most kept up and up to date one out there as nba_py looks like it's 4+ years old and may break with some of the changes made by the developers on the stats.nba.com site.

https://github.com/swar/nba_api

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

No branches or pull requests

3 participants