Everything about Third Party and Add-ons Programs; request, support, suggestions, etc / Tout ce qui touche les programmes tiers: demandes, support, suggestions, etc
laving wrote: ↑Fri Nov 17, 2023 2:25 pm
I'm more interested in getting a list of player names for database creation. Back in the days I used to add all players manually to my database creation. I want something easier this time.
The API has a record limit of 100 records per page so pagination will need to be implemented. Judging by the total field at the bottom of each JSON object returned, 734 players have played at least 1 NHL game this season. If you need help extracting and parsing this information, let me know.
You're speaking a language that I don't understand buddy. I was able to follow the instructions higher up in this thread, but my understanding stops there.
laving wrote: ↑Fri Nov 17, 2023 2:25 pm
I'm more interested in getting a list of player names for database creation. Back in the days I used to add all players manually to my database creation. I want something easier this time.
The API has a record limit of 100 records per page so pagination will need to be implemented. Judging by the total field at the bottom of each JSON object returned, 734 players have played at least 1 NHL game this season. If you need help extracting and parsing this information, let me know.
You're speaking a language that I don't understand buddy. I was able to follow the instructions higher up in this thread, but my understanding stops there.
I wrote the script in Python, but since I don't know how to script in Powershell I used ChatGPT to convert it into a Powershell script. This works when I run it only my machine. It creates a CSV of the 748 to-date that have played in at least one NHL game this season. It only returns the player id and full name right now.
The API has a record limit of 100 records per page so pagination will need to be implemented. Judging by the total field at the bottom of each JSON object returned, 734 players have played at least 1 NHL game this season. If you need help extracting and parsing this information, let me know.
You're speaking a language that I don't understand buddy. I was able to follow the instructions higher up in this thread, but my understanding stops there.
I wrote the script in Python, but since I don't know how to script in Powershell I used ChatGPT to convert it into a Powershell script. This works when I run it only my machine. It creates a CSV of the 748 to-date that have played in at least one NHL game this season. It only returns the player id and full name right now.
The API has a record limit of 100 records per page so pagination will need to be implemented. Judging by the total field at the bottom of each JSON object returned, 734 players have played at least 1 NHL game this season. If you need help extracting and parsing this information, let me know.
You're speaking a language that I don't understand buddy. I was able to follow the instructions higher up in this thread, but my understanding stops there.
I wrote the script in Python, but since I don't know how to script in Powershell I used ChatGPT to convert it into a Powershell script. This works when I run it only my machine. It creates a CSV of the 748 to-date that have played in at least one NHL game this season. It only returns the player id and full name right now.
# API call to determine how many pages
$response = Invoke-RestMethod -Uri "https://api.nhle.com/stats/rest/en/skater/summary?isAggregate=false&isGame=false&sort=[{%22property%22:%22points%22,%22direction%22:%22DESC%22},{%22property%22:%22playerId%22,%22direction%22:%22ASC%22}]&start=0&limit=100&factCayenneExp=gamesPlayed%3E=1&cayenneExp=gameTypeId=2%20and%20seasonId%3C=20232024%20and%20seasonId%3E=20232024" -Method Get
$count = $response.total
$pages = [math]::ceiling($count / 100)
# Loop through pages
$players = @()
for ($i = 0; $i -lt $pages; $i++) {
$urlPaged = "https://api.nhle.com/stats/rest/en/skater/summary?isAggregate=false&isGame=false&sort=[{%22property%22:%22points%22,%22direction%22:%22DESC%22},{%22property%22:%22playerId%22,%22direction%22:%22ASC%22}]&start=0&limit=$($i * 100)&factCayenneExp=gamesPlayed%3E=1&cayenneExp=gameTypeId=2%20and%20seasonId%3C=20232024%20and%20seasonId%3E=20232024"
$responsePaged = Invoke-RestMethod -Uri $urlPaged -Method Get
$data = $responsePaged.data
foreach ($d in $data) {
$players += [PsCustomObject]@{
playerId = $d.playerId
skaterFullName = $d.skaterFullName
}
}
}
# Export data to CSV
$players | Export-Csv -Path 'skater_info.csv' -NoTypeInformation
Do you think you could adapt it so it create a file with every id? not just NHL games played?
I figured the file would be insanely huge, but updating it in STHS would discard players not created, and update every single players, even those in the farm, right?