I have events (matches i.e. Richmond vs Collingwood) and their respective IDs for a given competition, in my case AFL, however when trying to get the market IDs associated with these events, the API only gives the competition market ID as a response. How do I change my request so that this information is also given?
The Python library I am using is: https://github.com/liampauling/betfair
The following is the code I'm using to 1. get the competition ID for afl, 2. get the event IDs and names for all of the matches in that competition, and 3. get the market IDs for the events.
In [1]:
competition_id = client.betting.list_competitions(filter=filters.market_filter(event_ids=event_ids))[-1].competition.id
Out [1]:
11897406
In [2]:
events = client.betting.list_events(
filter=filters.market_filter(
competition_ids=[competition_id]))
for event_result in events:
print(event_result.event.name, event_result.event.id)
Out[2]:
AFL 28159788
Brownlow Medal 2019 28927640
Hawthorn v Western Bulldogs 29182265
North Melbourne v Brisbane 29182264
Gold Coast v Fremantle 29182266
Port Adelaide v Carlton 29182261
Favourites To Win 29203764
Geelong v Melbourne 29182263
West Coast v GWS 29182262
Sydney v Adelaide 29182257
Women's AFL 28113600
Essendon v St Kilda 29182258
AFL Round 2 Multis 29195364
Adelaide (W) v Carlton (W) 29199747
In [3]:
AFL_market_catalogue = client.betting.list_market_catalogue(filter=filters.market_filter(event_ids=event_ids),
market_projection=['EVENT', 'COMPETITION'])[0]
Out [3]:
{"marketId":"1.148783689","marketName":"Premiers 2019","totalMatched":293415.056733,"competition":{"id":"11897406","name":"AFL"},"event":{"id":"28159788","name":"AFL","countryCode":"AU","timezone":"GMT","openDate":"2099-01-01T00:00:00.000Z"}}
As shown in the output of 3, the only marketID returned is that of the premiers 2019 - when I need Hawthorn v Western Bulldogs, North Melbourne v Brisbane and so on.