Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 

README.md

stattleship-r

Stattleship R Wrapper brought to you by @stattleship.

Check out the Stattleship API - The Sports Data API you've always wanted.

Affordable. Meaningful. Developer-Friendly.

🏈, 🏀, and available now. College 🏈 and Major League to come.

We're gonna need a bigger !

Install

devtools::install_github("stattleship/stattleship-r")

Getting Started

  • Obtain an access TOKEN from stattleship.com.
  • Load R and initialize your TOKEN for your session and load the library:
  • Consult Stattleship Developer API Documentation
  • Familiarize yourself with the API calls and parameters
  • Understn the use of slugs like nba-2018-2019 or nba-2018-2019-bos-det-2018-10-27-1900
  • Code! Query! Enjoy!

Some Brief Examples

These are NBA related, but can apply to NHL, NFL and MLB. The API is the same!

library(stattleshipR)
set_token('insert-your-token-here')

Get all NBA players:

league <- "nba"
sport <- "basketball"
ep <- "players"
q_body <- list()
players <- ss_get_result(sport = sport, league = league, ep = ep,
                         query = q_body, version = 1, walk = TRUE)
players_df <- do.call("rbind", lapply(players, function(x) x$players))

Get NBA Schedule for a regular season:

q_body <- list(season_id="nba-2018-2019", interval_type="regularseason")
tmp <- ss_get_result(sport="basketball",
                     league="nba",
                     ep="games",
                     query=q_body,
                     verbose=TRUE,
                     walk = TRUE)

Get NBA Play by Play for a single game:

Important: This endpoint works slightly differently and the game_id must be appended to the ep.

q_body <- list()
tmp <- ss_get_result(sport="basketball",
                     league="nba",
                     ep="play_by_play/nba-2018-2019-bos-det-2018-10-27-1900",
                     query=q_body,
                     verbose=TRUE,
                     walk = TRUE)
[1] "Making initial API request"
[1] "Retrieving results from page 2 of 12"
[1] "Retrieving results from page 3 of 12"
[1] "Retrieving results from page 4 of 12"
[1] "Retrieving results from page 5 of 12"
[1] "Retrieving results from page 6 of 12"
[1] "Retrieving results from page 7 of 12"
[1] "Retrieving results from page 8 of 12"
[1] "Retrieving results from page 9 of 12"
[1] "Retrieving results from page 10 of 12"
[1] "Retrieving results from page 11 of 12"
[1] "Retrieving results from page 12 of 12"

Next Steps

Want more? Check out our available stats across an expanding number of sports at the Stattleship Developer API Documentation or Stattleship blog.

Style Guide

We plan to follow Hadley Wickham's R Style Guide. Please follow these guidelines if you'd like to contribute!

You can’t perform that action at this time.