In this session we will access horse names and horse Id’s for the races we accessed in the previous session.
Getting hold of these two pieces of extra data, along with a host of other horse specific data, is quite simple. We simply need to add an extra parameter to our call to listMarketCatalogue within the getEvents subroutine in the myAPILib file.
Step 1 In the IDLE go to the myAPILIb file and locate the line of code within the getEvents subroutine that begins with
market_catalogue_req = ‘{“jsonrpc”: “2.0”, “method”: etc etc etc etc
Step 2 Edit the line manually (ie dont copy and paste) adding ,”RUNNER_DESCRIPTION” so that it now reads
market_catalogue_req = ‘{“jsonrpc”: “2.0”, “method”: “SportsAPING/v1.0/listMarketCatalogue”, “params”: {“filter”:{“eventTypeIds”:[‘+eventId+’],”marketCountries”:[“GB”],”marketTypeCodes”:[“WIN”], “marketStartTime”:{“from”:”‘ + now + ‘”,”to”:”‘ + to + ‘”}},”sort”:”FIRST_TO_START”,”maxResults”:”100″,”marketProjection”:[“MARKET_START_TIME”,”RUNNER_DESCRIPTION”]}, “id”: 1}’
Step 3 We now need to access within the testlib program the runner data that is going to be passed back. The updated code needed can be found at testlib.txt
Don’t forget to add your username, password and app key values if using this code as is. Alternatively you can just copy and paste the final section of the code from the getEvents call onwards, into your testlib file, replacing the code already there.
The output provided should be of the form
1.113839006
2014-04-24T19:55:00.000Z
Baltic Brave 7767233
Flashy Queen 7552880
Iseemist 7185307
Miss Brazil 7645993
Bowsers Bold 7362173
Seven Lucky Seven 7361654
Black Vale 7430139
1.113839020
2014-04-24T20:15:00.000Z
One Boy 7200987
Orient Class 7652539
Noble Asset 7422371
Camanche Grey 7642225
Danfazi 7200986
Tinsill 7407448
Distant Past 7943530
Under Approval 7320027
Well done you now have access to both market id’s and horse id’s and names.