marcoblume / pinnacle.API

R Wrapper for the Pinnacle API
40 stars 13 forks source link

pagetitle: 'pinnacle.API' output: html_document: keep_md: TRUE highlight: null mathjax: null toc: true theme: readable fold: TRUE toc_float: collapsed: FALSE smooth_scroll: true

CRAN Status Badge CRAN Total Downloads CRAN Monthly Downloads

Accessing the Pinnacle API

The Pinnacle manual can be found here :

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


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


Please contact Pinnacle directly at csd@pinnacle.com for all account questions.


Pinnacle Terms & Conditions:

This package is a GUIDELINE only.

All responsibility of activity on Pinnacle lies with the user of the package and NOT with the authors of the package.

Especially wagers placed with the help of this package are the sole responsibility of the user of this package. The authors and maintainers of the package are not liable or responsible in any form. Please see Manual:Fair-Use, API Rules and Terms and Conditions

http://www.pinnacle.com/en/termsandconditions


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

The Pinnacle API package

This document covers version >= 2.0 of the package and is intended to be an introduction to the package, it does Not cover all functions.

For a more detailed breakdown, we recommend you explore the functions in the package

The pinnacle.API package allows an R user to Access:

While also allowing the usage of this data by

Detailed information about what is available is in the Pinnacle API Manual: https://www.pinnacle.com/en/api/manual


Getting the Package

The most recent stable version is on CRAN, and can be installed with:

install.packages('pinnacle.API')

Development versions are available via github, and can be installed with the devtools package

install.packages('devtools')
devtools::install_github('marcoblume/pinnacle.API')

Setup

the package depends on:

load and configure it as follows:

 library(pinnacle.API)

Please make sure that you understand the terms and conditions.

 AcceptTermsAndConditions()

Run the following to store your session credentials:

 SetCredentials()

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

Example Usage:

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

# Get Sports
sport_data <- GetSports()
# Get Soccer id
soccer_id <- with(sport_data, id[name == 'Soccer'])
# Get Odds
soccer_data <- showOddsDF(soccer_id)

# Lets select a single record and see what we're looking at
# (transposed for easier reading)

A Record Example:

Data
league.id 2117
leagues.events.id 706786965
sportId 29
last 379958992
leagues.id 2117
events.periods.lineId 379958992
events.periods.number 0
events.periods.cutoff 2017-03-22T19:00:00Z
events.periods.maxSpread 2000
events.periods.maxMoneyline 500
events.periods.maxTotal 2000
events.periods.maxTeamTotal 750
periods.spreads.hdp -1.25
periods.spreads.home -118
periods.spreads.away 108
periods.spreads.altLineId NA
periods.totals.points 2.5
periods.totals.over -107
periods.totals.under -104
periods.totals.altLineId NA
periods.moneyline.home -289
periods.moneyline.away 957
periods.moneyline.draw 358
teamTotal.home.points 2
teamTotal.home.over 101
teamTotal.home.under -123
teamTotal.away.points 0.5
teamTotal.away.over 108
teamTotal.away.under -133
leagues.events.awayScore 0
leagues.events.homeScore 0
leagues.events.awayRedCards 0
leagues.events.homeRedCards 0
sportId.Fixture 29
last.Fixture 102176288
league.events.starts 2017-03-22T17:00:00Z
league.events.home Czech Republic
league.events.away Lithuania
league.events.rotNum 30904
league.events.liveStatus 1
league.events.status I
league.events.parlayRestriction 2
sports.id 29
sports.leagues.id 2117
leagues.events.state 1
leagues.events.elapsed 5
leagues.name International - Friendlies
leagues.homeTeamType Team1
leagues.hasOfferings TRUE
leagues.container
leagues.allowRoundRobins TRUE
leagues.leagueSpecialsCount 0
leagues.eventSpecialsCount 13
leagues.eventCount 13

Basic Functions


Get Client Balance:

GetClientBalance()
## $availableBalance
## [1] 3896.54
## 
## $outstandingTransactions
## [1] 3522
## 
## $givenCredit
## [1] 1e+05
## 
## $currency
## [1] "USD"

Get Sports:

Sports <- GetSports()

head(Sports)

Get Leagues:

BasketBallLeagues <- GetLeaguesByID(4)

# Get first 5 entries Basketball Leagues
head(BasketBallLeagues)

Get Fixtures:

# Get Basketball Fixtures
BasketballFixtures <- GetFixtures(4)
head(BasketballFixtures)

# Get Live Basketball Fixtures
LiveBasketballFixtures <- GetFixtures(4, islive = 1)
head(LiveBasketballFixtures)

Get Odds:

# Get Basketball Odds
BasketballOdds <- GetOdds(4)
head(BasketballOdds)

# Get Live Basketball Odds
LiveBasketballOdds <- GetOdds(4, islive = 1)
head(LiveBasketballOdds)

show Odds DF:

Combines the GetOdds, GetFixtures, and GetInrunning Calls, to get one picture of lines

Column names are slightly different than in the above calls, in that only the last 3 identifiers are kept

For example:

sport.leagues.events.periods.periodNumber

becomes

events.periods.periodNumber

This is done to make the tables easier to work with, but can be overridden (see ?showOddsDF)

(Default is to show only mainlines, alternate lines are accessible via the tableFormat option)

# Get Basketball oddsDF
BasketballOddsDF <- showOddsDF(4)
head(BasketballOddsDF)

Place Bet

Once we have our odds information, we can use this to make a bet, or string of bets

for the following example, we will place a bet of $0.01 (Below the minimum bet amount) on the favorite MONEYLINE

BasketballOddsDF <- showOddsDF(4,tableFormat = 'mainlines')

Record example (filtered to only the interesting fields):

Data
sportId 4
leagues.events.id 704584684
events.periods.number 0
events.periods.lineId 379913314
events.periods.maxMoneyline 250
periods.moneyline.home -477
periods.moneyline.away 353

Now we can use those details to fill out the PlaceBet arguments

PlaceBet(
    stake = 0.01, 
    sportId = 4,
    eventId = 704584684,
    periodNumber = 0,
    lineId = 379913314,
    betType = 'MONEYLINE',
    team = 'TEAM1'
)

Here, our stake is below the minimum amount, as we can see in the error message that is returned

List of 5:

PlaceBet(
    stake = 500, 
    sportId = 4,
    eventId = 704584684,
    periodNumber = 0,
    lineId = 379913314,
    betType = 'MONEYLINE',
    team = 'TEAM1'
)

List of 6: