get.lineups <- function(username, password, match_id, version = "v4",
baseurl = "https://data.statsbomb.com/api/"){
events <- tibble()
Events.url <- paste0(baseurl, version, "/lineups/", match_id)
raw.events.api <- GET(url = Events.url, authenticate(username, password))
events.string <- rawToChar(raw.events.api$content)
Encoding(events.string) <- "UTF-8"
events <- fromJSON(events.string, flatten = T)
if(length(events) == 0){
events <- tibble() #Some of the matches in the premier league are not available yet.
} else {
events <- events %>% mutate(match_id = match_id)
}
return(events)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.