This repository is an R package to easily stream StatsBomb data from the API using your log in credentials or from the Open Data GitHub repository cost free into R .
This repository is an R package to easily stream StatsBomb data into R using your log in credentials for the API or free data from our GitHub page. API access is for paying customers only
This package offers a parallel option to most computationally expensive functions. However, it is currently only designed for Windows.
install.packages("devtools")
devtools::install_github("statsbomb/StatsBombR")
library(StatsBombR)
This package depends on several other packages in order for all functions to run. Therefore, if you have problems with any functions or with installing the package, it is likely due to package dependencies.
Welcome to the Free Data Offerings from StatsBomb Services.
This package is reading in the open access dat found on https://github.com/statsbomb/open-data. Below you will find a list of the functions used to quickly read in all open data currently available. Check back often as new data is regularly added.
StatsBomb are committed to sharing new data and research publicly to enhance understanding of the game of Football. We want to actively encourage new research and analysis at all levels. Therefore we have made certain leagues of StatsBomb Data freely available for public use for research projects and genuine interest in football analytics.
StatsBomb are hoping that by making data freely available, we will extend the wider football analytics community and attract new talent to the industry. We would like to collect some basic personal information about users of our data. By giving us your email address, it means we will let you know when we make more data, tutorials and research available. We will store the information in accordance with our Privacy Policy and the GDPR.
Whilst we are keen to share data and facilitate research, we also urge you to be responsible with the data. Please register your details on https://www.statsbomb.com/resource-centre and read our User Agreement carefully.
By using this repository, you are agreeing to the user agreement.
If you publish, share or distribute any research, analysis or insights based on this data, please state the data source as StatsBomb and use our logo.
StatsBombData <- free_allevents()
FreeCompetitions()
or, for use in other functions, store it as a data frame object:
Comp <- FreeCompetitions()
Matches <- FreeMatches(Comp)
get.matchFree(Matches[1,])
It is important to note, that the argument here is the entire row returns from “FreeMatches”, this is because there is information from each match observation that is needed in the get.matchFree
function.
API access is for paying customers only
competitions <- competitions(username, password)
matches <- get.matches(username, password, season_id, competition_id)
comps <- competitions(username, password)
EuropeComps <- comps %>% filter(country_name == "Europe")
competitionmatrix <- as.matrix(EuropeComps[,1:2])
Matches <- MultiCompMatches(username, password, competitionmatrix)
StatsBombData <- get.events(username, password, match_id)
Note: A previous version of this function was named get.match(), get.match() is now deprecated).
matchids <- matchesvector(username, password, season_id, competition_id)
StatsBombData <- allevents(username, password, matchids)
Note: See documentation for additional parameters available to access different API versions, run in parallel or not, choose a specific number of cores. (A previous version of this function was named allmatches(), allmatches() is now deprecated).
comps <- competitions(username, password)
EuropeComps <- comps %>% filter(country_name == "Europe")
competitionmatrix <- as.matrix(EuropeComps[,1:2])
Events <- MultiCompEvents(username, password, competitionmatrix)
lineups <- get.lineups(username, password, match_id)
matchids <- matchesvector(username, password, season_id, competition_id)
StatsBombLineups <- allineups(username, password, matchids, parallel = T)
StatsBombLineups <- cleanlineups(StatsBombLineups)
Although JSON files can often be a pain to clean, especially due to nested data frames, these helper functions may make your data wrangling much easier.
StatsBombData <- allclean(StatsBombData)
This function cleans the data in one line of code by running each of the functions below sequentially.
StatsBombData <- cleanlocations(StatsBombData)
Please note all location variables must be present in the data set. This function will not work with a subset of variables (i.e. if any location variables are missing).
StatsBombData <- goalkeeperinfo(StatsBombData)
Please note that additional information is located under type.name == “Goal Keeper” and within the Freeze Frames.
StatsBombData <- shotinfo(StatsBombData)
StatsBombData <- freezeframeinfo(StatsBombData)
Description of these variables:
StatsBombData <- formatelapsedtime(StatsBombData)
StatsBombData <- possessioninfo(StatsBombData)
?StatsBombFreeEvents()
) for more specific description.