Usage of the API - Example
Scenario
-
Use one of the example Bet Angel Coupons to load all UK Horse racing Win & Place markets into a Watch List
-
Get the markets and selections so that we've got all of the market & selection Ids.
-
Set some Stored Values on one of the runners to define a stake and minimum price.
-
Apply an Automation Rules File to all of the markets (which could have been written to place a bet on any runner that has the stake and minimum price Stored Value set)
1) Apply the coupon
Send the JSON request to http://localhost:9000/api/guardian/v1.0/applyCoupon
{"couponName":"Ex: HR - UK - Win & Place - 2 column","clearOption":"CLEAR_GUARDIAN_AND_WATCH_LIST","watchListNumber":1}
Response:
{"status":"OK"}
Changes to the Bet Angel application:
-
14 markets are loaded into Guardian (the number of markets will depend on the market volume at the time you run the command)
-
Watch List 1 is made visible and displays the markets using the multi-column design of the coupon.
2) Get the market and selection Ids
Send the JSON request to http://localhost:9000/api/markets/v1.0/getMarkets
{"dataRequired":["ID","NAME","MARKET_START_TIME","EVENT_ID","EVENT_TYPE_ID","MARKET_TYPE","SELECTION_IDS","SELECTION_NAMES"]}
Response:
{"status":"OK","result":{"markets":[{"id":"1.206990726","name":"Wolverhampton 29th Nov - 15:50 5f Hcap","marketType":"WIN","eventId":"31937738_15:50","eventTypeId":"7","startTime":"2022-11-29T15:50:00+00:00","selections":[{"id":"35514509","name":"Pockley"},{"id":"27115875","name":"Never Dark"},{"id":"30152381","name":"Kim Wexler"},{"id":"19080425","name":"Second Collection"},{"id":"8111761","name":"Repartee"},{"id":"11235745","name":"The Daley Express"},{"id":"233020","name":"Autumn Flight"}]},{"id":"1.206990727","name":"Wolverhampton 29th Nov - 15:50 To Be Placed","marketType":"PLACE","eventId":"31937738_15:50","eventTypeId":"7","startTime":"2022-11-29T15:50:00+00:00","selections":[{"id":"35514509","name":"Pockley"},{"id":"27115875","name":"Never Dark"},{"id":"30152381","name":"Kim Wexler"},{"id":"19080425","name":"Second Collection"},{"id":"8111761","name":"Repartee"},{"id":"11235745","name":"The Daley Express"},{"id":"233020","name":"Autumn Flight"}]},{"id":"1.206990732","name":"Wolverhampton 29th Nov - 16:20 To Be Placed","marketType":"PLACE","eventId":"31937738_16:20","eventTypeId":"7","startTime":"2022-11-29T16:20:00+00:00","selections":[{"id":"16343426","name":"Victory March"},{"id":"36517299","name":"Lady Percival"},{"id":"41009684","name":"Peripeteia"},{"id":"35514508","name":"Fairmac"},{"id":"41176349","name":"Percy Jones"},{"id":"20922680","name":"The Dancing Poet"},{"id":"32393193","name":"Mickydee"}]},{"id":"1.206990731","name":"Wolverhampton 29th Nov - 16:20 1m6f Hcap","marketType":"WIN","eventId":"31937738_16:20","eventTypeId":"7","startTime":"2022-11-29T16:20:00+00:00","selections":[{"id":"16343426","name":"Victory March"},{"id":"36517299","name":"Lady Percival"},{"id":"41009684","name":"Peripeteia"},{"id":"35514508","name":"Fairmac"},{"id":"41176349","name":"Percy Jones"},{"id":"20922680","name":"The Dancing Poet"},{"id":"32393193","name":"Mickydee"}]},{"id":"1.206990739","name":"Wolverhampton 29th Nov - 16:50 To Be Placed","marketType":"PLACE","eventId":"31937738_16:50","eventTypeId":"7","startTime":"2022-11-29T16:50:00+00:00","selections":[{"id":"17103457","name":"Baccarat Baby"},{"id":"7450122","name":"Calypso"},{"id":"908572","name":"Wiltshire"},{"id":"50639455","name":"Pacos Pride"},{"id":"50639456","name":"Self Aclaim"},{"id":"49987722","name":"Ceilidh King"},{"id":"46783","name":"Strike Alliance"},{"id":"50307212","name":"Lough Leane"},{"id":"50047461","name":"Moonfleet Moment"},{"id":"49526286","name":"Urban Champion"},{"id":"47573420","name":"Landlordtothestars"},{"id":"49198993","name":"Sao Timothy"}]},{"id":"1.206990738","name":"Wolverhampton 29th Nov - 16:50 7f Mdn Stks","marketType":"WIN","eventId":"31937738_16:50","eventTypeId":"7","startTime":"2022-11-29T16:50:00+00:00","selections":[{"id":"17103457","name":"Baccarat Baby"},{"id":"7450122","name":"Calypso"},{"id":"908572","name":"Wiltshire"},{"id":"50639455","name":"Pacos Pride"},{"id":"50639456","name":"Self Aclaim"},{"id":"49987722","name":"Ceilidh King"},{"id":"46783","name":"Strike Alliance"},{"id":"50307212","name":"Lough Leane"},{"id":"50047461","name":"Moonfleet Moment"},{"id":"49526286","name":"Urban Champion"},{"id":"47573420","name":"Landlordtothestars"},{"id":"49198993","name":"Sao Timothy"}]},{"id":"1.206990751","name":"Wolverhampton 29th Nov - 17:20 7f Mdn Stks","marketType":"WIN","eventId":"31937738_17:20","eventTypeId":"7","startTime":"2022-11-29T17:20:00+00:00","selections":[{"id":"50148694","name":"Mohatu"},{"id":"3755728","name":"Good Karma"},{"id":"38988862","name":"Overactive"},{"id":"47029311","name":"Dancing Gypsy"},{"id":"49257735","name":"Mr Boson"},{"id":"12560","name":"Ski Jump"},{"id":"48708637","name":"Balmaha"},{"id":"50639457","name":"Boucle"},{"id":"50307187","name":"Optik"},{"id":"2545639","name":"Silky Smooth"},{"id":"50370316","name":"Jimmy Lifestyle"}]},{"id":"1.206990752","name":"Wolverhampton 29th Nov - 17:20 To Be Placed","marketType":"PLACE","eventId":"31937738_17:20","eventTypeId":"7","startTime":"2022-11-29T17:20:00+00:00","selections":[{"id":"50148694","name":"Mohatu"},{"id":"3755728","name":"Good Karma"},{"id":"38988862","name":"Overactive"},{"id":"47029311","name":"Dancing Gypsy"},{"id":"49257735","name":"Mr Boson"},{"id":"12560","name":"Ski Jump"},{"id":"48708637","name":"Balmaha"},{"id":"50639457","name":"Boucle"},{"id":"50307187","name":"Optik"},{"id":"2545639","name":"Silky Smooth"},{"id":"50370316","name":"Jimmy Lifestyle"}]},{"id":"1.206990746","name":"Wolverhampton 29th Nov - 17:50 To Be Placed","marketType":"PLACE","eventId":"31937738_17:50","eventTypeId":"7","startTime":"2022-11-29T17:50:00+00:00","selections":[{"id":"40626691","name":"King Of Conquest"},{"id":"40920672","name":"Court Of Session"},{"id":"23983749","name":"Alexander James"},{"id":"38964332","name":"Excel Power"},{"id":"25577504","name":"Amaysmont"},{"id":"18197157","name":"Young Fire"},{"id":"20548484","name":"Light Up Our Stars"},{"id":"8145922","name":"Hes A Gentleman"},{"id":"40034780","name":"Spacer"},{"id":"12085421","name":"Hieronymus"}]},{"id":"1.206990745","name":"Wolverhampton 29th Nov - 17:50 1m Hcap","marketType":"WIN","eventId":"31937738_17:50","eventTypeId":"7","startTime":"2022-11-29T17:50:00+00:00","selections":[{"id":"40626691","name":"King Of Conquest"},{"id":"40920672","name":"Court Of Session"},{"id":"23983749","name":"Alexander James"},{"id":"38964332","name":"Excel Power"},{"id":"25577504","name":"Amaysmont"},{"id":"18197157","name":"Young Fire"},{"id":"20548484","name":"Light Up Our Stars"},{"id":"8145922","name":"Hes A Gentleman"},{"id":"40034780","name":"Spacer"},{"id":"12085421","name":"Hieronymus"}]},{"id":"1.206990758","name":"Wolverhampton 29th Nov - 18:20 To Be Placed","marketType":"PLACE","eventId":"31937738_18:20","eventTypeId":"7","startTime":"2022-11-29T18:20:00+00:00","selections":[{"id":"35323716","name":"Inexplicable"},{"id":"23943024","name":"Galactic Glow"},{"id":"40525259","name":"Capparis"},{"id":"38369203","name":"Lockdown Lass"},{"id":"42071965","name":"Waltzing Intime"},{"id":"21806750","name":"Well Prepared"},{"id":"38772330","name":"Raffles Rebel"},{"id":"27753127","name":"Vitesse Du Son"},{"id":"35400158","name":"Broomy Law"},{"id":"35912907","name":"Lhebayeb"},{"id":"41645780","name":"Our Noble Lord"},{"id":"40027984","name":"Pearl Of Kuwait"}]},{"id":"1.206990757","name":"Wolverhampton 29th Nov - 18:20 1m Hcap","marketType":"WIN","eventId":"31937738_18:20","eventTypeId":"7","startTime":"2022-11-29T18:20:00+00:00","selections":[{"id":"35323716","name":"Inexplicable"},{"id":"23943024","name":"Galactic Glow"},{"id":"40525259","name":"Capparis"},{"id":"38369203","name":"Lockdown Lass"},{"id":"42071965","name":"Waltzing Intime"},{"id":"21806750","name":"Well Prepared"},{"id":"38772330","name":"Raffles Rebel"},{"id":"27753127","name":"Vitesse Du Son"},{"id":"35400158","name":"Broomy Law"},{"id":"35912907","name":"Lhebayeb"},{"id":"41645780","name":"Our Noble Lord"},{"id":"40027984","name":"Pearl Of Kuwait"}]},{"id":"1.206990765","name":"Wolverhampton 29th Nov - 18:50 To Be Placed","marketType":"PLACE","eventId":"31937738_18:50","eventTypeId":"7","startTime":"2022-11-29T18:50:00+00:00","selections":[{"id":"10124538","name":"Sicario"},{"id":"11782744","name":"International Law"},{"id":"17012328","name":"Jenny Ren"},{"id":"35765716","name":"Crystal Guard"},{"id":"41667719","name":"My Brother Jack"},{"id":"13126138","name":"Bobo"},{"id":"28179477","name":"Delightfilly"},{"id":"43930433","name":"Gulick"},{"id":"33808814","name":"Tanglewood Tales"},{"id":"36346967","name":"Many Words"},{"id":"20034792","name":"Deconso"}]},{"id":"1.206990764","name":"Wolverhampton 29th Nov - 18:50 1m4f Hcap","marketType":"WIN","eventId":"31937738_18:50","eventTypeId":"7","startTime":"2022-11-29T18:50:00+00:00","selections":[{"id":"10124538","name":"Sicario"},{"id":"11782744","name":"International Law"},{"id":"17012328","name":"Jenny Ren"},{"id":"35765716","name":"Crystal Guard"},{"id":"41667719","name":"My Brother Jack"},{"id":"13126138","name":"Bobo"},{"id":"28179477","name":"Delightfilly"},{"id":"43930433","name":"Gulick"},{"id":"33808814","name":"Tanglewood Tales"},{"id":"36346967","name":"Many Words"},{"id":"20034792","name":"Deconso"}]}]}}
3) Set a Stored Value on Calypso on both the Win & Place markets
Using the data above, we can extract that the market Id for the 16:50 Win market is 1.206990738, the Place market is 1.206990739 and Calypso has a selection Id of 7450122.
We want to set two Stored Values on that runner in the Win Market, so that STAKE = 10 and MIN_PRICE = 4
We also want to set a STAKE of 5 and a MIN_PRICE of 1.6 on that runner in the Place Market.
So we send the JSON request to http://localhost:9000/api/automation/v1.0/setStoredValues
{"writeToMarketLog":true,"markets":[{"id":"1.206990738","selections":[{"id":"7450122","sharedValues":[{"n":"STAKE","v":10},{"n":"MIN_PRICE","v":4}]}]},{"id":"1.206990739","selections":[{"id":"7450122","sharedValues":[{"n":"STAKE","v":5},{"n":"MIN_PRICE","v":1.6}]}]}]}
Response:
{"status":"OK"}
Changes to the Bet Angel application:
We see these lines in the respective markets' logs
29/11/2022 16:05:09: [API] : Set Stored Value (Shared) for Calypso: STAKE = 10
29/11/2022 16:05:09: [API] : Set Stored Value (Shared) for Calypso: MIN_PRICE = 4
29/11/2022 16:05:09: [API] : Set Stored Value (Shared) for Calypso: STAKE = 5
29/11/2022 16:05:09: [API] : Set Stored Value (Shared) for Calypso: MIN_PRICE = 1.6
4) Apply an Automation Rules File to all markets
Assuming that we have already created an Automation Rules File in Bet Angel called 'Place Bet Based on Stored Values' which looks for the STAKE and MIN_PRICE stored values and places a bet when the price is above the MIN_PRICE, we can assign that to each of the markets.
Send the JSON request to http://localhost:9000/api/guardian/v1.0/applyRules
{"rulesFileName":"Place Bet Based on Stored Values","marketsFilter":{"filter":"ALL"},"guardianRulesColumn":1}
Response:
{"status":"OK"}
Changes to the Bet Angel application:
The rules file has been applied to Guardian. Guardian can then scan the market prices and run the rules as required.
Note: Error Handling
If we had happened to get the market Id wrong for the Place market in part 3, here is an example of the response we would have received showing the error list with code & error message:
{"status":"PROCESSED_WITH_ERRORS","errors":[{"code":"UNKNOWN_MARKET","msg":"Market 1.206990799 has not been added to Bet Angel"}]}