A Wrapper for the Pinnacle API

An interface to the API by Pinnacle that allows Pinnacle customers to interact with the sports market data in R.See < https://www.pinnacle.com/en/api> for more information. The Pinnacle API can be used to place wagers, retrieve line information, retrieve account information.Please be aware that the TOC of Pinnacle apply < https://www.pinnacle.com/en/termsandconditions>. An account with Pinnacle is necessary to use the 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 [email protected] 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")
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.

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 "0"
      filter(PeriodNumber == 0 ) %>%
      ## Only Live Games
      filter( LiveStatus == 1) %>%
      ## Specific
      filter(homeScore + awayScore == 3 ) %>%
      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)

News

pinnacle.API v2.3.3 (Release date: 2018-01-24)

Changes

  • Error handling and messaging now ubiquitous
  • http codes mapped to failure messages

pinnacle.API v2.3.2 (Release date: 2016-07-20)

Changes

  • Better handling when there are no odds to display in showOddsDF.

pinnacle.API v2.3.1 (Release date: 2016-07-19)

Changes

  • Potentially breaking change in behavior of showOddsDF: we only return lines for which we have returned odds. So if a line is down, showOddsDF will not show it. If inrunning state or fixtures are required, please call those directly.

pinnacle.API v2.1.1 (Release date: 2016-07-19)

Changes

  • Bug in showOddsDF, since parameter was constraining both fixtures and odds Created "fixtures_since" and let the original since cover only odds.

pinnacle.API v2.1.0 (Release date: 2016-07-10)

Changes:

  • jsonlite::rbind.pages deprecated, switched to jsonlite::rbind_pages
  • Removed utf-8 messages
  • Added Real Messages

pinnacle.API v2.0.8 (Release date: 2016-05-30)

Changes:

  • Bug: solution for GetSpecialOdds caused another issue, fixed

pinnacle.API v2.0.7 (Release date: 2016-05-29)

Changes:

  • GetLine now returns visibly
  • GetSpecialOdds, wide format now working correctly

pinnacle.API v2.0.6 (Release date: 2016-05-08)

Changes:

  • Fix to showOddsDF (wide tableformat supported)

pinnacle.API v2.0.5 (Release date: 2016-04-02)

Changes:

  • Fix to showOddsDF (No live games bug)

pinnacle.API v2.0.4 (Release date: 2016-03-11)

Changes:

  • Major Upgrade, all functions now more in line with the fields and wrappers in the pinnacle.api manual (CRAN RELEASE READY)

pinnacle.API v2.0.3 (Release date: 2016-12-06)

Changes:

  • Major Upgrade, all functions now more in line with the fields and wrappers in the pinnacle.api manual

pinnacle.API v1.9.3 (Release data: 2016-11-30)

Changes:

  • Removing XML support in line with new API guidelines

pinnacle.API v1.9.2 (Release data: 2016-08-09)

Changes:

*Added replaceNulls function to cover an edge case *Added getAPIEndpoint function to check the current endpoint

  • Changed GetFixtures to work with MLB Pitcher names.

pinnacle.API v1.9.1 (Release date: 2016-06-06)

Changes:

*Added setAPIEndpoint function for dev and future reliability.

pinnacle.API v1.9.0 (Release date: 2015-10-02)

Changes:

*Added pinnRawXMLResponse for debugging unusual API responses

pinnacle.API v1.8.9 (Release date: 2015-09-17)

Changes:

*fixed dplyr duplicate in namespace *functions are now case insensitive with respect to sport *some changes to documentation

pinnacle.API v1.8.8 (Release date: 2015-09-11)

Changes:

*Replaced plyr's rbind.fill with do.call(bind) for speed *Removed plyr from import list *exported cbindNames from showOddsFunctions *fixPeriods is now JSONtoDF and is the only function called

pinnacle.API v1.8.7 (Release date: 2015-09-10)

Changes:

*Added GetInrunning, to get the state of live events

pinnacle.API v1.8.6 (Release date: 2015-09-9)

Changes:

*Changed default caching behavior *Fixed Caching Bug, involving switching leagues

pinnacle.API v1.8.5 (Release date: 2015-09-9)

Changes:

*Fixed showOddsDF for live, live fields now shown *Added Caching for GetLeagues

pinnacle.API v1.8.4 (Release date: 2015-09-8)

Changes:

*Added PlaceParlayBet function

pinnacle.API v1.8.3 (Release date: 2015-09-8)

Changes:

*Changes to showOddsDF ordering for readability

pinnacle.API v1.8.2 (Release date: 2015-09-7)

Changes:

  • Changes to default time ranges, switched to type POSIXlt from iso, and set timezone as UTC

pinnacle.API v1.8.1 (Release date: 2015-09-5)

Changes:

  • Due to GEO IP Blocking removed the testing of the examples in R CMD check

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("pinnacle.API")

2.3.3 by Marco Blume, 2 years ago


https://github.com/marcoblume/pinnacle.API#README


Report a bug at https://github.com/marcoblume/pinnacle.API/issues


Browse source code at https://github.com/cran/pinnacle.API


Authors: Nicholas Jhirad , Marco Blume , Aaron Jacobs , Amine Gassem


Documentation:   PDF Manual  


GPL-3 license


Imports data.table, openssl, magrittr, purrr, uuid, httr, jsonlite, rjson

Suggests testthat, yaml


Suggested by pinnacle.data.


See at CRAN