the-odds-api / samples-python

Python code samples for The Odds API
https://the-odds-api.com/
53 stars 21 forks source link

CommenceFromTime pulling older times #5

Closed sunb2021 closed 6 months ago

sunb2021 commented 6 months ago

Hi,

Setting CommenceFromTime I am still receiving games where the commence_time is from a couple of hours ago or currently in play.

odds_response = requests.get( f'https://api.the-odds-api.com/v4/sports/{SPORT}/odds', params={ 'api_key': API_KEY, 'markets': MARKETS, 'oddsFormat': ODDS_FORMAT, 'dateFormat': DATE_FORMAT, 'commenceTimeFrom': '2023-12-28T23:59:59Z', 'bookmakers': BOOKMAKERS } )

{'id': '3ca969d527694bc01e1714ef8138fd86', 'sport_key': 'basketball_euroleague', 'sport_title': 'Basketball Euroleague', 'commence_time': '2023-12-28T19:00:00Z', 'home_team': 'ASVEL Lyon Villeurbanne', 'away_team': 'Real Madrid', 'bookmakers': [{'key': 'betfair_ex_eu', 'title': 'Betfair', 'last_update': '2023-12-28T21:03:12Z', 'markets': [{'key': 'h2h', 'last_update': '2023-12-28T21:03:12Z', 'outcomes': [{'name': 'ASVEL Lyon Villeurbanne', 'price': 13.5}, {'name': 'Real Madrid', 'price': 1.04}]}, {'key': 'h2h_lay', 'last_update': '2023-12-28T21:03:12Z', 'outcomes': [{'name': 'ASVEL Lyon Villeurbanne', 'price': 110.0}, {'name': 'Real Madrid', 'price': 1.06}]}]}]}

{'id': 'd2a93438d888d3049cbcf324a13cf4d5', 'sport_key': 'americanfootball_ncaaf', 'sport_title': 'NCAAF', 'commence_time': '2023-12-28T19:15:00Z', 'home_team': 'Miami Hurricanes', 'away_team': 'Rutgers Scarlet Knights', 'bookmakers': [{'key': 'pinnacle', 'title': 'Pinnacle', 'last_update': '2023-12-28T21:16:51Z', 'markets': [{'key': 'h2h', 'last_update': '2023-12-28T21:16:51Z', 'outcomes': [{'name': 'Miami Hurricanes', 'price': 2.81}, {'name': 'Rutgers Scarlet Knights', 'price': 1.42}]}]}, {'key': 'betfair_ex_eu', 'title': 'Betfair', 'last_update': '2023-12-28T21:17:30Z', 'markets': [{'key': 'h2h', 'last_update': '2023-12-28T21:17:30Z', 'outcomes': [{'name': 'Miami Hurricanes', 'price': 2.54}, {'name': 'Rutgers Scarlet Knights', 'price': 1.5}]}, {'key': 'h2h_lay', 'last_update': '2023-12-28T21:17:30Z', 'outcomes': [{'name': 'Miami Hurricanes', 'price': 3.0}, {'name': 'Rutgers Scarlet Knights', 'price': 1.65}]}]}]}

sunb2021 commented 6 months ago

I was using 'upcoming' which makes commenceTimeFrom invalid.

Changed this to use a sport key which resolved the issue.