Apr-18-2020, 02:20 PM
if you know the player's name, you can use the following API: https://suggest.svc.nhl.com/svc/suggest/...veplayers/{player_name_goes_here}/99999
that's the REST call used on the NHL's player search page (https://www.nhl.com/player)
it returns an array of "suggestions"; so using https://suggest.svc.nhl.com/svc/suggest/...arls/99999 returns the following:
{
"suggestions": [
"8474590|Carlson|John|1|0|6' 3\"|217|Natick|MA|USA|1990-01-10|WSH|D|74|john-carlson-8474590",
"8478506|Carlsson|Gabriel|1|1|6' 5\"|192|Orebro||SWE|1997-01-02|CBJ|D|53|gabriel-carlsson-8478506",
"8479523|Carlsson|Lucas|1|1|6' 0\"|189|Gävle||SWE|1997-07-05|CHI|D|46|lucas-carlsson-8479523"
]
}
what's the "99999" at the end of the url for? that's the max count of items to return; i usually just leave it huge so as not to lose any results.
if you have the full name, it should return just the single match in the results (i.e. an array of 1). then just parse the pipe-delimited text to get the player's ID and you should be able to pop that into your player REST call and you're good to go.
that's the REST call used on the NHL's player search page (https://www.nhl.com/player)
it returns an array of "suggestions"; so using https://suggest.svc.nhl.com/svc/suggest/...arls/99999 returns the following:
{
"suggestions": [
"8474590|Carlson|John|1|0|6' 3\"|217|Natick|MA|USA|1990-01-10|WSH|D|74|john-carlson-8474590",
"8478506|Carlsson|Gabriel|1|1|6' 5\"|192|Orebro||SWE|1997-01-02|CBJ|D|53|gabriel-carlsson-8478506",
"8479523|Carlsson|Lucas|1|1|6' 0\"|189|Gävle||SWE|1997-07-05|CHI|D|46|lucas-carlsson-8479523"
]
}
what's the "99999" at the end of the url for? that's the max count of items to return; i usually just leave it huge so as not to lose any results.
if you have the full name, it should return just the single match in the results (i.e. an array of 1). then just parse the pipe-delimited text to get the player's ID and you should be able to pop that into your player REST call and you're good to go.