GithubHelp home page GithubHelp logo

pinnacle's Introduction

pinnacle

Python Wrapper for Pinnacle Sports API

Pinnacle Documentation

Installation

$ pip install pinnacle

Usage

>>> from pinnacle.apiclient import APIClient
>>> api = APIClient('username', 'password')
>>> sport_ids = api.reference_data.get_sports()
>>> tennis_events = api.market_data.get_fixtures(33)

pinnacle's People

Contributors

bryce9876 avatar eugep avatar mangiafuoco avatar r-raymond avatar rozzac90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pinnacle's Issues

Error installing pinnacle-0.0.5 and pinnacle-0.0.4 on windows

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\

JSONDecodeError when Pinnacle returns a error page instead of data

>>> 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.

"No json object could be decoded"

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?

The fromDate must be a date in ISO 8601 format.

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

Error installing 0.0.7 on Windows

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?

Asking for help in not getting data from market data

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')

no reference

This API's refernce "Pinnacle document" is no link

Error while installing pinnacle wrapper

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!

Possible issue with boolean default value

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 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

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:~$

module error

ModuleNotFoundError: No module named 'pinnacle.apiclient'; 'pinnacle' is not a package

right after installation?

error installing

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

alt_line_id=None, win_risk_stake=WinRiskType.Risk.value, accept_better_line=Boolean.TRUE.name,

Package updating

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?

Error decoding json when there's no updates on "get_odds"

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.

Missing toDate. The toDate must be a date in ISO 8601 format.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.