-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
251 lines (169 loc) · 4.09 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
---
title: "sportmonks"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = T, message = F, error = F, warning = F)
```
```{r, echo = FALSE, results='asis', eval = T}
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
```{r, eval = F}
devtools::install_github("systats/sportmonks")
library(sportmonks)
```
```{r, echo = F}
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
```{r}
get_continents()
get_continent(1)
```
## Country
```{r}
get_countries()
get_country(2)
```
## Leagues
```{r}
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
```{r}
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.
```{r}
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
```{r, message = T}
get_live()
# get_live_now()
# all
# inplay
```
## Comments
```{r}
get_comments(10333321)
```
## Highlights
```{r}
get_highlights(10333321)
```
## Head2Head
```{r}
get_head2head(team1 = 309, team2 = 66)
```
## Teams
```{r}
get_team(180)
get_team(season_id = 1273)
```
## Players
```{r}
get_player(180)
```
## Topscores
```{r}
get_topscores(season_id = 1273, agg = T)
```
## Venues
```{r}
get_venue(8928)
# by id
# by season id
```
## Rounds
```{r}
get_round(round_id = 147767)
get_round(season_id = 12963)
```
## Odds
```{r}
get_odds(10333321)
# by fixture and bookmarker
# by fixture and market
# by fixture id
# inplay odds by fixture id
```
## Coaches
```{r}
get_coache(896462)
```
## Stages
```{r}
get_stage(stage_id = 7508262)
get_stage(season_id = 12963)
```
## Bookmarkers
```{r}
get_bookmakers()
get_bookmaker(book_id = 25679219)
```
## Markets
```{r}
get_markets()
get_market(id = 10)
```
## Team Squads
```{r}
get_team_squads(season_id = 12963, team_id = 180)
```
## TV-stations
```{r}
get_tv(10333321)
```
```{r}
sessionInfo()
```
## Get future games
```{r}
get_future_games()
get_future_games(league_id = 501)
get_future_games(league_id = c(271, 501))
```
# Status Response
* 2xx range indicate success.
- 200 The request was successful and data is returned.
* 4xx range indicate an error that failed given the information provided.
- 400 It seems that some part of the request is malformed. The exact reason is returned in the response.
- 401 The request is not authenticated.
- 403 Not authorized. Indicates you're attempting to access a feed which is not accesible from your plan.
- 429 Too Many Requests. In order to make the API as responsive as possible, you have an hourly request limit. The limit for your current subscription can be found in any successfull response. Check the "meta" section to find out your limit.
* 5xx range indicate an error with SportMonks' servers.
- 500 An internal error has occurred, and has been logged for further inspection. Please email support if you are receiving this error.
## Ratelimits
* `default` all our plans are included with 2000 requests per 60 minutes per endpoint.