Sourcing

Just a warning before I go over all my data. I'm not a expert in this field this is simply something I did for fun not all of the info/data that I show is not neccesarily going to be 100% right if you notice anything that is wrong let me know and I'll try to look at it and fix it.

I'm going to be as transparent as possible for every step of the way on the data sourcing as I find this to be somewhat difficult to find if you are new to looking for data on the NHL. I'll be going over the sources for both the methods I used to calculate the data and the sources for the data itself.

For the game info and live game scores I used the following API https://api-web.nhle.com/v1/ this is an official NHL API though for the public this is undocumented which makes it difficult to find the data you are looking for. Though it is undocumented there are many people who have done the work to find the endpoints and I will be linking to their work here. This API is quite useful as it has a lot of data that you can pull from which is great for getting the data you need. I used this API along side a cloudflare worker to send requests to the API and then return the data to my site. This is a great way to get around CORS issues and allows you to get the data you need without having to worry about CORS.

Any historical data that I may or may not have used is simply downloaded from nhl.com where I then compile the data to be used. This is helpful in case of any updates to the API that may break the data I am using. I will be updating this data as often as I can but issues will most likely be a problem at the end of seasons when there is no games going on.

Game Odds

For this section I'll mainly be going over the method I have for winning percentage and why I think it partially works.

These odds are not live odds I intend to make some calculation based on time remaining and scores but as of the moment I am not going to be going ahead with that as its a work in progress and I would like to get a good idea on how to do it before I go ahead and do it so I can test with previous data to see how accurate it is.

Though for the moment I'll go over the current system I have for calculating the initial odds as it is quite simple and could use a little bit of tweaking. Right now historically there are many factors that go into a teams winning percentage. I am diving into the first few factors that I think are the most important. The first factor that I believe to be important and so does many others is the current point percentage of the teams. This is not as relevant early in the season as teams have fewer games played but as the season progresses this becomes more and more relevant showing the teams current form. I find the difference in point percentage between the two teams and multiply by a set number to add to find the odds.

The next factor I have included is home ice advantage, historically teams with home ice advantage have a higher chance of winning the game so I include this in my calculations.

Lastly one of the most important factors is back to back games. Inversely to home ice advantage, teams that are playing back to back games have a 54%~ chance of losing the game so I include this in my calculations as well.

There are definitely some better stats that I can work on adding such as starter goalies with some teams who have a clear starter and backup goalie making a big impact on the team. Additionally there are other factors like team injuries and other factors that I can work on adding in the future but at the current moment I find that these stats though quite simple produce a good result. I will work on adding more stats in the future but for now I am happy with the results I am getting.

Draft Lottery Odds

The draft lottery is confusing so I will attempt to break it down as best as I can here.

The draft lottery is a system used by the NHL to determine the order of selection for the first 16 picks of the NHL draft. The lottery is held at the end of the regular season to ensure that the teams that did not make the playoffs have a chance to select the best players available in the draft. The reason it is called a lottery is because two teams have the chances of winning the lottery and moving up in the draft order there are a few rules I will go over.

  • Only 2 picks are determined by the lottery pick 1 and 2.
  • A team cannot move up more than 10 spots from their standing position.
  • A team cannot win the lottery more than twice in a five year span (The oiler rule for being so bad and lucky).
  • On the occasion a team 12-16 wins they will move up a max of 10 spots and the worst team retains the pick that is drawn.
  • The second draft lottery pick can move up a maximum of 10 spots from the reseeded order after the first pick.
Basically if I were to break it down as simple as I can pick 1 and 2 are decided by the ping pong ball lottery and the rest of the picks are decided by the standings.

The issue with this is when teams lower 12-16 win this makes it a bit more confusing so lets say the following happens

  • 14th worst team wins draft lottery
  • 13th worst team wins second draft lottery

In this case the 14th team would move up to 4th overall and you would think the 13th team would move up to 3rd overall since they move up 10 spots but that isnt the case. The 14th team got 4th overall and the worst team gets the 1st overall pick those two are locked in right away off the first draw but on the second draw once the 13th team wins they move up 10 positions in the RESEEDED order of the draft which means the 13th team would move to 4th overall but since that pick has already been taken they actually move to 5th overall.

This scenario is my biggest dislike about the draft lottery because I feel like its somewhat pointless to add in that they move up 10 spots in the reseeded order but it probably is just bothering me since I had to code a few extra things.

How I coded this

Maybe the more interesting part besides the way the draft lottery is done is how I coded it though its not neccesarily the most exciting process. First I had to get an official drawing number from the nhl website this is for the 2023-2024 season and I will update if anything changes in the future. I scraped the numbers for each ball and team names and compared them to the standings for that year. Once I had that I was able to replace the team names with their respective standings so I can just interchange the team names with the current standings since they are not the same as last year. All that is left is to use a random number generator to pick the balls and I can use a lookup function to find the team that will move up in the draft order.

Though it is a pretty boring process it is quite simple and I like how it looks plus I use this to see how the draft lottery would look if it were to happen today.

The rest of the code is mainly just visual stuff to make it look nice the API I used to get the current standings is linked here it should be fairly easy to figure out how to replicate this if you put any thought into it especially with all the info I have included here.

Player Stats

This was fairy quick to make and probably my favourite type of table to produce I'll go through the entire process of making this and it should be fairly easy to replicate if you are interested. I used the an API to get the player stats from the NHL for the current season as of writing this its the 2024-2025 season though I have my cloudflare worker set to change to the 2025-2026 season when that arrives so I wont have to manually change the year. I used this API call https://api.nhle.com/stats/rest/en/skater/summary?cayenneExp=seasonId=20242025 and teamAbbrevs='CGY'. This will allow you to filter down to the team you want to look at assuming you have the right abbreviation for that team, all of this is covered in the API documentation I linked above.

Besides using that and a cloudflare worker to get around CORS issues I simply got the percentiles of each player for every stat and fed that through to a table to display the data. I used a calculation to essentially conditional format the cells to change the color of the cell based on their performance in each stat. Besides visual work it was fairly simple to setup and I am happy with what I see it should be fairly easy to replicate if you are interested in doing so.

Playoff Odds

Not implemented yet but I will be adding this soon.

Playoff Bracket

This section does not really go over any statistics but its just a fun little tool I made to help you see the playoff bracket and how it would look if the playoffs started today. This is just a fun little tool I made to help you see the playoff bracket and how it would look if the playoffs started today. I really like the way that brackets look on websites and sometimes I struggle to find a site that displays the bracket in a way that I like. So I made this little tool to help you see the playoff bracket and how it would look if the playoffs started today. As for data this section uses the NHL API to get the current standings and then uses that data to display the bracket.