BeT API - Connecting the cart and calculating rates
Important information before integrating the calculation of rates in our system.
Some clarifications:
Bet is a set of data for 1 outcome in a match made by a user. The bet can be part of both a single and an express.
Coupon is a set of bets or outcomes that a player places. The coupon consists of separate bets. If the coupon includes 1 bet, then it is a single bet. If the coupon includes more than one bet, it is an express bet.
To connect rate calculation in our system, you need to follow these steps:
1. Ask for a partner ID, and register your personal user in our system. User registration should be registered as follows:
Registering for the test server (where the integration will take place)
or for production server where your system will run
2. After the user is successfully registered, you need to log in to our system with the data that you provided during registration. Successful authorization is the fact that you returned an object with your user ID :
{"d": {"UserId": "1344225"}}
Also, upon successful authorization, cookies and session are returned in response. This data must be transmitted in order to save the bet with us.
3. Once you are logged in to our system, you can send us data to save your bet or coupon.
4. After the calculation of the bet, you will be sent the result of the COUPON (win, loss or return of the bet). Please note - We are sending the general result for the coupon , we do not send the result for a specific rate. If you need to receive data, you can take it yourself using the API at any time.
List of parameters for API
Parameter | Description |
---|---|
{HOST_API} | Url to send requests to. Available from Administrator . |
{PARTNER_ID_API} | Number , which will be issued for the owner of the api. This partner number identifies you in the Shan system. Available from Administrator . |
User registration:
First, you need to register a user through which bids will be accepted. This user will be one in our system, through this user, bets will be accepted.
RETURN attention to the nesting of data in the example: "registerModel"
Data upload type: POST
Url to which the request is sent:
{HOST_API}/WebServices/Mobile/BetsStoreService.asmx/Register/
Data to send:
Parameter | Description |
---|---|
Email |
User Mail |
Password |
User password |
registr_phone |
User's phone number |
currency |
User currency, 3 characters |
partner |
partner id, issued during integration |
ext_name |
The parameter that starts with ext_ is optional and will be available later as name or another name that will be specified. |
Please note:
We do not require that you submit reliable data. You can specify the phone number and Currency - any
$dataSend = array("registerModel"=>array(
"Email"=>"[email protected]",
"Password"=>"tq354j533ge",
"registr_phone"=>"050986542585",
"currency"=>"USD",
"partner"=>"{PARTNER_ID_API}"
));
$request = WGet::post_request('{HOST_API}/WebServices/Mobile/BetsStoreService.asmx/Register/',json_encode($dataSend));
User authorization:
Url to which the request is sent:
{HOST_API} /WebServices/BCService.asmx/LogIn/
Data sending type: POST
Data to send:
Parameter | Description |
---|---|
login |
User login |
password |
User password |
Attention! During authorization, cookies
is received in response, this cookie must be saved, and on subsequent requests it must be sent.
An object is returned in response:
{"d": {"UserId": "1344225"}}
Inside it is the user ID if the authorization was successful. If authorization fails, then the object will be empty .
{"d":{}}
$dataSend = array(
"login"=>'[email protected]',
"password"=>"tq354j533ge"
);
$request = WGet::post_request('{HOST_API}/WebServices/BCService.asmx/LogIn/',json_encode($dataSend));
Save coupon
Please note that we do not require you to send real bet amounts in the coupon. You can specify a static number if you need it. For example "realAmount" => "1", will always come to us in the amount of 1USD. Although the user placed a completely different stake.
Url to which the request is sent:
{HOST_API}/bet/place/
Parameter | Description |
---|---|
list_bets |
Betpointers - What is a betpointer |
realAmount |
Bet Amount |
currency |
Coupon Currency |
lang |
Language in which we save the rate |
remote_host |
Url to which we will then send the results of the coupon calculation |
rate_mode |
Option for accepting a coupon, depending on the change in the coefficient. reject - do not accept when changing the coefficient. accept - accept anyway. Default accept. |
Please note that you need to specify the host of your site (test or production, it is to this URL that the results will be sent at the rate.)
remote_host - you need to specify without a slash, just the site url.
Sending will be carried out on url: hostUrl/api/bet/result
Example of sending data for SINGLE :
$dataSend = array(
"data"=>array(
"list_bets"=>array('live#187183313|17|9|0.5#1.02'),
"realAmount"=>"150",
"currency"=>"USD",
"lang"=>"ru",
"remote_host"=>"http://Yoursite.name.com",
"rate_mode"=>"accept"
)
);
$request = WGet::post_request('{HOST_API}/bet/place/',json_encode($dataSend));
Example of sending data for EXPRESS :
$dataSend = array(
"data"=>array(
"list_bets"=>array('live#187183313|17|9|0.5#1.02', 'line#217118313|1|1|0#3.12'),
"realAmount"=>"150",
"currency"=>"USD",
"lang"=>"ru",
"remote_host"=>"http://Yoursite.name.com",
"rate_mode"=>"accept"
)
);
$request = WGet::post_request('{HOST_API}/bet/place/',json_encode($dataSend));
Answer to the sent SINGLE bet
IMPORTANT !!!
You can save the data at your discretion, but the main thing is to save: betCode
, it is on it that the status of the bet will come
{
"betCode": "607vtec620",
"status": 1,
"errorCode": 0,
"fullErrorCode": 0,
"d": {
"BetHeadDetail": {
"LiveType": "Usual",
"AmountOut": 30.85,
"CoefOrig": 1.99,
"BetCode": "607vtec620",
"BetDate": 1581249549000,
"Bet": 15.5,
"Status": 1,
"CountEvents": 1,
"BetId": "607vtec620",
"Coef": 1.99,
"IsLive": false,
"PosWin": 30.85
}
},
"__type": "BR.Web.BLL.Objects.Bets.BetInfo",
"BetsContentDataList": [
{
"LinesId": 224751652,
"CountResults": 0,
"Outcome": 1,
"TournamentName": "Spanish Championship. Example",
"IsBonus": false,
"CoefOrig": 1.99,
"Coef": 1.99,
"BetName": "P1",
"Result": "No result yet",
"SportId": 1,
"IsLive": true,
"EventDate": 1581245100000,
Teams: Espanyol - Mallorca
}
],
"errorMessage": ""
}
Response to the sent EXPRESS rate
IMPORTANT !!!
You can save the data at your discretion, but the main thing is to save: betCode
, it is on it that the status of the bet will come
{
"betCode": "76r9i02g9x",
"status": 1,
"errorCode": 0,
"fullErrorCode": 0,
"d": {
"BetHeadDetail": {
"LiveType": "Usual",
"AmountOut": 1843.5,
"BetCode": "76r9i02g9x",
"BetDate": 1597146488000,
"Bet": 150,
"Status": 1,
"CountEvents": 2,
"BetId": "76r9i02g9x",
"Coef": 12.29,
"PosWin": 1843.5
}
},
"__type": "BR.Web.BLL.Objects.Bets.BetInfo",
"BetsContentDataList": [{
"LinesId": 250614983,
"Outcome": 1,
"TournamentName": "China Championship",
"Coef": 4.82,
"BetName": "Total (2.5) B",
"Result": "No result yet",
"SportId": 1,
"IsLive": true,
"EventDate": 1597139100000,
"Teams": "Shijiazhuang Ever Bright - Tianjin Teda",
}, {
"LinesId": 250612386,
"Outcome": 1,
"TournamentName": "KVO. Championship of South Korea",
"Coef": 2.55,
"BetName": "Handicap 1 (-4.5)",
"Result": "No result yet",
"SportId": 5,
"IsLive": true,
"EventDate": 1597138200000,
"Teams": "Dusan Bears - Samsung Lions",
}],
"errorMessage": ""
}
Description of fields in response:
Parameter | Description |
---|---|
betCode |
Unique bet number in our system |
errorCode |
This field can have two values.
|
fullErrorCode |
If the " errorCode" field is 1. You can check the fullErrorCode field. This field can have different values.
|
errorMessage |
System error labels are stored in text format error_exist_bet - there is no such outcome anymore error_repeat_bet_data - bets from one match on different events. For example, W2 and Total over 1 were added to the express from the same match. error_block_bet_data - the bet is currently temporarily blocked for acceptance. |
AmountOut - PosWin |
Coupon winning amount |
betCode - BetId |
Unique bet number in our system |
Bet |
User bet |
CountEvents |
Number of bets per coupon |
Coef |
Odds per outcome |
IsLive |
Where the bet was made. In line or in Live. Can take values: false or true |
LinesId |
Go to match |
EventDate |
Match date |
Sending calculation results and coupon statuses
When a bet is added to our system and calculated, a COUPON result is sent to you. Please note that you receive a RESULT or COUPON STATUS . If you need coupon rate data , see the API below.
Example of sending data:
{
"remote_host": "https://sitepartner_url.com",
"Heads": [{
"KeyHead": {
"Id": "344143",
"BarCode": "x9c52i8411"
},
"Status": 2,
"ExtStatus": 0,
"AmountOut": 11130,
"DateRecive": "1597075782"
}]
}
ЕСЛИ НЕСКОЛЬКО СТАВОК:
{
"remote_host": "https://sitepartner_url.com",
"Heads": [{
"KeyHead": {
"Id": "313",
"BarCode": "75vz48t935"
},
"Status": 2,
"ExtStatus": 0,
"AmountOut": 19.85,
"DateRecive": "1592937968"
}, {
"KeyHead": {
"Id": "312",
"BarCode": "77i0r6e15t"
},
"Status": 2,
"ExtStatus": 0,
"AmountOut": 12.51,
"DateRecive": "1592937280"
}]
}
You need to check the Status; fields and optionally ExtStatus .
This Status field can have different values.
- 2 - coupon won
- 4 - the coupon is calculated as a loss
This ExtStatus field has two values.
- 0 - coupon has no changes.
- 1 - One or more games in the coupon are calculated with a change in the odds.
ExtStatus = 1.
For example, this happens when the game has been canceled. The game will be settled with odds 1.
Summing up the statuses:
Status = 2 and ExtStatus = 0 - Win ;
Status = 4 and ExtStatus = 0 - Lost;
Status = 2 and ExtStatus = 1 - Return (by default, we specify the coefficient 1)
IMPORTANT !!!
You need to recalculate the coupon if we send a new status.
For example. We sent status 4. And later we can send status 2. You need to add money to the user.
And also. We sent status 2. And later we can send status 4. You should charge the user's money. This is due to the fact that sometimes the wrong score of the match comes. In this case, we perform the recalculation manually
Parameter | Description |
---|---|
Id |
The ID of the bet in our system can be ignored. |
BarCode |
Unique coupon number |
Status |
Coupon status. Maybe Win = 2, Lose = 4, Refund. |
ExtStatus |
Coupon distribution status, if there was a refund. It can take two values. 0 and 1. |
AmountOut |
Possible winnings |
DateRecive |
Date and time of calculation |
Request example:
$dataSend = array(
"begin"=> "1549922400",
"count"=> 10,
"end"=> "1552428000",
"page"=> 1,
"periodType"=> 0,
"showLossBets"=> true,
"showWinBets"=> true,
"showWorkBets"=> true
);
$request = WGet::post_request('http://partner_site.com/GetUserBets/',json_encode($dataSend));
Sample response:
Getting Active and Bid History of a user
The user's bids are received by the link:
{HOST_API}/GetUserBets/
Parameter | Description |
---|---|
begin |
Start date of bet withdrawal selection |
count |
Number of bids displayed per page |
end |
End date of selection of rates |
page |
Active page |
periodType |
Bet type (active, history) |
showLossBets |
Show losers |
showWinBets |
Show winners |
showWorkBets |
Show not calculated |
Request example:
$dataSend = array(
"begin"=> "1549922400",
"count"=> 10,
"end"=> "1552428000",
"page"=> 1,
"periodType"=> 0,
"showLossBets"=> true,
"showWinBets"=> true,
"showWorkBets"=> true
);
$request = WGet::post_request('http://partner_site.com/GetUserBets/',json_encode($dataSend));
Sample response:
{
"d": [{
"events": [{
"dateEvent": 1597146000,
"name": "Atlet (Yellow) - Wolfs (Black) - [with OT]",
"oc_name": "1X",
"tournamentName": "Premier League 4х4",
"score": "-: -",
"status": 0,
"coef": 1.02
}, {
"dateEvent": 1597147200,
"name": "Chongqing Lifan - Qingdao Hainu",
"oc_name": "Draw",
"tournamentName": "China Championship",
"score": "-: -",
"status": 0,
"coef": 4.15
}],
"date": "1597147108",
"amountIn": "150",
"amountOut": "634.5",
"betCode": "gi7888283r",
"coef": "4.23",
"type": 2,
"countEvents": 2,
"match": "",
"id": "109",
"status": "0"
}, {
"events": [{
"dateEvent": 1597146000,
"name": "Atlet (Yellow) - Wolfs (Black) - [with OT]",
"oc_name": "1X",
"tournamentName": "Premier League 4х4",
"score": "-: -",
"status": 0,
"coef": 1.02
}, {
"dateEvent": 1597147200,
"name": "Chongqing Lifan - Qingdao Hainu",
"oc_name": "Draw",
"tournamentName": "China Championship",
"score": "-: -",
"status": 0,
"coef": 4.15
}],
"date": "1597147097",
"amountIn": "150",
"amountOut": "634.5",
"betCode": "t75890591t",
"coef": "4.23",
"type": 2,
"countEvents": 2,
"match": "",
"id": "108",
"status": "0"
}, {
"events": [{
"dateEvent": 1597147200,
"name": "Perth (20) - Armadale (20)",
"oc_name": "1X",
"tournamentName": "Australian Championship Western Australian Premier League U20",
"score": "-: -",
"status": 0,
"coef": 1.02
}, {
"dateEvent": 1597147200,
"name": "Chongqing Lifan - Qingdao Hainu",
"oc_name": "Draw",
"tournamentName": "China Championship",
"score": "-: -",
"status": 0,
"coef": 4.15
}],
"date": "1597147081",
"amountIn": "150",
"amountOut": "634.5",
"betCode": "155g6g92x3",
"coef": "4.23",
"type": 2,
"countEvents": 2,
"match": "",
"id": "107",
"status": "0"
}, {
"events": [{
"dateEvent": 1597147200,
"name": "Perth (20) - Armadale (20)",
"oc_name": "1X",
"tournamentName": "Australian Championship Western Australian Premier League U20",
"score": "-: -",
"status": 0,
"coef": 1.02
}, {
"dateEvent": 1597147200,
"name": "Chongqing Lifan - Qingdao Hainu",
"oc_name": "Draw",
"tournamentName": "China Championship",
"score": "-: -",
"status": 0,
"coef": 4.15
}],
"date": "1597147075",
"amountIn": "150",
"amountOut": "634.5",
"betCode": "45x65075v6",
"coef": "4.23",
"type": 2,
"countEvents": 2,
"match": "",
"id": "106",
"status": "0"
}, {
"events": [{
"dateEvent": 1597139100,
"name": "Shijiazhuang Ever Bright - Tianjin Teda",
"oc_name": "Total (2.5) M",
"tournamentName": "China Championship",
"score": "-: -",
"status": 0,
"coef": 1.45
}],
"date": "1597146309",
"amountIn": "150",
"amountOut": "217.5",
"betCode": "v921921i9i",
"coef": "1.45",
"type": 1,
"countEvents": 1,
"match": "",
"id": "102",
"status": "0"
}, {
"events": [{
"dateEvent": 1597139100,
"name": "Mindil Aces - Casuarina",
"oc_name": "P2",
"tournamentName": "Australian Championship Northern Territory Premier League",
"score": "-: -",
"status": 2,
"coef": 25
}],
"date": "1597146179",
"amountIn": "150",
"amountOut": "3750",
"betCode": "i7a4489439",
"coef": "25",
"type": 1,
"countEvents": 1,
"match": "",
"id": "100",
"status": "2"
}],
"count": "11",
"e": [],
"u": {
"id": "24070",
"name": "t1esrter",
"mail": "[email protected]"
},
"t": "",
"log": {
"cookies": {
"PHPSESSID": "aosthk5rseo0pjccpd4cni4lsb",
"COOKIS": "82f4a36113b2ed879a84eb9ca7256486"
},
"params": {
"data_set": "{\"begin\":\"1594395909\",\"count\":10,\"end\":\"1597151604\",\"page\":1,\"periodType\":0,\"showLossBets\":true,\"showWinBets\":true,\"showWorkBets\":true}",
"page": 1,
"count": 10,
"type": "all",
"forced_type": "",
"start": 1594395909,
"end": 1597151604
}
}
}
Parameter | Description |
---|---|
events -> dateEvent |
Match Date |
events -> name |
Match name |
events -> oc_name |
The outcome the bet was placed on |
events -> tournamentName |
Tournament name |
events -> score |
Match score |
events -> status |
Bet status (2 win, 4 lose, 0 - not calculated) |
events -> coef |
Rate Factor |
date |
Coupon Date |
amountIn |
Bet Amount |
amountOut |
Coupon Amount |
betCode |
Coupon number |
coef |
Total Coupon Rate |
type |
Coupon type (Single or Express) |
countEvents |
Number of bets in the coupon |
status |
Coupon status (2 wins, 4 losses, 0 - not calculated) |
All results of coupon calculation, our system sends to the specified remote_host
. In cases where the copon result did not come within three attempts, using this api, you can take the result at any time.
Getting statuses by coupons:
{HOST_API}/loadbars/
Parameter | Description |
---|---|
mails |
user's mail |
links |
link or coupon number |
Send request:
$dataSend = array(
"mails"=>array('[email protected]'),
"links"=>array('fd1rv7z10c')
);
$request = WGet::post_request('http://partner_site.com/loadbars/',json_encode($dataSend));
Get a response:
[{
"Heads": [{
"KeyHead": {
"Id": "644559",
"BarCode": "fd1rv7z10c"
},
"Status": 4,
"AmountOut": "1509",
"list": [{
"status": 0,
"oc_name": "X",
"rate": 7.22,
"game_name": "San Lorenzo de Almagro - Independiente",
"game_dop_name": "",
"game_score": "7:2 (4:0,3:2)"
}, {
"status": 4,
"oc_name": "Handiсap 1 (0)",
"rate": 2.09,
"game_name": "Norwich City - Wolverhampton Wanderers",
"game_dop_name": "",
"game_score": "8:5 (3:2,5:3)"
}]
}],
"remote_host": "partner_site.com"
}]