nhlpy
is an easy to use NHL API python wrapper. This wrapper was designed to be very "thin" and easy to use as it just provides helper functions that map directly to the NHL API, and it's purpose it to get you the data you need as quick as possible.
All data is returned as a python object of type dict
.
The NHL API does not require an API key to make requests so all you have to do is install this package and you can start using it!
The NHL API gives each team in the league an ID number. When working with the Team class, each instance of Team takes a team id as a parameter. For a list of known team id's please see the document team-ids.md.
golden_knights = Team(54)
print(golden_knights.info())
golden_knights = Team(54)
print(golden_knights.stats())
golden_knights = Team(54)
print(golden_knights.stats())
golden_knights = Team(54)
print(golden_knights.next_game())
nj_devils = Team(1)
print(nj_devils.last_game())
ny_rangers = Team(3)
print(ny_rangers.roster())
The game class takes a game ID as a parameter when creating an instance of the class. Tip to find a game ID: If you want to find a game ID you can go to the NHL team website of one of the teams that participated in that game, go their schedule, select the game your looking for and then copy and paste the game ID from your browser's address bar. The game ID will be the number that begins with the year of when the game took place.
Note: This returns about 30,000 lines of statistics. This is best viewed with some kind of JSON viewer.
knights_vs_jackets = Game(2017021023)
print(knights_vs_jackets.all_stats))
knights_vs_jackets = Game(2017021023)
print(knights_vs_jackets.boxscore))
Returns links to media such as pictures and videos of shots, goals, and saves.
knights_vs_jackets = Game(2017021023)
print(knights_vs_jackets.media))
conf = Conference()
print(conf.all())
eastern_conference = Conference()
print(eastern_conference.info(1))
Note: Each one of the above methods makes a request to the NHL API
- Add a license
- Add tests
- Add CI
- Add code of conduct
- Prettify the JSON or
dict
output