msf is an R wrapper for the MySportsFeeds API.
There is an official R package provided by MySportsFeeds, but this package differs in the following ways:
parse_*
functions to convert a JSON list into a tidy dataframe. delay
parameter in API calls to execute multiple queries with a delay between them in order to obey rate limits.season = "current"
) to reduce typing.These additions have been very helpful for me to use the data effectively in R. Also, when I started this package the official R package had not been released yet.
devtools::install_github("zamorarr/msf")
To start, make sure you have set the following environment variables set on your computer. Putting them in your .Renviron file is probably the easiest way to do it.
MYSPORTSFEEDS_USER=YOUR_USERNAME
MYSPORTSFEEDS_PASSWORD=YOUR_PASSWORD
Then in R you can query the feeds easily. See the function documentation for a description of the parameters. They should follow the same parameters required to query the official web API.
library(msf)
# Get data
resp <- game_boxscore("nba", "20171027-BRO-NYK")
# You can directly work with the json content represented as a list
json <- resp$content
# Or parse the json list into tidy dataframe
boxscore <- parse_boxscore(json)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.