Skip to content

Betting events

This page lists the events exchanged between the betting frame and your platform. Outbound events are delivered through bettingAPI.subscribe, inbound events are sent with bettingAPI.emit.

Initialization

betting-init

Description: This event is dispatched by application once it is fully initialized on the client side.

This event acts as a signal that the global window.bettingAPI object is now available and ready to be used.

Important

Unlike other application events, betting-init is a global DOM event emitted via document.dispatchEvent(...), not an event you subscribe to through bettingAPI.

Example:

1
2
3
4
5
6
document.addEventListener("betting-init", () => {
  // bettingAPI is now available
  window.bettingAPI.subscribe("<some-event>", (data) => {
    console.log("Received event:", data);
  });
});

Outbound events

Events the frame sends to your platform. Subscribe with bettingAPI.subscribe(event, handler); the returned function unsubscribes.

redirect

Description: Trigger at the moment of performing the actions specified in the Destination; it must be possible to set the transition via external routes.

1
2
3
4
5
6
interface RedirectPayload {
  destination: Destination;
  link: string;
}

type Destination = "login" | "logout" | "betting-page";

Example: This event is typically used to trigger the opening of a login modal when an unauthorized user attempts to place a bet

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
bettingAPI.subscribe("redirect", ({ destination, link }) => {
  switch (destination) {
    // at the moment only two values are available for the 'destination'
    case "login": {
      window.location.href = "#!/auth/signin?popup";
    }

    case "logout": {
      window.location.href = "#!/auth/signout";
    }

    case "betting-page": {
      **Description:**
    When integrating Widgets, it will help to return to betting

      window.location.href = `${'your betting path'}/${link}`;

    }

    // after handling login and logout events you should execute window.location.reload()
    default: {
      break;
    }
  }
});

handle-not-enough-balance

Description: Trigger when a player does not have enough funds to make a bet. The integrator can handle the case where the user needs to deposit more funds.

1
2
3
interface HandleNotEnoughBalancePayload {
  deposit: string;
}

Example: This event is typically used to trigger the opening of a deposit modal

1
2
3
bettingAPI.subscribe("handle-not-enough-balance", ({ deposit }) => {
  console.error(`Not enough balance, deposit: ${deposit}`);
});

handle-custom-errors

Description: Triggers when a custom_error is received from the bet/place callback. The integrator can handle these custom errors and implement appropriate user-facing actions based on the error codes and context.

1
2
3
4
5
6
7
8
9
interface HandleCustomErrorsEventPayload {
  errors: Array<{
    code: string;
    context: Array<{
      name: string;
      value: string;
    }>;
  }>;
}

Example:

1
2
3
bettingAPI.subscribe("handle-custom-errors", ({ errors }) => {
  console.error(`Place bet custom errors:`, errors);
});

toggle-widget-betslip

Description: Trigger when a player opens or close the betslip widget

1
2
3
4
5
interface ToggleWidgetBetslipPayload {
  isOpen: boolean;
  widgetType: "static" | "island";
  breakpoint: "mobile" | "tablet" | "desktop";
}

Example: The integrator can use this event to handle UI changes, such as enabling/disabling scrolling on mobile devices.

custom-widget-init

Description: Triggered when the custom widget container is mounted and ready to receive content. This event indicates that the container is ready for rendering custom React components using createPortal.

1
2
3
4
interface ICustomWidgetMountEvent {
  containerId: string;
  element: HTMLElement;
}

Properties:

  • containerId: Unique identifier for the container
  • element: The DOM element where custom content should be rendered

Example:

Use this event to render custom content into specific widget containers once they become available.

1
2
3
4
5
6
bettingAPI.subscribe("custom-widget-init", ({ containerId, element }) => {
  // Render custom component into the provided element
  const content = <div>{/* Your custom content */}</div>;

  return createPortal(content, element);
});

odd-click

Description: Triggered when the user clicks an odd in the SPA: one selection for a plain click, several for a bundle (for example a pre-generated bet). The event only reports the click. What it means for your betslip (add, remove, replace, reject) is your decision; the SPA does not keep its own copy and learns the outcome from betslip-selections-change. Use the identifiers to fetch the current odds from your own API.

The odds for a Bet Builder and its individual legs are returned in betBuilderSelections instead of selections. A Bet Builder is one bet per sportEventId, so group the legs by that id: a click in a Bet Builder market reports one leg, a pre-generated Bet Builder card reports all of its legs. A bundle that combines regular odds with a Bet Builder fills both arrays in the same click; apply them to your betslip as one change.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
interface OddClickPayload {
  selections: Selection[];
  betBuilderSelections: Selection[];
}

interface Selection {
  sportEventId: string;
  marketId: string;
  oddId: string;
}

Example: A host with its own betslip applies its rules to the click and reports the result back with emit("betslip-selections-change"). See External betslip.

1
2
3
bettingAPI.subscribe("odd-click", ({ selections, betBuilderSelections }) => {
  myBetslip.applyClick({ selections, betBuilderSelections });
});

Inbound events

Events your platform sends to the frame with bettingAPI.emit(event, payload). Unknown event names are logged and ignored. See External betslip for the full integration flow.

betslip-selections-change

Description: Reports the full set of selections currently in the host's own betslip, allowing the SPA to highlight the corresponding odds as selected. This is a snapshot, not a delta: send it on start, once bettingAPI is available, and after every change (add, remove, clear, bet placed). An empty array clears every highlight. Odds rendered later (navigation, expanded markets) pick the snapshot up automatically. Bet Builder legs go into betBuilderSelections; the SPA groups them into one Bet Builder per sportEventId and highlights them in the Bet Builder markets. Omit the field when your betslip has no Bet Builders.

1
2
3
4
interface BetslipSelectionsChangePayload {
  selections: Selection[];
  betBuilderSelections?: Selection[];
}

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
// Your betslip item → the frame's selection triple.
const toSelection = ({ eventId, marketId, outcomeId }) => ({
  sportEventId: eventId,
  marketId,
  oddId: outcomeId,
});

const publish = () =>
  bettingAPI.emit("betslip-selections-change", {
    selections: myBetslip.items().map(toSelection),
    betBuilderSelections: myBetslip.betBuilderLegs().map(toSelection),
  });

publish();
myBetslip.onChange(publish);