SportApi
API Documentation

System Integration for Bet and Coupon Calculation

This system is designed for sports betting operators, bookmakers, and platform developers who aim to automate the process of bet calculation and coupon management. It allows for quick integration of result calculations, providing accurate data on coupon statuses (win, loss, or refund), and simplifies the interaction between the operator’s server and the calculation system.

POST /v1/coupon json
{
  "coupon_id": "A7F3K9",
  "type": "express",
  "events": [
    { "id": 88213, "pick": "1", "odds": 2.10, "result": "win" },
    { "id": 88150, "pick": "over_2_5", "odds": 1.80, "result": "win" }
  ],
  "total_odds": 3.78, "status": "won"
}

How does the system work?

How Does the Odds and Outcomes Calculation System Work?

Integration with our bet and coupon calculation system consists of three key stages:

Step 1: Authorization

In the first stage, you need to authorize in the system. This is done by performing a POST request with user credentials (login and password). Successful authorization returns a session represented as a cookie, which must be saved. These cookies are required for all subsequent requests as they are used to identify the user's session in the system.

Step 2: Sending a Bet

At this stage, a bet code is sent to our system containing:

  • Match ID, corresponding to the event.
  • Bet code, describing the selected outcome (e.g., team win, handicap, or total).
  • Bet odds, valid at the time of submission.

When submitting data, the cookies obtained during authorization must be included. This ensures proper user identification and bet processing.

Step 3: Receiving Results

After the outcomes or coupons are calculated, our system sends POST requests to the specified remote_host. This request includes:

  • Coupon status (win, loss, or refund).
  • Statuses of all outcomes included in the coupon.

Results are sent as soon as the outcome is determined. For example:

  • If the bet was placed on an intermediate outcome (e.g., handicap 2.5, and the third goal is scored), the calculation may be performed during the match.
  • If the bet is on the final result (e.g., team win), the status information will be sent immediately after the match ends.

Now review each step individually. We have described the requests, parameters, and API responses in detail.

User authorization

Login, password, and the host for sending requests can be obtained from the manager.

Request URL:

{APIHOST}/WebServices/BCService.asmx/LogIn/

Data Submission Type: POST

Submitted Data:

ParameterDescription
loginUser login
passwordUser password

Important!

  • During authorization, the response includes cookies. These cookies must be saved and sent with subsequent requests.

Recommendations for easier integration:

  • Ensure the login field is passed as a string.
  • Verify the correct saving and sending of cookies, as this affects the execution of subsequent requests.
  • In case of an error, the request will return an empty object. Make sure to handle this scenario appropriately.

Cookies are valid for 3 months. However, they may be reset if the server is restarted. Therefore, you need to reauthorize if you encounter an error while saving a coupon.

Error response json
"errorCode":1,
"fullErrorCode":99,
"errorMessage":"Invalid access level"

Example of sending a request (use the data provided by the manager):

Example Response:

Successful:

{"d":{"UserId":"36557"}}

Unsuccessful:

{"d":{}}

Response Fields Description:

FieldDescription
UserIdUnique user identifier
dRoot object of the response

General Recommendations:

  • Before the first request, ensure the user has entered the correct credentials.
  • Set up error handling to display the reasons for failed authorization to the user (e.g., incorrect login or password).
  • Log both successful and unsuccessful attempts for analysis and monitoring.

Cookies must be saved and sent with subsequent requests.

POST {APIHOST}/WebServices/BCService.asmx/LogIn/ python
import requests
import json

url = "https://example-domain-calc.com/WebServices/BCService.asmx/LogIn/"

payload = json.dumps({
  "login": "[email protected]",
  "password": "demo-password"
})
headers = {
  'Content-Type': 'application/json'
}

print(response.text)

Bet or coupon submission method

To submit a bet, you must use the cookies obtained during the authorization stage. These data are required to identify your session and process requests.

Request URL:

{HOST_API}/bet/place/
Example body payload json
{
    "data":{
        "list_bets":[
            "line#586464528|17|954|2.5#4.27",  "live#586464528|87|4|0#1.12"
        ],
        "realAmount":"2",
        "currency":"USD",
        "lang":"en",
        "remote_host":"https://mysites.com",
        "rate_mode":"reject"
    }
}

remote_host & rate_mode parameters

Field Descriptions

