Last active
August 29, 2016 12:59
-
-
Save batpigandme/98d44737bbfcf32fc842 to your computer and use it in GitHub Desktop.
Retrieve NBA teams using Stattleship API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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