HFBoards

Go Back   HFBoards > General Hockey Discussion > By The Numbers
By The Numbers Hockey Analytics... the Final Frontier. Explore strange new worlds, to seek out new algorithms, to boldly go where no one has gone before.

NHL.com + Sochi 2014 Data URLs in JSON and JSONP

Reply
 
Thread Tools
Old
02-01-2014, 08:54 PM
  #1
Step7750
Registered User
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 23
vCash: 500
NHL.com + Sochi 2014 Data URLs in JSON and JSONP

Over the course of a couple days, I will be adding more info.

After going through the network traffic of NHL's services, I have compiled a list of URLs that the NHL uses to obtain stats for certain players, teams, standings, etc... Best of all, all of this data is free and does not require any sort of API Key or anything of that nature.

This data came from the network traffic of NHL.com on a PC, NHL Gamecenter App on an iPhone, and TSN's iPhone App. There is no HTML/Web scraping involved


To make the data more readable, please use www.jsonlint.com to parse it.

JSON/JSONP Data > HTML Scraping

All URLs are subject to change but based upon the previous URLs, the NHL will post the new URL when you call the old one


Team Roster:


http://nhlwc.cdnak.neulion.com/fs1/n...lubroster.json

Change the team name (ex. ANA) to the wanted team; returns most current roster

Team Schedule Per Month

http://nhlwc.cdnak.neulion.com/fs1/n...bschedule.json

Change CGY to the wanted team abbreviation, 2014 to the wanted year and 02 to the wanted month.

Player Stats for the Entire Specified Team:


ex. http://nhlwc.cdnak.neulion.com/fs1/n...statsline.json

From the Gamecenter App - Simple Structure, change the season and team as wanted

Playoff Player Stats for the Entire Specified Team:


http://nhlwc.cdnak.neulion.com/fs1/n...statsline.json

Simple Structure, change the season and team as wanted, the 3 stands for Playoffs

Stats for an Individual Player:


You can either loop through the club roster and "player stats line" URL's above or get it from TSN:

http://www.tsn.ca/mobile/bbcard.aspx...=Sidney+Crosby

XML Data!

Just change the player name as desired.

Stats for Games:


There are a couple of URL's for this data, the most common that NHL.com uses are:

Structure: "http://live.nhle.com/GameData/" + Year (ex 20132014) + "/" + Gameid (ex 2013020821) + "/gc/" + Data Wanted (gcsb, gcbx etc...) + ".jsonp"


http://live.nhle.com/GameData/201320.../gc/gcsb.jsonp