ParameterDescription
list_betsBet code and odds. Format: "event_type#match_ID|bet_code#odds". Example: "live#579216393|1|1|0#2.1"
realAmountBet amount. Must be passed as a string, e.g., "150".
currencyCoupon currency.
langThe language in which the bet and coupon are saved. For example: "en", "ru", or "tr".
remote_hostThe URL to send the coupon calculation results to. Do not include a trailing slash.
rate_modeOption for handling coupon acceptance when odds change: "reject" (reject on changes) or "accept" (accept regardless of changes). Default: "accept".

Note: Ensure that parameters are passed in the correct format. For example, list_bets must be an array, even if there is only one bet.

We do not validate the bet amount. You can submit either the actual bet amount or any arbitrary value. This is to ensure the confidentiality of your financial data. Our task is to provide calculation results. You are responsible for crediting winnings to your players.

Required Parameters for Submitting a Bet:

  • list_bets — contains information about the bet and the corresponding match.
  • remote_host — the URL to which we will send the calculation results for the coupon or outcome.
  • rate_mode — determines how the system handles odds changes.

Other parameters should also be sent, but they are optional and can be used for your convenience.

Description of the remote_host Parameter

remote_host is the address of your server where we send requests with the results of bet calculations. This host must be configured to accept requests from our server. Below are examples of possible values and specific details about working with this parameter.

You can specify various options for remote_host:

  • Simple host: https://mysites.com
  • Host with port: https://mysites.com:78665
  • Host with additional paths: https://mysites.com/request/sportapi/sender
  • Host with parameters: https://mysites.com/request.php?action=webhook

Important: When sending a request, our system automatically appends the string /api/bet/result to the specified remote_host. Thus, the final address for receiving requests is formed as remote_host + "/api/bet/result". Ensure that your server is configured to receive data at this path.

Examples:
  • You specify remote_host = https://mysites.com. We send requests to: https://mysites.com/api/bet/result.
  • You specify remote_host = https://mysites.com/request.php?action=webhook. We send requests to: https://mysites.com/request.php?action=webhook/api/bet/result.

Technical Details:

  • Requests are sent using the POST method.
  • Your server must be ready to accept JSON data that we send.
  • Your server must return a 200 status code upon successful data receipt.

Ensure that your server correctly processes the specified path and requests. The next section provides an example of the data structure sent by our server.

Description of the rate_mode Parameter

The rate_mode parameter defines the system's behavior when odds change. It can take two values:

  • accept: In this mode, the coupon will be accepted with the current odds, even if they have changed. For example, a player adds a bet "Manchester Wins" with odds of 2.02. While they press the "Place Bet" button, the odds change to 1.37 or 2.78. In the accept mode, the system saves the coupon with the new odds without notifying your system.
  • reject: In this mode, the system rejects the coupon if the odds have changed. The response will include an error notifying that the odds have changed.

Choose the mode that best suits your business processes and provides convenience for your users.

Important Recommendations

  1. JSON Formatting: Ensure that the data is properly serialized into JSON format before sending.
  2. Cookies: Include the cookies obtained during authorization to successfully identify the user's session.
  3. Error Handling: Handle server responses, especially cases where errorCode = 1 is returned.
  4. Testing: Conduct tests at all stages of integration, including sending single and multiple bets.

Response fields & error description

Response Fields

ParameterDescription
betCodeUnique bet number in our system
errorCodeMain status of the request result
fullErrorCodeError details
errorMessageSystem error text messages
AmountOutPotential win amount
CountEventsNumber of bets in the coupon
CoefOutcome coefficients
IsLiveBet type: live or pre-match (true/false)
LinesIdMatch ID
EventDateMatch date

Error Description for Bet Submission

Various errors may occur when submitting a bet. The server response contains three key fields:

  • errorCode: Main request status.
  • fullErrorCode: Error details.
  • errorMessage: Text description of the error.

Successful operation

Successful operation json
{
  "errorCode": 0,
  "fullErrorCode": 0,
  "errorMessage": ""
}

Error codes

If the bet is successfully accepted, the server returns a success response (see above). The coupon has been accepted, and there are no errors.

If an error occurs, the server returns a general error response (see above). One of the possible errors occurred. Below are the error codes and messages.

Possible Error Codes and Descriptions

