My usual suggestion for new users is to use the documentation to create classe in their programs using information from the documentation. The classes should contain data variables for whatever each API call receives. Doing this exercise should show you where each piece of data can be found and how the classes relate to each other.
Warning api on python is slow and can only retrieve one horses odds
I'm enquiring about help with the api for horseracing based on the free api key, essentially not only is it 3 seconds before I get any kind of odds or python output which is a detriment if I want to do betting with live races but also it only allows me to get one horses odds at a time regardless if I use a for loop and try and chain requests. Is this a code issue or betfair issue?
payload = 'username=' + my_username + '&password=' + my_password
headers = {'X-Application': my_app_key, 'Content-Type': 'application/x-www-form-urlencoded'}
resp = requests.post('https://identitysso-cert.betfair.com/api/certlogin',data=payload,cert=('c:/Users/steph/OneDrive/Documents/2023/WORK/BETTING/client-2048.crt','c:/Users/steph/OneDrive/Documents/2023/WORK/BETTING/client-2048.pem.'),headers=headers)
json_resp=resp.json()
print(json_resp['loginStatus'])
SSOID = json_resp['sessionToken']
bet_url="https://api.betfair.com/exchange/betting/json-rpc/v1"
event_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEventTypes", "params": {"filter":{ "eventTypeIds":["7"],"marketCountries":["GB","AU"]}}, "id": 1}'
headers = {'X-Application': my_app_key, 'X-Authentication': SSOID, 'content-type': 'application/json'}
req = requests.post(bet_url, data=event_req.encode('utf-8'), headers=headers)
Leave a comment: