@nhl/api v0.0.0-ca3c6aa
NHL API Node.js Library
The NHL Node library provides convenient access to the Records and Stats API from applications written in server-side JavaScript.
This is an unofficial, Fan-made project, built for learning and discovery purposes of the exposed NHL APIs. Copyrights and Trademarks belong to their respective organization.
NHL and the NHL Shield are registered trademarks of the National Hockey League. NHL and NHL team marks are the property of the NHL and its teams. © NHL 2021. All Rights Reserved.
Table of Contents
- Installation
- Technical Prologue
- Usage
Medal.categories
Medal.latest()
Medal.search()
Medal.trending()
- Global Options
- Example
- Async/Await Example
Installation
You can add the library as a dependancy to your project using Yarn or NPM.
yarn add @nhl/api
# OR
npm install @nhl/api
Technical Prologue
This library is built by extending the functionality (and types) of the axios HTTP client library. It does the heavy lifting for you but it effectively is axios
at it's core. This means you should find success in both browser and node environments, however server-side (Node.js) is the intended usage of the library and browser-specific bugs may not be prioritzed.
Usage
The entire API appears to be unauthenticated and can be consumed without the need for an access token of any sort.
JavaScript Example:
import { nhl } from '@nhl/api';
// Promises
nhl.positions.retrieve().then(response => {
console.log(response.data)
})
// Async/Await
async function () {
const response = await nhl.positions.retrieve()
console.log(response.data)
}
[
{
abbrev: 'G',
code: 'G',
fullName: 'Goalie',
type: 'Goalie',
},
{
abbrev: 'D',
code: 'D',
fullName: 'Defenseman',
type: 'Defenseman',
},
{
abbrev: 'RW',
code: 'R',
fullName: 'Right Wing',
type: 'Forward',
},
{
abbrev: 'LW',
code: 'L',
fullName: 'Left Wing',
type: 'Forward',
},
{
abbrev: 'C',
code: 'C',
fullName: 'Center',
type: 'Forward',
},
{
abbrev: 'N/A',
code: 'N/A',
fullName: 'Unknown',
type: 'Unknown',
},
{
abbrev: 'Head Coach',
code: 'HC',
fullName: 'Head Coach',
type: 'Coach',
},
];
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago