Bet Angel
×
Full Guide

Usage of the API - Example 2

 

Scenario

 
Having already added a market to Bet Angel ( in this case the English Premier League - Winner market )
 
 

1) Place £10 lay bets at 1.10 on the top three selections

 
Send the JSON request to  http://localhost:9000/api/betting/v1.0/placeBets
 
{"marketId":"1.214607388","globalSettings":{"action":"NONE"},"async":false,"betsToPlace":[{"selectionId":"47999","type":"LAY","price":1.10,"stake":10.0},
{"selectionId":"1096","type":"LAY","price":1.10,"stake":10.0},
{"selectionId":"56323","type":"LAY","price":1.10,"stake":10.0}]}
 
Response:
 
{"status":"OK","result":{"bets":[{"betToPlace":{"selectionId":"47999","type":"LAY","price":1.1,"stake":10.0},"status":"OK","betRef":"313259260005","stakeMatched":0.0},{"betToPlace":{"selectionId":"1096","type":"LAY","price":1.1,"stake":10.0},"status":"OK","betRef":"313259260006","stakeMatched":0.0},{"betToPlace":{"selectionId":"56323","type":"LAY","price":1.1,"stake":10.0},"status":"OK","betRef":"313259260007","stakeMatched":0.0}]}}
 
Note:
 
The response contains the details of the bet placement requests, the fact each was placed OK, and provides the reference of each bet. As the bets were offered below market price, they are unmatched, so the stakeMatched in each case is zero.
 
 

2) Increase the stake on one of the bets and change the price of another

 
Send the JSON request to http://localhost:9000/api/betting/v1.0/modifyBets
 
{"marketId":"1.214607388","async":false,"betsToModify":[{"betRef":"313259260005","newStake":12.67},{"betRef":"313259260006","newPrice":1.15}]}
 
Response:
 
{"status":"OK","result":{"bets":[{"betToModify":{"betRef":"313259260005","newStake":12.67},"status":"OK","additionalBetRef":"313259360782","additionalBetStakeMatched":0.0},{"betToModify":{"betRef":"313259260006","newPrice":1.15},"status":"OK","newBetRef":"313259360429","stakeMatched":0.0}]}}
 
Note:
 
By increasing the stake, an additional bet was created by betfair for the extra amount and that bet reference has been returned.
By changing the price of a bet, betfair issued a new bet reference.
 
 

3) Get details of the unmatched bets in the market

 
Send the JSON request to http://localhost:9000/api/markets/v1.0/getMarketBets
 
{"marketId":"1.214607388","filter":{"option":"ALL_UNMATCHED"}}
 
Response:
 
{"status":"OK","result":{"unmatchedBets":[{"selectionId":"47999","betRef":"313259360782","type":"LAY","price":1.1,"stake":2.67,"atInplay":"CANCEL"},{"selectionId":"1096","betRef":"313259360429","type":"LAY","price":1.15,"stake":10.0,"atInplay":"CANCEL"},{"selectionId":"56323","betRef":"313259260007","type":"LAY","price":1.1,"stake":10.0,"atInplay":"CANCEL"},{"selectionId":"47999","betRef":"313259260005","type":"LAY","price":1.1,"stake":10.0,"atInplay":"CANCEL"}]}}
 
 

4) Cancel the third bet that was originally placed

 
Send the JSON request to http://localhost:9000/api/betting/v1.0/cancelBets
 
{"marketId":"1.214607388","filterOption":"SPECIFIED_BET_REFS","betRefs":["313259260007"],"type":"ALL","async":false}
 
Response:
 
{"status":"OK","result":{"bets":[{"status":"OK","betRef":"313259260007","stakeCancelled":10.0}]}}
 
 

4b) Attempt to Cancel the same bet again to trigger an error message

 
Send the JSON request to http://localhost:9000/api/betting/v1.0/cancelBets
 
{"marketId":"1.214607388","filterOption":"SPECIFIED_BET_REFS","betRefs":["313259260007"],"type":"ALL","async":false}
 
Response:
 
{"status":"PROCESSED_WITH_ERRORS","result":{"bets":[{"status":"FAILED","betRef":"313259260007","error":{"code":"UNKNOWN_BET_REF","msg":"Bet 313259260007 has not been found as an unmatched bet"}}]}}
 
 

5) Decrease the stakes of the two £10 bets in the market to be £5

 
Send the JSON request to http://localhost:9000/api/betting/v1.0/modifyBets
 
{"marketId":"1.214607388","async":false,"betsToModify":[{"betRef":"313259260005","newStake":5},{"betRef":"313259360429","newStake":5}]}
 
Response:
 
{"status":"OK","result":{"bets":[{"betToModify":{"betRef":"313259260005","newStake":5.0},"status":"OK","stakeCancelled":5.0},{"betToModify":{"betRef":"313259360429","newStake":5.0},"status":"OK","stakeCancelled":5.0}]}}
 
Note:
 
There is no change of bet references when decreasing stake, but the response shows that £5.00 was successfully cancelled from the two bets to change the stakes to the requested amounts.
 
 

6) Get details of the unmatched bets in the market again

 
Send the JSON request to http://localhost:9000/api/markets/v1.0/getMarketBets
 
{"marketId":"1.214607388","filter":{"option":"ALL_UNMATCHED"}}
 
Response:
 
{"status":"OK","result":{"unmatchedBets":[{"selectionId":"47999","betRef":"313259360782","type":"LAY","price":1.1,"stake":2.67,"atInplay":"CANCEL"},{"selectionId":"1096","betRef":"313259360429","type":"LAY","price":1.15,"stake":5.0,"atInplay":"CANCEL"},{"selectionId":"47999","betRef":"313259260005","type":"LAY","price":1.1,"stake":5.0,"atInplay":"CANCEL"}]}}
 
 

7) Cancel all unmatched bets in the market

 
Send the JSON request to http://localhost:9000/api/betting/v1.0/cancelBets
 
{"marketId":"1.214607388","filterOption":"ALL","type":"ALL","async":false}
 
Response:
 
{"status":"OK","result":{"bets":[{"status":"OK","betRef":"313259260005","stakeCancelled":5.0},{"status":"OK","betRef":"313259360429","stakeCancelled":5.0},{"status":"OK","betRef":"313259360782","stakeCancelled":2.67}]}}
 
Note:
 
The response shows the bets references that were cancelled and the stakes cancelled from each.
 
 

8) Get details of the unmatched bets in the market one more time to show that all the bets have been cancelled

 
Send the JSON request to http://localhost:9000/api/markets/v1.0/getMarketBets
 
{"marketId":"1.214607388","filter":{"option":"ALL_UNMATCHED"}}
 
Response:
 
{"status":"OK","result":{"unmatchedBets":[]}}
 
Note:
 
The unmatchedBets list is now empty.