In this session we will look at how to access the array of runner meta data available through the API.

There is all kinds of data we can access, for example the draw, sire damsire, cloth number, days since last run and so on. For a complete list of what can be accessed see https://api.developer.betfair.com/services/webapps/docs/display/1smk3cen4v3lu3yomq5qye0ni/Runner+Metadata+Description

To access this data we first need to make a small change to the getEvents procedure in myAPILib. We need to add RUNNER_METADATA as an extra marketProjection parameter (see below)

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”, “RUNNER_METADATA”]}, “id”: 1}’

Note– dont copy and paste the above, add the extra RUNNER_METADATA text manually

To access say the STALL_DRAW data item in our testLib program we can add the following bit of code

for selection in allRunners:
  print (selection[‘runnerName’] + ” ” + str(selection[‘selectionId’]) )
  print (‘Draw is ‘ + selection[‘metadata’][‘STALL_DRAW’])

The third line is one you will need to add the other two are just for points of reference and are already in your file. If you copy and paste it make sure that you change all the wonky quote marks to single quotes. As I mentioned before WordPress has a mind of its own when displaying quotes and its tedious for me to edit them on the wordpress site.

Advertisements