nhlapi
nhlapi copied to clipboard
Stats beyond the skater summary?
Do you have an idea how to query to include stats like face off wins and takeaways by player? I can only find them in the game/boxscore endpoint. Thanks! This documentation is fantastic!
Unfortunately I've yet to find where this information is accessed in this API, however there is a second one that drives the advanced stats and reports available from the NHL website. I haven't managed to really get much from it yet however, but a good start would be to check out http://www.nhl.com/stats/rest/skaters?isAggregate=false&reportType=basic&isGame=false&reportName=skatersummary&sort=%5B%7B%22property%22:%22points%22,%22direction%22:%22DESC%22%7D%5D&cayenneExp=gameTypeId=2%20and%20seasonId=20162017 and then see if you can figure out how to make it show the correct report type which I haven't had any luck on yet
Thanks for the tip. With a little intuition I was able to make your suggestion work! Just switched out the reportName parameter of the rest api for what is shown as the report parameter in the URL of the NHL stats web page for the report selection you want. You'll need to update the sort parameters or remove them altogether. Examples below.
Face off report: http://www.nhl.com/stats/rest/skaters?isAggregate=false&reportType=basic&isGame=false&reportName=faceoffs&cayenneExp=gameTypeId=2%20and%20seasonId=20162017
Hits, blocks, takeaways, etc. http://www.nhl.com/stats/rest/skaters?isAggregate=false&reportType=basic&isGame=false&reportName=realtime&sort=[{%22property%22:%22hits%22,%22direction%22:%22DESC%22}]&cayenneExp=gameTypeId=2%20and%20seasonId=20162017
SAT percentages: http://www.nhl.com/stats/rest/skaters?isAggregate=false&reportType=basic&isGame=false&reportName=skaterpercentages&cayenneExp=gameTypeId=2%20and%20seasonId=20162017 EDIT: just noticed this one doesn't work - returns only basic player data.
I suspect all different reports on the web site are available through the rest api using this method.
Thanks again!
Here we go. SAT percentages: http://www.nhl.com/stats/rest/skaters?isAggregate=false&reportType=shooting&isGame=false&reportName=skaterpercentages&cayenneExp=gameTypeId=2%20and%20seasonId=20172018
Needed to change the reportType parameter as well as the reportName. Hat tip to one of the responders in your reddit thread about a month ago.
Awesome, think I'm going to have to start another document to cover this advanced stats API section, its a lot more flexible than the other API which seems more for game data than anything else.
I also found this repo which may help with understanding how to query the NHL REST API: https://github.com/nhl/link-rest
It doesn't document the NHL specific endpoints and parameters, but there is documentation on the framework used in the API. I haven't had a chance to look closely.
Currently trying to figure out how to aggregate a game by game report and sum the last x number of days for a report as you can from the web site. Not much success so far.