Skip to content

BettingAPI

The BettingAPI provides methods for interacting with the betting SPA once it has been initialized. You can use it to configure various aspects of the betting interface, such as change theme, listen events, setup callbacks, etc.

An instance of the BettingAPI is passed to the onLoad callback of the bettingLoader.load() method and is also made available globally via the window object

1
2
3
4
5
6
7
8
interface BettingAPI {
  registerCallbacks(callbacks: BettingCallbacks): void;
  subscribe(event: IBettingEvent, handler: (data: IBettingEventPayload) => void): () => void;
  updateBettingOptions(options: {token: string}): void;
  updateThemeConfig(themeConfig: Partial<ThemeConfig>): void;
  setUserBalance(balance: string): void;
  destroy(): void;
}

registerCallbacks

Description: Registers a set of callbacks that the betting SPA can use to interact with the integrator.

Parameters: callbacks (BettingCallbacks) — An object containing the callback functions.

subscribe

Description: Subscribes to a specific betting event.

Parameters: event (BettingEvents) — The name of the event to subscribe to. handler — A callback function that will be executed when the event is triggered.

Returns: A function that, when called, unsubscribes the handler from the event.

updateBettingOptions

Description:
Updates the token for the betting SPA.

Authorization data, currency, and locale are injected into the token (Token), so when any of these values change, the token must be re-generated and updated.

This method can be used in scenarios such as:

  • when the user login / logout

  • when the language is changed on the main website

  • when the currency is changed on the main website

Parameters:

  • token – Token of the current player (Token)

updateThemeConfig

Description: Updates the theme configuration of the betting SPA.

Parameters: themeConfig (ThemeConfig) — An object containing the new theme configuration.

destroy

Description: Destroys the betting SPA instance, cleaning up any resources or event listeners.

setUserBalance

Description:
Our Sportsbook application does not track the user balance on the backend. To improve the frontend experience, integrations have the optional ability to update the user balance via the setUserBalance function.

Updating the balance allows the frontend to:

  • Automatically adjust the maximum bet (capping it at the user’s available balance if it exceeds that amount).

  • Provide smarter stake suggestions based on the current balance.

  • Avoid unnecessary /bet/place calls to your platform when the user does not have sufficient funds.

  • Support any other UI features that depend on knowing the user’s current balance.

On the integration side, to use the balance features, you need to subscribe to balance updates and call this function to transfer the balance.

Parameters:

  • balance – The current user balance in the currency specified in the Betting Token, which can be an integer or a decimal value using a dot as the separator.

Examples:

  • "1.5"

  • "100"

  • "100.00"