Skip to content

Instantly share code, notes, and snippets.

@batpigandme
Last active August 29, 2016 12:59
Show Gist options
  • Save batpigandme/98d44737bbfcf32fc842 to your computer and use it in GitHub Desktop.
Save batpigandme/98d44737bbfcf32fc842 to your computer and use it in GitHub Desktop.
Retrieve NBA teams using Stattleship API
## install and load the stattleshipR package
devtools::install_github("stattleship/stattleship-r")
library(stattleshipR)
## get API token at playbook.stattleship.com
## set API token
set_token('YOUR_ACCESS_TOKEN')
## set up envt
options(stringsAsFactors=FALSE)
## set params
league <- "nba"
sport <- "basketball"
ep <- "teams"
## leave empty for all teams
## set season_id
q_body <- list(season_id="nba-2015-2016")
## get the data
teams <- ss_get_result(sport=sport, league=league, ep=ep, query=q_body, version=1, verbose=TRUE, walk=TRUE)
## bind the data together
tms <- lapply(teams, function(x) x$teams)
nba_teams <- do.call('rbind', tms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment