knitr::opts_chunk$set(echo = TRUE)

shlr

This is an API client to retrieve data from the Swedish Hockey League Open API.

You can install the package with devtools.

devtools::install_github("filipwastberg/shlr")

To be able to use it you need to apply for a client id and client secret from http://doc.openapi.shl.se/.

When you have these you can save them as environment variables:

Sys.setenv('SHL_CLIENT_ID' = "xxxxxx")
Sys.setenv('SHL_CLIENT_SECRET' = "xxxxxxxx")

If you need to repeat this procedure during start up then save them to your .Renviron usually done by file.edit("~/.Renviron")

Using the package

For example you can get the top 10 players of a team (or the whole league) using get_top10_player_stats().

library(shlr)
get_top10_player_stats(season = "2017", team_id = "DIF")

You can aquire the same information but for only goalies with get_top10_player_stats().

You can get all the games for a season with get_games().

get_games(season = "2018")

Active teams and meta information about the teams:

get_teams()

The current standing in SHL:

get_team_standing(season = "2018")


filipwastberg/shlr documentation built on May 17, 2019, 1:14 a.m.