Many thanks again for this great wrapper very useful for me. I wrote the following program to try to place a bet with the API. Today in NHL we have Tampa Bay visiting Detroit, I want to bet on the alternate line of Tampa Bay +1.5. Here is the small program I wrote.
!/usr/bin/python
import sys
from pinnacle.apiclient import APIClient
today = '2017-10-16'
home_team = 'Detroit'
api = APIClient('user', 'pass')
sport_ids = api.reference_data.get_sports()
find hockey
for sport in sport_ids:
if sport['name'] == 'Hockey': break
for league in fixtures['league']:
if league['name'] == 'NHL OT Included Alternates': break
get events for today
event_id = ''
for event in league['events']:
if event['starts'].startswith('2017-10-16'):
and find the event id for home team and not live betting (rotation < 9000)
if event['home'].startswith('Detroit') and int(event['rotNum']) < 9000:
event_id = event['id']
break
if not event_id: sys.exit(0)
get the line
print '\nFound event_id %s data: %s' % (event_id, event)
line = api.market_data.get_line(sport['id'], league['id'], event_id, 0, 'SPREAD', 'Team1', handicap = 1.5,
odds_format = 'AMERICAN')
if line['status'] != 'SUCCESS':
print 'Sorry line not found, continue digging...'
sys.exit(0)
print '\nFound line data: %s' % line
risk = raw_input('Please enter risk amount for The following line, hitting enter WILL place the bet? ')
result = api.betting.place_bet(sport_id=sport['id'], event_id=event_id, line_id=line['lineId'],
period_number=0, bet_type='SPREAD', stake=float(risk), team='Team1',
win_risk_stake='RISK', odds_format='AMERICAN', accept_better_line='TRUE')
print '\nSubmitted bet data: %s' % result
If you don't include <, accept_better_line='TRUE'> in the place_bet call you get the following output:
linux@sue:~$ pint.py
Found event_id 774911107 data: {u'status': u'O', u'parlayRestriction': 2, u'starts': u'2017-10-16T23:35:00Z', u'away': u'Tampa Bay Lightning', u'rotNum': u'1', u'home': u'Detroit Re
d Wings', u'id': 774911107, u'liveStatus': 0}
Found line data: {u'status': u'SUCCESS', u'team2RedCards': None, u'minRiskStake': 3.49, u'team2Score': None, u'price': -349.0, u'team1RedCards': None, u'maxWinStake': 1000.0, u'maxR
iskStake': 3490.0, 'Latency': 0.141317, u'team1Score': None, u'altLineId': None, 'TIMESTAMP': '2017-10-16 20:09:11.299569', u'lineId': 434550724, u'minWinStake': 1.0, u'effectiveAsO
f': u'2017-10-16T20:06:29.7431'}
Please enter risk amount for The following line, hitting enter WILL place the bet? 3490
Submitted bet data: {'TIMESTAMP': '2017-10-16 20:09:51.352022', u'message': u'Invalid acceptBetterLine parameter value. The allowed values are (TRUE, FALSE)', u'code': u'INVALID_REQ
UEST_DATA', 'Latency': 0.162374}
linux@sue:~$
With the program above the output gives this:
linux@sue:~$ pint.py
Found event_id 774911107 data: {u'status': u'O', u'parlayRestriction': 2, u'starts': u'2017-10-16T23:35:00Z', u'away': u'Tampa Bay Lightning', u'rotNum': u'1', u'home': u'Detroit Re
d Wings', u'id': 774911107, u'liveStatus': 0}
Found line data: {u'status': u'SUCCESS', u'team2RedCards': None, u'minRiskStake': 3.49, u'team2Score': None, u'price': -349.0, u'team1RedCards': None, u'maxWinStake': 1000.0, u'maxR
iskStake': 3490.0, 'Latency': 0.127161, u'team1Score': None, u'altLineId': None, 'TIMESTAMP': '2017-10-16 20:40:37.072995', u'lineId': 434550724, u'minWinStake': 1.0, u'effectiveAsO
f': u'2017-10-16T20:37:48.3548'}
Please enter risk amount for The following line, hitting enter WILL place the bet? 3490
Good spot I will push an update to fix this. On that note I dont have access to a pinnacle api right now, so any bugs/updates etc please submit issues or PRs.
Hello,
Many thanks again for this great wrapper very useful for me. I wrote the following program to try to place a bet with the API. Today in NHL we have Tampa Bay visiting Detroit, I want to bet on the alternate line of Tampa Bay +1.5. Here is the small program I wrote.
!/usr/bin/python
import sys from pinnacle.apiclient import APIClient
today = '2017-10-16' home_team = 'Detroit'
api = APIClient('user', 'pass') sport_ids = api.reference_data.get_sports()
find hockey
for sport in sport_ids: if sport['name'] == 'Hockey': break
find fixtures
fixtures = api.market_data.get_fixtures(sport['id'])
extract wanted nhl events
for league in fixtures['league']: if league['name'] == 'NHL OT Included Alternates': break
get events for today
event_id = '' for event in league['events']: if event['starts'].startswith('2017-10-16'):
and find the event id for home team and not live betting (rotation < 9000)
if not event_id: sys.exit(0)
get the line
print '\nFound event_id %s data: %s' % (event_id, event) line = api.market_data.get_line(sport['id'], league['id'], event_id, 0, 'SPREAD', 'Team1', handicap = 1.5, odds_format = 'AMERICAN') if line['status'] != 'SUCCESS': print 'Sorry line not found, continue digging...' sys.exit(0) print '\nFound line data: %s' % line risk = raw_input('Please enter risk amount for The following line, hitting enter WILL place the bet? ') result = api.betting.place_bet(sport_id=sport['id'], event_id=event_id, line_id=line['lineId'], period_number=0, bet_type='SPREAD', stake=float(risk), team='Team1', win_risk_stake='RISK', odds_format='AMERICAN', accept_better_line='TRUE') print '\nSubmitted bet data: %s' % result
If you don't include <, accept_better_line='TRUE'> in the place_bet call you get the following output:
linux@sue:~$ pint.py
Found event_id 774911107 data: {u'status': u'O', u'parlayRestriction': 2, u'starts': u'2017-10-16T23:35:00Z', u'away': u'Tampa Bay Lightning', u'rotNum': u'1', u'home': u'Detroit Re d Wings', u'id': 774911107, u'liveStatus': 0}
Found line data: {u'status': u'SUCCESS', u'team2RedCards': None, u'minRiskStake': 3.49, u'team2Score': None, u'price': -349.0, u'team1RedCards': None, u'maxWinStake': 1000.0, u'maxR iskStake': 3490.0, 'Latency': 0.141317, u'team1Score': None, u'altLineId': None, 'TIMESTAMP': '2017-10-16 20:09:11.299569', u'lineId': 434550724, u'minWinStake': 1.0, u'effectiveAsO f': u'2017-10-16T20:06:29.7431'} Please enter risk amount for The following line, hitting enter WILL place the bet? 3490
Submitted bet data: {'TIMESTAMP': '2017-10-16 20:09:51.352022', u'message': u'Invalid acceptBetterLine parameter value. The allowed values are (TRUE, FALSE)', u'code': u'INVALID_REQ UEST_DATA', 'Latency': 0.162374} linux@sue:~$
With the program above the output gives this:
linux@sue:~$ pint.py
Found event_id 774911107 data: {u'status': u'O', u'parlayRestriction': 2, u'starts': u'2017-10-16T23:35:00Z', u'away': u'Tampa Bay Lightning', u'rotNum': u'1', u'home': u'Detroit Re d Wings', u'id': 774911107, u'liveStatus': 0}
Found line data: {u'status': u'SUCCESS', u'team2RedCards': None, u'minRiskStake': 3.49, u'team2Score': None, u'price': -349.0, u'team1RedCards': None, u'maxWinStake': 1000.0, u'maxR iskStake': 3490.0, 'Latency': 0.127161, u'team1Score': None, u'altLineId': None, 'TIMESTAMP': '2017-10-16 20:40:37.072995', u'lineId': 434550724, u'minWinStake': 1.0, u'effectiveAsO f': u'2017-10-16T20:37:48.3548'} Please enter risk amount for The following line, hitting enter WILL place the bet? 3490
Submitted bet data: {u'status': u'ACCEPTED', 'Latency': 0.416879, u'betId': 775519529, 'TIMESTAMP': '2017-10-16 20:41:10.197698', u'price': -349.0, u'betterLineWasAccepted': False, u'errorCode': None, u'uniqueRequestId': u'c4d994ba-034d-4fae-a94b-e859aeeec4fb'} linux@sue:~$