Error Code (fullErrorCode)Error Message (errorMessage)Description
1error_wrong_bet_dataIncorrect bet data. Check the list_bets parameter and other required fields.
1error_block_bet_dataThe bet is temporarily blocked and cannot be accepted.
1error_repeat_bet_dataDuplicate bets on the same outcome from one match are not allowed.
2label_change_rateThe odds have changed. The coupon was rejected due to a mismatch between the specified and current odds.
3error_exist_betThe specified bet outcome no longer exists. Check the data for accuracy.
99Invalid access levelThe user does not have the rights to perform this operation. Most likely, reauthorization is required, cookies are missing, or the account is blocked.
99Error exist remote host!The remote_host parameter is incorrect or missing. Check your server settings.

Recommendations for Error Handling

  • Input Data Validation: Ensure that all required parameters are provided correctly. Check the format of list_bets and the presence of all mandatory fields.
  • Working with Odds: If rate_mode = reject is used, handle errors related to odds changes (label_change_rate).
  • Server Configuration: Ensure that your server is correctly specified in the remote_host parameter.
  • Error Logging: Log all errors (errorCode, fullErrorCode, errorMessage) to simplify debugging and interaction with support.
  • Actions for Critical Errors: In case of level 99 errors, check access rights and API configurations on your side.
General error json
{
  "errorCode": 1,
  "fullErrorCode": [ERROR_CODE],
  "errorMessage": "[ERROR_DESCRIPTION]"
}

Recommendations for handling errors when odds have changed

Recommendations for handling errors when odds have changed json
{
    "errorCode":1,
    "fullErrorCode":2,
    "errorMessage":"Odds have changed",
    "rate_mode":"reject",
    "changed":[
        {
            "gid":"586464528", // match ID
            "rb":2.15, // odds in your coupon
            "rg":"2.27", // current real odds
            "rt":0 // status of change. 0 - decreased, 1 - increased
        }
    ]
}

Sending calculation results

When a bet is added to our system and calculated, we send the coupon results to your server. These can include:

  • Coupon results (full calculation).
  • Coupon statuses (win, loss, refund).

Requests are sent to the address you specified in the remote_host parameter. The string /api/bet/result is automatically appended to this address. Ensure that your server is configured to receive data at this path.

Example of the Final Address:

If you specified: remote_host = https://mysite.com, we will send data to: https://mysite.com/api/bet/result.

Example data for a single coupon json
{
    "remote_host": "https://mysite.com",
    "Heads": [{
        "KeyHead": {
            "Id": "344143",
            "BarCode": "x9c52i8411"
        },
        "Status": 2,
        "ExtStatus": 0,
        "AmountOut": 11130,
        "DateReceive": "1597075782"
    }]
}

Example data for multiple coupons

Field Descriptions

FieldDescription
remote_hostThe address of your server where data is sent.
IdUnique identifier of the bet in our system. Ignored in most cases.
BarCodeUnique coupon number.
StatusCurrent status of the coupon. Possible values: 2 — win, 4 — loss.
ExtStatusAdditional status in case of a refund: 0 — no changes, 1 — one or more outcomes were calculated with a changed coefficient.
AmountOutWin amount (if the coupon won).
DateReceiveThe time and date when the coupon was calculated.

How to Interpret Status and ExtStatus

  • Status = 2 and ExtStatus = 0: The coupon won.
  • Status = 4 and ExtStatus = 0: The coupon lost.
  • Status = 2 and ExtStatus = 1: Refund. The coupon was calculated with a coefficient of 1.

Important Points for Integration

  • Handling ExtStatus = 1: This may occur if a match was canceled or ended prematurely. In such cases, all bets are calculated with a coefficient of 1.
  • Technical Requirements: Requests are sent using the POST method. Your server must be ready to accept JSON data at the path remote_host + /api/bet/result.
Example data for multiple coupons json
{
    "remote_host": "https://mysite.com",
    "Heads": [{
        "KeyHead": {
            "Id": "313",
            "BarCode": "75vz48t935"
        },
        "Status": 2,
        "ExtStatus": 0,
        "AmountOut": 19.85,
        "DateReceive": "1592937968"
    }, {
        "KeyHead": {
            "Id": "312",
            "BarCode": "77i0r6e15t"
        },
        "Status": 2,
        "ExtStatus": 0,
        "AmountOut": 12.51,
        "DateReceive": "1592937280"
    }]
}