In this session we will ask the API for a list of all GB horse races due to run from the current time up to midnight. With this information our program can access the race ID’s for each race along with other information such as off times. We are then in a position to get individual horse ID’s. Horse ID’s and Race ID’s are needed to strike bets.
Step 1 We need to append the following statements to our testlib file in IDLE (Remember indentation is relevant in Python)
races = myAPILib.getEvents(appKey, sessionToken, horseRacingEventTypeID)
if races != -1:
for race in races:
print (race[‘marketId’])
race[‘marketStartTime’] = myAPILib.checkSummerTime(race[‘marketStartTime’])
print (race[‘marketStartTime’])
print ()
Step 2 Looking at the above we can see that two new subroutines need to be added to the myAPILib file, namely getEvents and checkSummerTime. The latter checks for summer time and edits the Betfair off times accordingly otherwise all times returned by Betfair would be one hour out here in the UK.
You can copy and paste a complete to date myAPILib content from the following link myAPILib
The output should be a list of race ID’s and offtime details such as
1.113839006
2014-04-24T19:55:00.000Z
1.113839020
2014-04-24T20:15:00.000Z
Well done your program now has the race details for the day safely stored. In the next session we will look at getting hold of horse ID’s
Hi Mate – quick question with summertime times: would it be an idea to disregard timezones? The Betfair APING docs mention all times being returned in GMT. I wondering if it’d be better to use:
strftime(“%Y-%m-%d %H:%M:%S”, gmtime())
…and disregard BST or other timezones in a non-interactive bot.
Or is there a reason for BST correction I’m overlooking?
Hi, I am based in the UK and if you do not correct for BST your race times as supplied by the APING will be one hour out half of the year.