Skip to content

Sportsbook API documentation

INFO

NOTE: This functionality is available exclusively in Shadow mode and is not supported in iFrame integration.

This document describes the available methods for interacting with the Sportsbook application integrated into a webpage.


Obtaining the Sportsbook instance

To interact with the Sportsbook instance, ensure the initialization method resolves correctly. This method ensures scripts and fonts are loaded sequentially. It creates or identifies the root container element, applies the initial configuration, and waits for the application to fully load before resolving. You can store the instance in a variable for future use.

Returns: A promise that resolves to the initialized Sportsbook instance.

javascript
const SportsbookApp = Sportsbook.init({
  host: 'https://APP_URL',
  cid: 'PARTNER_ID',
  isHideLanguagePicker: true, // Optional: hide language picker dropdown
  ...otherParams,
});

Then, use the SportsbookApp variable to interact with the Sportsbook instance via its available methods.

Initialization Parameters:

  • host (string, required): Sportsbook application host URL.
  • cid (string, required): Your partner ID, provided by the account manager.
  • isHideLanguagePicker (boolean, optional): When set to true, hides the language picker dropdown in the Sportsbook interface. Default is false.

Sportsbook.update(options)

Reinitializes the Sportsbook application with new parameters. This method allows you to update the configuration of the Sportsbook instance without destroying and recreating it.

javascript
SportsbookApp.then((sportsbookInstance) => {
  // Example of using the Sportsbook reinitialization with new parameters
  sportsbookInstance.update({
    lang: 'ja',
  });
});

Sportsbook.destroy()

Destroys the Sportsbook application. Calling this method performs the following actions:

  • Sends a destroy message to close active socket connections.
  • Removes the application's root DOM element.
  • Disconnects all active MutationObservers and ResizeObservers.
  • Removes injected scripts and fonts from the document.
  • Clears dynamically injected styles.

Important: You do not need to call Sportsbook.destroy() when leaving the application. The SDK automatically detects when the container no longer exists and performs the cleanup.

No parameters are required.

Usage example:

javascript
SportsbookApp.then((sportsbookInstance) => {
  sportsbookInstance.destroy();
});

Sportsbook.login(token)

Logs in a user and updates the application state. Reconnects the socket connection to receive personalized updates.

Parameters:

  • token (string, required): User session token

Usage example:

javascript
SportsbookApp.then((sportsbookInstance) => {
  sportsbookInstance.login(token);
});

Sportsbook.logout()

Logs out the user. After logging out, the application continues to operate in guest mode.

No parameters are required.

Usage example:

javascript
SportsbookApp.then((sportsbookInstance) => {
  sportsbookInstance.logout();
});

Sportsbook.setRoute(route)

Updates the application's internal navigation route. By default, calling this method will also update the browser's URL include the new sportsBookPath query parameter unless the application was initialized with disallowUrlChange: true.

Parameters:

  • route (string, required): Internal path within the application to navigate to.

Usage example:

javascript
SportsbookApp.then((sportsbookInstance) => {
  sportsbookInstance.setRoute('/live');
});

Sportsbook.setIsOpenSearch(isOpen)

Controls the search functionality state in the Sportsbook application. This method allows you to enable or disable the search popup.

Parameters:

  • isOpen (boolean, required): Set to true to enable search functionality, false to disable it.

Usage example:

javascript
SportsbookApp.then((sportsbookInstance) => {
  sportsbookInstance.setIsOpenSearch(true);
});

Sportsbook.setIsOpenMyBets(isOpen)

Controls the My Bets panel visibility in the Sportsbook application. This method allows you to programmatically open or close the My Bets panel.

Parameters:

  • isOpen (boolean, required): Set to true to open the My Bets panel, false to close it.

Usage example:

javascript
SportsbookApp.then((sportsbookInstance) => {
  sportsbookInstance.setIsOpenMyBets(true); // Open My Bets panel
});

Sportsbook.setIsOpenBetslip(isOpen)

Controls the Betslip panel visibility in the Sportsbook application. This method allows you to programmatically open or close the Betslip panel.

Parameters:

  • isOpen (boolean, required): Set to true to open the Betslip panel, false to close it.

Usage example:

javascript
SportsbookApp.then((sportsbookInstance) => {
  sportsbookInstance.setIsOpenBetslip(true); // Open Betslip panel
});

Additional SDK methods for Shadow mode integration

