Learn R Programming

⚠️There's a newer version (2.3.3) of this package.Take me there.

pinnacle.API

R Wrapper for the Pinnacle Sports API

The Pinnacle Sports ( www.pinnaclesports.com) manual can be found here :

http://www.pinnaclesports.com/en/api/manual

To use the Pinnacle Sports API you must have an account with Pinnacle Sports.

Please contact Pinnacle Sports directly at csd@pinnaclesports.com for all account questions. Pinnacle Terms & Conditions: http://www.pinnaclesports.com/en/termsandconditions

The API is not accessible from all IP-Ranges , especially IP addresses from the UK and the USA are Geo IP blocked.

To install the newest version :

devtools::install_github("marcoblume/pinnacle.API")

Or install a stable version from CRAN :

install.packages("pinnacle.API")

Example Code

library(pinnacle.API)
library(dplyr)
library(lubridate)

Please make sure that you understand the terms and conditions.

AcceptTermsAndConditions()

and then accept them. If AcceptTermsnAndConditions is not set to TRUE the functions will not run.

AcceptTermsAndConditions(TRUE)

Your credentials are the username and password for logging into www.pinnaclesports.com.

SetCredentials("MyUserName","MyPassWord")

Pull the Sport Data and filter out the leagues that have lines for Badminton available.

Sport_data <- GetSports() 
Badminton_ID <- Sport_data$SportID[Sport_data$SportName=="Badminton"]
League_data <- GetLeagues("Badminton")
active_leagues <- League_data %>% 
  filter(LinesAvailable == 1)
Badminton_League_Ids <- active_leagues$LeagueID

Use the showOddsDF() function to aggregate all the data into a nicer data.frame.

badminton_data <- showOddsDF(sportname = "Badminton" , Badminton_League_Ids )

Convert the dates into POSIX

## Convert Times to Posix
badminton_data$StartTime <- as.POSIXct(badminton_data$StartTime,format="%Y-%m-%dT%H:%M:%S",tz="UTC")
badminton_data$cutoff <- as.POSIXct(badminton_data$cutoff,format="%Y-%m-%dT%H:%M:%S",tz="UTC")

This DF has all the necessary IDs and information that you can then pass to the PlaceBet() function to place your wagers.

Examples for Filter Settings on Soccer Data

use the same code as above and change the Sport from Badminton to Soccer.

## Some Filter Suggestions to clean the Data 
soccer_filtered <- soccer_data %>% 
  ## Only Period "0" , the main period 
  filter(PeriodNumber == 0 ) %>% 
  ## No Live Games
  filter( LiveStatus != 1) %>% 
  ## No Corners
  filter(. , !grepl("Corner",HomeTeamName)) %>% 
  ## No Home vs Aways
  filter(. , !grepl("Home Team",HomeTeamName)) %>% 
  ## No advance Lines
  filter(. , !grepl("advance",HomeTeamName)) %>%
  ## No raise the cup lines
  filter(. , !grepl("raise",HomeTeamName)) %>% 
  ## Filter games past cutoff time
  filter(cutoff > as.POSIXlt(Sys.time(),tz="UTC")) %>%
  ## Filter games that are played in the next 24h
  filter(StartTime < as.POSIXlt(Sys.time(),tz="UTC")+hours(24) )

This is a filter Ideas for Live Games in Soccer. Modify showOddsDF() with ISLive= TRUE for a faster response if only Live Events are needed. The League IDs are retrieved using GetLeagues().

data <- showOddsDF(sportname = "Soccer" , Sport_Type_League_IDs , isLive = TRUE)

data %>%
      ## Only bet on Period "1"
      filter(PeriodNumber == 0 ) %>%
      ## No Live Games
      filter( LiveStatus == 1) %>%
      ## Specific
      filter(homeScore + awayScore == 3 ) %>%
      ## only 1st half
      filter(state == 1) %>%
      ## only from 17th min into state
      filter(elapsed  > 17)

To check all Running Wagers use GetBetsList() with betlist = "RUNNING". Below call will fetch all wagers that are RUNNING from the last 28 days.

 betlist <- GetBetsList(betlist = "RUNNING",
                         fromDate = as.POSIXlt(Sys.Date(), tz = "UTC") - 28 * 24 * 60 * 60,
                         toDate = as.POSIXlt(Sys.Date(), tz = "UTC") + 24 * 60 * 60)

Copy Link

Version

Install

install.packages('pinnacle.API')

Monthly Downloads

36

Version

1.90

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Marco Blume

Last Published

November 27th, 2015

Functions in pinnacle.API (1.90)

authorization

Authorization for the Pinnacle API
GetInrunning

GetInrunning
cbindNames

Combines elements of an object, keeping names
GetSports

Get Sports
CheckTermsAndConditions

Prompts User for Terms and Conditions, otherwise stops running function
PlaceParlayBet

PlaceParlayBet
pinnRawXMLResponse

pinnRawXMLResponse
JSONtoDF

Sets the determined depth as a data.frame, and evades R's list-dropping rules
GetLeagues

Get Leagues for Sport(s) by name
GetClientBalance

Get Client Balance
showOddsDF

showOddsDF - Takes a GetOdds JSON response and turns it into a data.frame
SetCredentials

Set your pinnaclesports.com user credentials
GetOdds

Get Odds
GetBetsList

Get a list of running/settled bets
GetLeaguesByID

Get Leagues for Sport(s) by ID
GetCurrencies

Get the list of supported Currencies
PlaceBet

Place Bet
GetCredentials

Get your credential values
AcceptTermsAndConditions

Accept terms and conditions, only run once per session, must agree to terms or functions will not work
GetLine

Get Lines (Use to get more detail on a single line, but the GetOdds or showOddsDF versions are intended for large amounts of data)
GetFixtures

Get Fixtures