In this session we will look at how to access Irish racing in addition to UK racing.

This is a fairly simple process and involved editing one line in our MyAPILib library that we created. This will hardwire so to speak our library to pick up Irish and UK races in the same way that the library at the moment is hard wired to pick up only UK races. It might be better to write the subroutine so that we pass it a parameter indicating what markets to pick up.

First let us take the simple approach and simply change the routine to gather Irish and UK races. In our library we need to edit only one line within the getEvents subroutine. This line will now read as

market_catalogue_req = ‘{“jsonrpc”: “2.0”, “method”: “SportsAPING/v1.0/listMarketCatalogue”, “params”: {“filter”:{“eventTypeIds”:[‘+eventId+’],”marketCountries”:[“GB”, “IE”],”marketTypeCodes”:[“WIN”], “marketStartTime”:{“from”:”‘ + now + ‘”,”to”:”‘ + to + ‘”}},”sort”:”FIRST_TO_START”,”maxResults”:”100″,”marketProjection”:[“MARKET_START_TIME”,”RUNNER_DESCRIPTION”, “RUNNER_METADATA”, “EVENT”]}, “id”: 1}’

Notice how the marketCountries parameter has IE added to it. API NG takes two letter country codes as specified by ISO 3166 at

To make the getEvents sub routine more generic we need to modify it to receieve an extra parameter stating the required markets

def getEvents(appKey, sessionToken, eventId, reqMarkets):

Now we can call this routine with the following modified call

myMarkets = ‘”GB”,”IE”‘
races = myAPILib2.getEvents(appKey, sessionToken, horseRacingEventTypeID, myMarkets)

The market_catalogue_req initialisation line will now need changing to

market_catalogue_req = ‘{“jsonrpc”: “2.0”, “method”: “SportsAPING/v1.0/listMarketCatalogue”, “params”: {“filter”:{“eventTypeIds”:[‘+eventId+’],”marketCountries”:[‘+reqMarkets+’],”marketTypeCodes”:[“WIN”], “marketStartTime”:{“from”:”‘ + now + ‘”,”to”:”‘ + to + ‘”}},”sort”:”FIRST_TO_START”,”maxResults”:”100″,”marketProjection”:[“MARKET_START_TIME”,”RUNNER_DESCRIPTION”, “RUNNER_METADATA”, “EVENT”]}, “id”: 1}’