To access advanced features, such as subscribing to categorizer data and tracking the number of bets in the user's betslip, you need to include the following SDK script on your page:

html
<script
  type="text/javascript"
  src="https://{APP_URL}/assets/sdk/modules/init.js"
></script>

These methods are available globally via the window.Sportsbook object.

1. Subscribe to betslip count

This method tracks the number of bets the user has added to their betslip in the Sportsbook app. The onChange callback is triggered every time the bet previously added by the user becomes unavailable.

This is useful when a user adds bets to their betslip and then navigates away from the page containing the Sportsbook.

javascript
await window.Sportsbook.initBetslipCount({
  host: 'https://APP_URL',
  cid: 'PARTNER_ID',
  token: '<string>',
  onChange: (count) => {
    console.log('Betslip count:', count);
  },
});
  • Parameters:
    • host (string, required): Sportsbook application host URL.
    • cid (string, required): Your partner ID, provided by the account manager.
    • token (string, optional): The authentication token for the user's session.
    • onChange (function, required): Callback function receiving the current betslip count.

2. Subscribe to categorizer data

This method subscribes to categorizer data updates. The onChange callback is triggered whenever the categorizer data changes.

Important: By default, calling this method will automatically hide the categorizer in the Sportsbook application to prevent duplication. If you want to keep the categorizer visible in the Sportsbook, set isShowCategorizerInSportsbook to true.

javascript
await window.Sportsbook.subscribeOnCategorizerData({
  host: 'https://APP_URL',
  cid: 'PARTNER_ID',
  token: '<string>',
  sportsbookPath: '/betting', // Path within the Sportsbook
  isShowCategorizerInSportsbook: false, // Default: hides categorizer in Sportsbook
  onChange: (categorizerData) => {
    console.log('Categorizer data:', categorizerData);
  },
});
  • Parameters:
    • host (string, required): Sportsbook application host URL.
    • cid (string, required): Your partner ID, provided by the account manager.
    • token (string, optional): User session token. If omitted, the method operates in guest mode. In guest mode, the order and list of disciplines returned by the method may differ from those displayed in the Sportsbook when not in guest mode.
    • lang (string, optional): Language code in ISO 639-1 format (e.g., 'en', 'uk'). If not specified, the data will be returned in the language selected by the user in Sportsbook. If the user has not selected a language, the default language (en) will be used.
    • sportsbookPath (string, optional): Path within the Sportsbook (e.g., /betting). This parameter is optional, but to ensure correct route generation in the categorizer data, you should specify the path of the page where the Sportsbook is located.
    • isShowCategorizerInSportsbook (boolean, optional): Set to true to keep the categorizer visible in the Sportsbook. Default is false, which hides the categorizer to prevent duplication.
    • onChange (function, required): Callback function receiving the latest categorizer data. Returned payload includes:
      • topTournaments (array): Top tournaments list.
      • swipeBet (object): Swipe bet settings.
      • hasLeaderboards (boolean): Indicates whether leaderboards are available for the current authorized user context. Default is false (including guest mode when no token is provided).

3. Get tournaments by discipline

Retrieves a list of tournaments for a specific discipline. It is seful when a user selects a discipline from the Categorizer dropdown menu.

javascript
const tournamentsByDid = await window.Sportsbook.getTournamentsByDiscipline({
  host: 'https://APP_URL',
  cid: 'PARTNER_ID',
  token: '<string>',
  sportsbookPath: '/betting', // Path within the Sportsbook
  disciplineId: 'dota2', // Discipline ID (e.g., 'dota2')
});
  • Parameters:
    • host (string, required): Sportsbook application host URL.
    • cid (string, required): Partner ID.
    • token (string, optional): User session token. If omitted, the method operates in guest mode. In guest mode, the order and list of disciplines returned by the method may differ from those displayed in the Sportsbook when not in guest mode.
    • lang (string, optional): A language code in ISO 639-1 format (e.g., 'en', 'uk'). If not specified, the data will be returned in the language selected by the user in Sportsbook interface. If no language is selected by the user, the default language 'en' (English) will be applied.
    • sportsbookPath (string, optional): The path within the Sportsbook (e.g., /betting). Although this parameter is optional, you should specify the path of the page where the Sportsbook is located to ensure correct route generation in the data that returns this method.
    • disciplineId (string, required): Discipline ID (e.g., dota2).