rozzac90 / pinnacle

Python Wrapper for Pinnacle Sports API
MIT License
52 stars 26 forks source link

The fromDate must be a date in ISO 8601 format. #14

Open jeckjeck opened 6 years ago

jeckjeck commented 6 years ago

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

jeckjeck commented 6 years ago

Solved. Uncommented line 29 and 30 in betting.py file in pinnacle/endpoints/betting.py

For example, mine is located in: C:/Users/jeck/Miniconda3/envs/django/Lib/site-packages/pinnacle/endpoints/betting.py

# from_date = pd.to_datetime(from_date).isoformat() if from_date is not None else from_date # to_date = pd.to_datetime(to_date).isoformat() if to_date is not None else to_date

Then this works:

from pinnacle.apiclient import APIClient from datetime import datetime, timedelta

username = 'username' password = 'password'

api = APIClient(username, password)

last_x_date_time = datetime.now() - timedelta(days = 20)

s = api.betting.get_bets( betlist='RUNNING',from_date=last_x_date_time.strftime('%Y-%m-%d'), to_date='2018-06-21')

magiclevinho commented 5 years ago

Thank You! This solved my problem!