knitr::opts_chunk$set(echo = T, message = F, error = F, warning = F)
git_repo <- "systats/sportmonks"
cat(
  badger::badge_custom("Premium", "Soccer Data", "yellow"),
  badger::badge_devel(git_repo, "blue"),
  #badge_travis(git_repo),
  #"[![Codecov test coverage](https://codecov.io/gh/favstats/peRspective/branch/master/graph/badge.svg)](https://codecov.io/gh/favstats/peRspective?branch=master)",
  badger::badge_code_size(git_repo),
  badger::badge_last_commit(git_repo)
)

Install via

devtools::install_github("systats/sportmonks")
library(sportmonks)
pacman::p_load(tidyverse, crayon)
devtools::load_all()
# devtools::document()
# devtools::test()

key <- jsonlite::read_json("tests/settings.json")[[1]]
Sys.setenv(sportmonks = key)
#Sys.getenv("sportmonks")

Endpoints

API responses are parsed per default. To get the raw json response, set the parse parameter to "F".

Continents

get_continents()
get_continent(1)

Country

get_countries()
get_country(2)

Leagues

my_leagues <- get_leagues(parse = T) # Default
my_leagues_raw <- get_leagues(parse = F)
my_leagues_raw %>% parse_request()
my_leagues

get_league(271)

Seasons

new_leagues <- get_seasons()
get_season(1273)

Fixtures

Depending on your substription plan and the situational needs you can include nested tables which is particuarly useful for the fixture Endpoint to get all the data at once.

includes <- c('localTeam','visitorTeam','goals',
              'cards','lineup','referee','venue',
              'odds', 'stats')


get_fixture(id = 10333321, includes = includes)
get_fixtures(ids = c(10333321, 10333322))
get_fixture(date = "2019-01-23")
get_fixtures(dates = c("2019-01-01", "2019-02-01"))
# missing: get by date range for team

Livescores

get_live()
# get_live_now()
# all 
# inplay

Comments

get_comments(10333321)

Highlights

get_highlights(10333321)

Head2Head

get_head2head(team1 = 309, team2 = 66)

Teams

get_team(180)
get_team(season_id = 1273)

Players

get_player(180)

Topscores

get_topscores(season_id = 1273, agg = T)

Venues

get_venue(8928)
# by id
# by season id

Rounds

get_round(round_id = 147767)
get_round(season_id = 12963)

Odds

get_odds(10333321)

# by fixture and bookmarker
# by fixture and market
# by fixture id
# inplay odds by fixture id

Coaches

get_coache(896462)

Stages

get_stage(stage_id = 7508262)
get_stage(season_id = 12963)

Bookmarkers

get_bookmakers()
get_bookmaker(book_id = 25679219)

Markets

get_markets()
get_market(id = 10)

Team Squads

get_team_squads(season_id = 12963, team_id = 180)

TV-stations

get_tv(10333321)
sessionInfo()

Get future games

get_future_games()
get_future_games(league_id = 501)
get_future_games(league_id = c(271, 501))

Status Response

Ratelimits



systats/sportmonks documentation built on Nov. 5, 2019, 9:42 a.m.