rozzac90 / pinnacle Goto Github PK
View Code? Open in Web Editor NEWPython Wrapper for Pinnacle Sports API
License: MIT License
Python Wrapper for Pinnacle Sports API
License: MIT License
Since the latest commit, pandas is no longer required (unless I'm missing something).
>>> from pinnacle.apiclient import APIClient
>>> api = APIClient(name, passwd)
>>> api.reference_data.get_leagues(29)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/pinnacle/endpoints/referencedata.py", line 63, in get_leagues
response.json().get('leagues', []), resources.LeagueDetails, date_time_sent, datetime.datetime.utcnow()
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 866, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
1 from pinnacle.apiclient import APIClient
File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 2)
I guess this might related to encoding, but not sure how to fix it yet.
from pinnacle.apiclient import APIClient
from pinnacle.endpoints.betting import Betting
from datetime import datetime, timedelta
username = 'foo'
password = 'bar'
api = APIClient(username, password)
last_hour_date_time = datetime.now() - timedelta(days = 1)
s = Betting(api).get_bets(from_date=last_hour_date_time.isoformat(), to_date=datetime.utcnow())
print(s)
´´
{'TIMESTAMP': '2018-06-17 14:12:38.346040', 'code': 'INVALID_REQUEST_DATA', 'message': 'Invalid fromDate. The fromDate must be a valid Iso8601 time.\r\nInvalid toDate. The toDate must be a valid Iso8601 time.', 'Latency': 1.254998}
Whatever format I use, it always return this. Without isoformat, '2016-06-15' etc...
No arguments at all returns: 'message': 'Missing fromDate.
pinnacle.API version 0.0.7
I m using win10, python 2.7.
When I try to install the wrapper i get the following error:
Collecting pinnacle
Downloading pinnacle-0.0.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "c:\users\john\appdata\local\temp\pip-build-db6bbp\pinnacle\setup.py", line 3, in
from pinnacle import version
File "pinnacle_init_.py", line 1, in
from pinnacle.apiclient import APIClient
File "pinnacle\apiclient.py", line 2, in
from pinnacle import endpoints
File "pinnacle\endpoints_init_.py", line 3, in
from pinnacle.endpoints.betting import Betting
File "pinnacle\endpoints\betting.py", line 46
SyntaxError: Non-ASCII character '\xe2' in file pinnacle\endpoints\betting.py on line 47, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\john\appdata\local\temp\pip-build-db6bbp\pinnacle\
Any help would be appreciated!
Hello! Your package is very useful, but it hasn't been updated for a long time. Do you plan to update it in the foreseeable future?
This API's refernce "Pinnacle document" is no link
ModuleNotFoundError: No module named 'pinnacle.apiclient'; 'pinnacle' is not a package
right after installation?
Hi, trying to install. However im ending up with following error?
File "pinnacle\endpoints\betting.py", line 46, in Betting
alt_line_id=None, win_risk_stake=WinRiskType.Risk.value, accept_better_line=Boolean.TRUE.name,
AttributeError: 'str' object has no attribute 'value'
Command "python setup.py egg_info" failed with error code 1 in c
pinnacle/pinnacle/endpoints/betting.py
Line 46 in dd09378
d:\Pinnacle>pip install pinnacle
Collecting pinnacle
Using cached pinnacle-0.0.5.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\sas\appdata\local\temp\pip-build-gbe0wo\pinnacle\setup.py", line 3, in <module>
from pinnacle import __version__
File "pinnacle\__init__.py", line 1, in <module>
from pinnacle.apiclient import APIClient
File "pinnacle\apiclient.py", line 2, in <module>
from pinnacle import endpoints
File "pinnacle\endpoints\__init__.py", line 3, in <module>
from pinnacle.endpoints.betting import Betting
File "pinnacle\endpoints\betting.py", line 11, in <module>
class Betting(BaseEndpoint):
File "pinnacle\endpoints\betting.py", line 36, in Betting
alt_line_id=None, win_risk_stake=WinRiskType.Risk.value, accept_better_line=Boolean.TRUE.value,
AttributeError: 'str' object has no attribute 'value'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\sas\appdata\local\temp\pip-build-gbe0wo\pinnacle\
Hello @rozzac90 ,
I'm trying to retrieve fixtures using since parameter, but I'm getting some error. Note, that this only happened when I used sport_id=34 (volleyball).
I tested using sport_id=33 (tennis) and it worked perfectly.
Do you have any idea what it can be?
Thank you very much,
Rodrigo
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()
for sport in sport_ids:
if sport['name'] == 'Hockey': break
fixtures = api.market_data.get_fixtures(sport['id'])
for league in fixtures['league']:
if league['name'] == 'NHL OT Included Alternates': break
event_id = ''
for event in league['events']:
if event['starts'].startswith('2017-10-16'):
if event['home'].startswith('Detroit') and int(event['rotNum']) < 9000:
event_id = event['id']
break
if not event_id: sys.exit(0)
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:~$
I have a fresh install of Pycharm and Python 2.7.15 and Pinnacle Python API.
When I try the following command:
api.market_data.get_fixtures(29)
I get a response: "No json object could be decoded"
Additionally I get this:
Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.1\helpers\pydev\pydevd.py", line 1664, in <module> main() File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.1\helpers\pydev\pydevd.py", line 1658, in main globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.1\helpers\pydev\pydevd.py", line 1068, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:/Users/Administrator/.PyCharmCE2018.2/config/scratches/scratch.py", line 6, in <module> soccer_events = api.market_data.get_fixtures(29) File "C:\Python27\lib\site-packages\pinnacle\endpoints\marketdata.py", line 27, in get_fixtures response.json(), resources.FixtureDetails, date_time_sent, datetime.datetime.utcnow() File "C:\Python27\lib\site-packages\requests\models.py", line 866, in json return complexjson.loads(self.text, **kwargs) File "C:\Python27\lib\site-packages\simplejson\__init__.py", line 518, in loads return _default_decoder.decode(s) File "C:\Python27\lib\site-packages\simplejson\decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "C:\Python27\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 2 column 1 (char 2)
If I delete simpleJSON package, I get:
Traceback (most recent call last):
File "C:/Users/Administrator/.PyCharmCE2018.2/config/scratches/scratch.py", line 6, in <module>
soccer_events = api.market_data.get_fixtures(29)
File "C:\Python27\lib\site-packages\pinnacle\endpoints\marketdata.py", line 27, in get_fixtures
response.json(), resources.FixtureDetails, date_time_sent, datetime.datetime.utcnow()
File "C:\Python27\lib\site-packages\requests\models.py", line 866, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Python27\lib\json\__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\lib\json\decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
What could be the problem?
Dear @rozzac90 !
I have trouble again with installing pinnacle 0.0.7 version on Windows 10 again.
C:\Users\Administrator>python --version
Python 2.7.15
C:\Users\Administrator>pip install pinnacle
Collecting pinnacle
Using cached https://files.pythonhosted.org/packages/12/06/55706032d6d245e1f28b7e3c3c1ab48ec978ee5a3de260adb0a91ea36a72/pinnacle-0.0.7.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\admini~1\appdata\local\temp\2\pip-install-cqitoa\pinnacle\setup.py", line 3, in <module>
from pinnacle import __version__
File "pinnacle\__init__.py", line 1, in <module>
from pinnacle.apiclient import APIClient
File "pinnacle\apiclient.py", line 1, in <module>
from pinnacle.baseclient import BaseClient
File "pinnacle\baseclient.py", line 3, in <module>
import requests
ImportError: No module named requests
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\admini~1\appdata\local\temp\2\pip-install-cqitoa\pinnacle\
C:\Users\Administrator>python -m pip --version
pip 18.0 from C:\Python27\lib\site-packages\pip (python 2.7)
Can you help me out?
But there's no v2 for placing straight bets in your wonderful wrapper. Could you please fix that?)
This error happens when there's no updates on the odds:
File "/usr/local/lib/python3.7/site-packages/pinnacle/endpoints/marketdata.py", line 117, in get_odds
response.json(), resources.OddsDetails, date_time_sent, datetime.datetime.utcnow()
File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 866, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
debugging it I got this:
> https://api.pinnacle.com/v1/odds - 200
>response: <Response [200]>
>response.content: b''
>response.text:
>response.headers: {'Date': 'Mon, 12 Aug 2019 22:21:36 GMT', 'Content-Length': '0', 'Connection': 'keep-alive'; expires=Tue, 11-Aug-20 22:21:36 GMT; path=/; domain=.pinnacle.com; HttpOnly', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache', 'Expires': '-1', 'X-Powered-By': 'ASP.NET, ARR/3.0, ASP.NET', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare'}
Last time I checked you can use a league with no odds for it to get that response. At the time I used this league id on the odds api call: 1891
I've already seen two issues with problems with the return pinnacle sends (I believe they were related with not being in a region allowed), not sure why it doesn't just return a json with the message though.
When calling the get_bets
routine of the betting
endpoint without any arguments, I get
Missing fromDate. The fromDate must be a date in ISO 8601 format.
Missing toDate. The toDate must be a date in ISO 8601 format.
When setting from_date
and to_date
to datetime.utcnow()
I get
Invalid fromDate. The fromDate must be a date in ISO 8601 format.
Invalid toDate. The toDate must be a date in ISO 8601 format.
Dear rozzac90,
Could you help me why am I not getting data for the following:
api.market_data.get_line(sport_id=29, league_id=163787, event_id=854626664, period_number=0,
bet_type='MONEYLINE', team='DRAW', side=None, handicap=None, odds_format='DECIMAL')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.