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
interface BettingAPI {
  registerCallbacks(callbacks: BettingCallbacks): void;
  subscribe(event: IBettingEvent, handler: (data: IBettingEventPayload) => void): () => void;
  updateBettingOptions(options: {token: string, isAuthorized: boolean, locale?: string, currency?: string}): void;
  updateThemeConfig(themeConfig: Partial<ThemeConfig>): 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 authorization data, locale, and currency.

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) - isAuthorized – Player's authorization status - locale – Selected language - currency – Selected currency

Important

Use the same locale and currency values that were used when generating the token. If either value changes, a new token must be generated.

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.