npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nhl-api/client

v3.1.4

Published

Async request wrapper around the [NHL API](https://statsapi.web.nhlApi.com/api/v1).

Downloads

17

Readme

@nhl-api/client

Async request wrapper around the NHL API.

Usage

import nhlApi from "@nhl-api/client";

nhlApi.getTeams({ name: "boston bruins" }).then(data => console.log(data));

nhlApi
  .getPlayer({
    name: "wayne gretzky",
    stats: "statsSingleSeason",
    season: "19841985"
  })
  .then(data => console.log(data));

API

getTeams(options?)

Gets either a list of all teams, or individual team data.

By default, it returns a list of all NHL teams.

nhlApi.getTeams(); // returns an array of team objects

You can pass in either id or name as an option to get an individual team.

nhlApi.getTeams({ id: 20 }); // calgary flames
nhlApi.getTeams({ name: "boston" }); // boston bruins
nhlApi.getTeams({ name: "caps" }); // washington capitals

// if you search for a team by location, and  that location has ever had more than 1 team, it will return an array of teams matching the query.
nhlApi.getTeams({ name: "toronto" }); // returns an array with the Maple Leafs, St. Pats, and Arenas.

Modifiers

Info.

Expand modifiers don't require the team. prefix.

nhlApi.getTeams({ id: 6, expand: "roster" }); // returns the current team roster

nhlApi.getTeams({ id: 6, expand: "schedule.next" }); // returns the next game the team plays

nhlApi.getTeams({ id: 6, expand: "schedule.previous" }); // returns the last game a team played

nhlApi.getTeams({ id: 6, expand: "stats" }); // returns current season stats and rankings

getPlayer(options)

Gets data for a specific player. Requires at least 1 option param of either the player's name or ID.

nhlApi.getPlayer({ id: 8447400 });
nhlApi.getPlayer({ name: "wayne gretzky" });
// you can also search by nickname
nhlApi.getPlayer({ name: "the great one" });

// searching by just first or last name will probably result in multiple players.
// these will be returned in an array of player objects.
nhlApi.getPlayer({ name: "gretzky" }); // returns brett and wayne

// nickname searches must be exact
nhlApi.getPlayer({ name: "ace bailey" });

Modifiers

Info.

The only modifier this endpoint accepts is stats:

nhlApi.getPlayer({
  name: "wayne gretzky",
  stats: "statsSingleSeason",
  season: "19801981"
});

Accepted stat options:

  • statsSingleSeason
  • yearByYear
  • homeAndAway
  • winLoss
  • byMonth
  • byDayOfWeek
  • vsDivision
  • vsConference
  • vsTeam
  • gameLog
  • regularSeasonStatRanking
  • goalsByGameSituation
  • onPaceRegularSeason

Every stat option (except yearByYear) also requires a season param be passed. This is an 8 digit number with both years of a season- i.e. '20192020'.

getSchedule(options?)

Gets game scheduling information.

nhlApi.getSchedule(); // by default it returns all games for the current day

Modifiers

Info.

Modifiers don't require the schedule. prefix.

nhlApi.getSchedule({ expand: "broadcasts" }); // shows game broadcasts

nhlApi.getSchedule({ expand: "boxscore" }); // boxscore for completed games

nhlApi.getSchedule({ expand: "linescore" }); // linescore for completed games

nhlApi.getSchedule({ id: 6 }); // gets today's games for a given team
nhlApi.getSchedule({ team: "bruins" }); // same as above

nhlApi.getSchedule({ date: "2019-10-27" }); // gets games for a given date

nhlApi.getSchedule({ startDate: "2019-09-30", endDate: "2019-10-14" }); // returns all games between a timeframe

// modifiers can be combined
nhlApi.getSchedule({
  team: "bruins",
  startDate: "2019-09-30",
  endDate: "2019-10-14"
}); // returns all bruins games between 9/30/19 and 10/14/19

getGame(options)

Gets data from a specified game. Requires a game ID which can be retrieved from the getSchedule call, or you can decipher the game ID yourself.

nhlApi.getGame({ id: 2019020174 }); // by default it calls the /feed/live endpoint

Modifiers

Info.

// both of these return from the /feed/live endpoint
// same as default
// contains all details from a given game
nhlApi.getGame({ id: 2019020174, type: "feed" });
nhlApi.getGame({ id: 2019020174, type: "live" });

nhlApi.getGame({ id: 2019020174, type: "boxscore" }); // post-game details

nhlApi.getGame({ id: 2019020174, type: "linescore" }); // less-detailed post-game details

nhlApi.getGame({ id: 2019020174, type: "content" }); // returns media related to game

getGameTypes()

Info.

getPlayTypes()

Info

getPlayoffs(options?)

Returns several playoff-specific details.

nhlApi.getPlayoffs(); // returns default playoff structure info

Info.

getSeasons(options?)

Info.

getStandings(options?)

Returns standings broken up by division

nhlApi.getStandings();

Modifiers

Info

nhlApi.getStandings({ season: "19911992" }); // standings for specific season

nhlApi.getStandings({ date: "2019-09-30" }); // standings for a given day

nhlApi.getStandings({ expand: "record" }); // gives detailed individual team info

You can use the getStandingsType() call to retrieve types to query standings by.

nhlApi.getStandings({ type: "wildCardWithLeaders", date: "2019-01-01" }); // returns complete wildcard standings for a given day

getStandingsTypes()

Returns standings types to use with getStandings().

nhlApi.getStandingsTypes(); // returns an array of all types

Info.

getDraft(options?)

Get round-by-round draft data for a given year

nhlApi.getDraft(); // returns current year by default

nhlApi.getDraft({ year: "1985" }); // returns draft for a given year

Info.

getProspects(options?)

Info

nhlApi.getProspects(); // returns a full list of prospects

nhlApi.getProspect({ id: 53727 }); // returns an individual prospect

Note: the name param cannot be used here, there's no database of all draft prospects to query.

getAwards(options?)

Info

nhlApi.getAwards(); // returns all NHL awards
nhlApi.getAward({ id: 1 }); // returns individual award

getVenues(options?)

Info

nhlApi.getVenues(); // returns all venues
nhlApi.getVenues({ id: 5064 }); // returns individual venue

getDivisions(options?)

Info

nhlApi.getDivisions(); // returns all divisons
nhlApi.getDivisions({ id: 17 }); // returns individual division

getConferences(options?)

Info

nhlApi.getConferences(); // returns all conferences
nhlApi.getConferences({ id: 5 }); // returns individual conferece

Props

All this made possible by Drew Hynes' NHL API Documentation.

Contributing

Please open an issue if you find anything incorrect / out-of-date / not working, etc.


built with skeletor 💀