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

open-shl

v1.1.3

Published

Node.js client for open shl api

Downloads

14

Readme

#open-shl

Node.js client for the open SHL (Swedish Hockey League) API. Developed with and for node.js 5+

Install

npm install --save open-shl

Usage

First make sure you have a valid clientId and clientSecret for the API, which can be gained by emailing [email protected]

After that, you can access the api thusly:

const shl = require("open-shl");
const options = {
    clientId: "YOUR_CLIENT_ID",
    clientSecret: "YOUR_CLIENT_SECRET",
    userAgent: "YourUserAgent" // Optional 
}
const client = shl.connect(options);

The SHL API

This client is built to mimic the API as documented on http://doc.openapi.shl.se

Many methods support extra query parameters, if they are supported in the API they can be supplied in an optional query argument as final (or only) parameter to the matching method. Most of the time this is the teamId, which is supplied as an array of three letter team codes.

client.season(season)

Parameters

  • season: int: The year the season started

Returns

  • season: The season API object

season.games([query])

Fetches all games for the season

Query Properties

  • teamIds: string[]: List of team codes of to include. Leave empty to include all teams

Returns

  • Promise<Game[]>: Promise of all games for the season

season.game(gameId)

Fetches a specific games

Parameters

  • gameId: int: Id for the game to fetch

Returns

  • Promise<Game>: The game with the specified id

season.statistics.goalkeepers([query])

Gets the top goalkeepers for the season

Query Properties

  • teamIds: string[]: List of teams to include. Leave empty to include all teams
  • sort: string: What attribute to sort on: saves|savesPercent|goalsAgainst|goalsAgainstAverage|won|tied|lost|shooutOuts|minutesInPlay

Returns

  • Promise<GoalkeeperStatistics[]>: Statistics for all goalkeepers during that season

season.statistics.players([query])

Gets the top players for the season

Query Properties

  • teamIds: string[]: List of teams to include. Leave empty to include all teams
  • sort: string: What attribute to sort the players on assists|goals|points|pim|hits|plusminus

Returns

  • Promise<PlayerStatistics[]>: Statistics for top players during that season

season.statistics.teams.standings([query])

Get current standings for that season

Query Properties

  • teamIds: string[]: List of teams to include. Leave empty to include all teams

Returns

  • Promise<TeamStandings[]>: List of all teams and their current standing

client.teams()

Get a list of all teams

Returns

  • Promise<Fact[]>: A list of basic facts for all teams in the SHL

client.team(teamCode)

Get details for a particular team.

Parameters

  • teamCode: String: is the three-character team code. i.e. "FHC" for Frölunda HC

Returns

  • Promise<Team>: All information about the requested team. Includes team facts, player facts and more

client.videos([query])

Get the ten latest videos

Query Properties

  • teamIds: string[]: List of teams to include. Leave empty to include all teams

Returns

  • Promise<Video[]>: Ten latest videos

client.articles([query])

Get the latest articles

Query Properties

  • teamIds: string[]: List of teams to include. Leave empty to include all teams

Returns

  • Promise<Article[]>: Ten latest articles

Examples

const shl = require("open-shl");
let client = shl.connect({clientId: "", clientSecret:""});
// Fetch the current standings
client.season(2015).statistics.teams.standings()
   .then(teams => {
       console.log(teams[0].team_code, "is currently leading the SHL");
   });
   
//Fetch the top hitters between FHC and FBK
client.season(2015).statistics.players({sort: "hits", teamIds: ["FHC", "FBK"]})
   .then(players => {
       console.log("Between FBK and FHC, ", players[0].info.first_name, players[0].info.last_name, ", hits the most")
   });

License

Copyright © 2016, Jakob Nilsson-Ehle.

Published under ISC license. See LICENSE.md