- Updates way quicker than the data for the specified day (http://live.nhle.com/GameData/GCScor...13-01-31.jsonp) and contains Team ID's, Player's currently on the ice (gives their jersey numbers), Shots and goals for each team separated by the total or by period, current game time (in seconds in the sr listing), most recent event/play.


http://live.nhle.com/GameData/201320.../gc/gcbx.jsonp

- Recommended for in depth recent in-game plays and player stats. Contains recent events (it does not contain all of the events!), goal summary (goal scorer, assists, time, id, teams involved, type of play (you can find the alphabetical equivalents that correspond to the numbers on a script the NHL has which will be discussed below), penalty summary, and the only way to obtain the game stats for each player in the game according to their jersey number (the NHL.com Player ID is not necessary).

- For each player it includes their Assists, Goals, PIM, Plus Minus, Shots, and Time On Ice for that game


PlayByPlay.jsonp is not used by the NHL.com at this current time but contains all of the plays of the game, and goal info; I don't know whether NHL.com will continue to update it in the future.

"League Leaders" Overview Stats

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Points

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Goals

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Assists

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Plus/Minus

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Wins

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In GAA

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Save Percentage

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Shutouts

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

Team Standings:


http://app.cgy.nhl.yinzcam.com/V2/Stats/Standings

XML Data!

NHL Game Center requires an "auth" code in order to obtain team standings, this URL data is extracted from the same data and doesn't require authentication.

or TSN's Standings:

http://www.tsn.ca/datafiles/XML/NHL/standings.xml

Also XML

NHL News:


http://nhlwc.cdnak.neulion.com/fs1/n...ne/1/news.json

Player Mug Pictures


You need the id of the player in order to access this which can be obtained from their team roster:

URL: http://3.cdn.nhle.com/photos/mugs/thumb/8476822.jpg

Self explanatory, just change the ending to the desired player id.

NHL Game Calendar


http://www.nhl.com/gamecenter/en/aja...th=4&year=2011

Games on the Specified Day


http://live.nhle.com/GameData/GCScor...13-02-01.jsonp

This gives a good outlook on the games happening that day and also provides the Game ID's. Game ID explanation below!




Game ID Explained:


For its web services, each game in the NHL is assigned a GameID which is needed in order to obtain/maintain data for that game. Here are a couple examples of GameIDs and their structure:

ex. 2011020581

Year - 2011
Same Code - 02
Game Code - 0581

2012020144

Year - 2012
Same Code - 02
Game Code - 0144

2013020524

Year - 2013
Static Code - 02
Game Code - 0524

4 digits are necessary for the "Game Code" due to there being more than 999 games in a season; so if there is an extra 0 in the game code, ignore it when obtaining video highlights (significant digits).


So, the gameid would be contructed like so:

$gameid = "$year 02 $gamecode"; PHP

int gameid = year + "02" + gamecode; C++/C

var gameid = year + "02" + gamecode; JavaScript

NOTE: For Neulion's Video Highlight service (which the NHL uses to manage NHL Game Center), you use the significant digits of the Game Code specified above. So if the game code is 0815, then in the video highlight URL, it will be 815.


Neulion Highlights


This does not require the Game Center Live subscription!

NHL.com requires you to have NHL GameCenter Live in order to view highlights, but the video is just an MP4 so you can easily track it down.





UPDATE: 3/31/2014

Well, you can now find the highlight video URL really easily.

http://live.nhle.com/GameData/201320.../gc/gcgm.jsonp

Replace 2013021122 with the specified game id and 20132014 with the year of that game.

This will return the highlight id's for each video, once you have the id, go to:

http://video.nhl.com/videocenter/ser...-h&format=json

Replace 2013021122-60-h with the your highlight id.

It will look something like this:

Quote:
[**
"id":"2013021122-60-h",
"name":"Corey Crawford Save on Beau Bennett (02:00/1st)",
"trackName":"Corey Crawford Save on Beau Bennett (02:00/1st)",
"description":"Home broadcast - Chicago Blackhawks at Pittsburgh Penguins - March 30, 2014",
"image":"www/thumbs/2014/03/30/591215_es.jpg",
"bigImage":"www/thumbs/2014/03/30/591215_eb.jpg",
"publishPoint":"http://e1.cdnak.neulion.com/nhl/vod/2014/03/30/1122/2_1122_chi_pit_1314_h_discrete_PIT60_save_1_1600.m p4?eid=590676&pid=591215&gid=3000&pt=1",
"formats":"0",
"shareable":true,

"releaseDate":"2014-03-30T19:30:00.000",
"runtime":"0:14","duration":"14"
}]
Which includes everything you'll need to obtain the video source and info!







Ex. Highlight Video URL: http://e1.cdnak.neulion.com/nhl/vod/...oal_1_1600.mp4


The URL can be accessed without any credentials, let me explain the structure for the URL to view any highlight from a game.

Base URL: http://e1.cdnak.neulion.com/nhl/vod/

/2014/ - Year of the game
/01/ - Month of the game
/30/ - Day of the game
/815/ - Game code (last 3 digits of the gameid)
2_ - It is a static value, always 2
815_ - Game code (last 3 digits of the gameid)
sjs_ - Away team (San Jose Sharks)
cgy_ - Home team (Calgary Flames)
1314_ - Game season (2013 - 2014)
h_discrete_ - Static value
CGY - Home team (Calgary Flames)
475_ - Highlight ID (You can obtain this from PlayByPlay.jsonp, gcbx.jsonp, gcsb.jsonp etc...)
goal_ - Type of highlight (Goal, save, hit etc...)
1_ - I don't really know what this value stands for, it is either 1 or 2
1600 - Bitrate of the highlight (This is the only bitrate available)




Sochi 2014 Olympic Stats:





Medals for each country:


http://mapi.sochi2014.com/v1/en/olympic/medal/rating


Ice Hockey Schedule:


http://mapi.sochi2014.com/v1/en/olympic/results/IHSNR

Ice Hockey Olympic News:


http://mapi.sochi2014.com/v1/en/olym...ze=24&sport=IH

Olympic Games Schedule for Specified Day:


http://mapi.sochi2014.com/v1/en/olym...ate=2014-02-06

Just change the date parameter YYYY/MM/DD



I will update these URLs once the Olympics have begun and more data is provided.


Last edited by Step7750: 03-31-2014 at 08:33 PM. Reason: Fixed/Added Some Info
Step7750 is offline   Reply With Quote
Old
02-02-2014, 09:38 AM
  #2
Chalupa Batman
Mod Supervisor
 
Chalupa Batman's Avatar
 
Join Date: Sep 2005
Posts: 21,927
vCash: 500
Very interesting stuff!

For hockeygoalies.org, I've always pulled all of my data by hand, just because I've seen enough errors in the data to cause me doubt.

I'd still love to learn more about how to automate the process.

Chalupa Batman is offline   Reply With Quote
Old
02-02-2014, 06:30 PM
  #3
Step7750
Registered User
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 23
vCash: 500
Quote:
Originally Posted by Chalupa Batman View Post
Very interesting stuff!

For hockeygoalies.org, I've always pulled all of my data by hand, just because I've seen enough errors in the data to cause me doubt.

I'd still love to learn more about how to automate the process.
Wow, I give you massive credit for doing that all manually.

You could create a PHP Server Side script that runs once a day/week/hour etc.. that checks the roster of the teams that played that day (or every single team roster) and get the stats of the goalies. You would then put that data into a MySQL database that your web page would gather info from when a user visits it.

You would have to tweak your website though since in order to extract data from MySQL, you would have to use a server side language like PHP which would then "echo" the tables with the stats.

PHP Example:




This PHP script generates a live scoreboard image based upon the parameters "gameid" and "date" on the url. It finds the team names, score, shots, plays, and logos, generates it and presents it to the user every single time the page is reloaded. Unlike HTML, it is impossible to see the source code of PHP since it runs server side. PHP files can also generate HTML documents pretty easily so it shouldn't be too much of a task.

ex.

Code:
<html> 
 <title>Calgary Flames Goalie Stats</title>
 <body>
 <h1>CALGARY FLAMES GOALTENDING HISTORY: YEAR-BY-YEAR</h1>

 <?php
 // PHP Code:
 // Extract the data from your database and generate the appropriate tables with the data
 ?>
 
 </body>
 </html>

To avoid the website reloading when going to a new page, you can use an AJAX call to post and receive the data from a PHP script. Efficiency

Ex. http://stackoverflow.com/questions/1...all-php-script (or) http://www.w3schools.com/php/php_ajax_database.asp

PHP is a pretty simple language, here is W3 Schools tutorial: http://www.w3schools.com/php/default.asp

This forum (vBulletin) is based off of MySQL and PHP

There are some other ways to do this, but a MySQL database would be your best bet.


Last edited by Step7750: 02-02-2014 at 06:40 PM.
Step7750 is offline   Reply With Quote
Old
02-02-2014, 09:42 PM
  #4
Kane One
Global Moderator
vBookie Bookie
 
Kane One's Avatar
 
Join Date: Feb 2010
Location: Brooklyn, New NY
Country: United States
Posts: 25,762
vCash: 3100
Yep, PHP + MySQL is the only way to go.

__________________
++++++++++[>+++++++>++++++++++>+++>+<<<<
-]>++++++.>+.+++++++++++++++.>+++++++++.<-.
>-------.<<-----.>----.>.<<+++++++++++.>-------------
-.+++++++++++++.-------.--.+++++++++++++.+.>+.>.

NHL Standings Under Different Point Systems
Kane One is offline   Reply With Quote
Old
02-02-2014, 09:50 PM
  #5
Chalupa Batman
Mod Supervisor
 
Chalupa Batman's Avatar
 
Join Date: Sep 2005
Posts: 21,927
vCash: 500
I do PHP/MySQL on my database side of things. Part of the downside of creating my site in 1994 was that I continued to update the page incrementally, so by the time I went to "databaseize" it, it took me more than two years.

I still need a lot of practice pulling things down from other websites, though. That's next on the old Doug's new trick list.

Chalupa Batman is offline   Reply With Quote
Old
02-03-2014, 09:31 AM
  #6
hatterson
Global Moderator
 
hatterson's Avatar
 
Join Date: Apr 2010
Location: North Tonawanda, NY
Country: United States
Posts: 10,908
vCash: 874
Send a message via Skype™ to hatterson
Personally I'd roll SQL Server and asp.net MVC/Razor/C# but to each their own

__________________
2013/2014 NHL suspensions tracker - Here
2013/2014 Maple Leafs Prediction Contest Last 2 Games - 2013/04/10 @ Florida Panthers & 2013/04/12 @ Ottawa Senators
Come join us on the By The Numbers forum. Take a look at our introduction post if you're new. If you have any questions, feel free to PM me.
hatterson is online now   Reply With Quote
Old
02-07-2014, 05:03 PM
  #7
Fever
Rookie User
 
Join Date: Feb 2014
Posts: 1
vCash: 500
Me also PHP/MySQL..

Does anyone know much about this JSON data from NHL? Is it for their own GameCenter Live website and their apps?

They dont provide any documentation or anything ... I was just looking for a game result json feed but I guess if you use the gamecenter json you can iterate through and get the results that way.

Edit... Just saw this in the first post:
http://live.nhle.com/GameData/GCScor...13-02-01.jsonp

This is awesome!!


I have a really good use for this data once I figure it out!


Last edited by Fever: 02-07-2014 at 05:08 PM.
Fever is offline   Reply With Quote
Old
02-07-2014, 11:18 PM
  #8
Step7750
Registered User
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 23
vCash: 500
Quote:
Originally Posted by Fever View Post
Me also PHP/MySQL..

Does anyone know much about this JSON data from NHL? Is it for their own GameCenter Live website and their apps?

They dont provide any documentation or anything ... I was just looking for a game result json feed but I guess if you use the gamecenter json you can iterate through and get the results that way.

Edit... Just saw this in the first post:
http://live.nhle.com/GameData/GCScor...13-02-01.jsonp

This is awesome!!


I have a really good use for this data once I figure it out!
This is the raw data for their NHL GameCenter Website/App services, there is no documentation (unless you worked on the infrastructure) but if you don't understand what a certain attribute means, feel free to ask; shouldn't take too long for me to analyze.

Remember that the URL you linked above is in JSONP and thus needs the "loadScoreboard(***DATA***)" to be removed in order to parse it as JSON.

You use PHP, so here is how you convert the JSONP to JSON:

PHP Code:
$dayscores "http://live.nhle.com/GameData/GCScoreboard/" $gamedate ".jsonp";
$rawscores file_get_contents($dayscores);
// Convert JSONP to JSON
$rawscores preg_replace('/.+?(**.+}).+/','$1',$rawscores);
$rawscores json_decode($rawscorestrue); 
To get more data for a specific game as well as more up to the second updated stats, use gcsb.jsonp or some of the other URLs listed.

PHP Code:
$scoresraw "http://live.nhle.com/GameData/20132014/" $gameid "/gc/gcsb.jsonp";
$gamestats file_get_contents($scoresraw);
$gamestats preg_replace('/.+?(**.+}).+/','$1',$gamestats);
$gamestats json_decode($gamestatstrue); 


Last edited by Step7750: 02-07-2014 at 11:56 PM. Reason: Added Info
Step7750 is offline   Reply With Quote
Reply

Forum Jump


Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -5. The time now is 11:08 AM.

monitoring_string = "e4251c93e2ba248d29da988d93bf5144"
Contact Us - HFBoards - Archive - Privacy Statement - Terms of Use - Advertise - Top - AdChoices

vBulletin Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
HFBoards.com is a property of CraveOnline Media, LLC, an Evolve Media, LLC company. 2014 All Rights Reserved.