By completing this tutorial, you will:
tickets adapter endpointtickets endpoint that retrieves and transforms user bet dataBetShareResponse type specificationBefore implementing the tickets endpoint, ensure you have:
The tickets endpoint is one of several adapter endpoints. Implement additional endpoints (event, eventMarkets, availableMarketsForEvent, etc.) as needed for your widget features.
The tickets endpoint retrieves a user's bet history and returns it in the BetShareResponse format. This endpoint enables features like bet sharing and bet copying in Virtual Stadium widgets.
The endpoint receives request arguments including the customer ID, optional event filters, and pagination data. Your implementation should:
BetSlip formatFirst, register your adapter with the SIR global function before adding any widgets. Ensure only one adapter is registered per page load.
const adapter = {
endpoints: {
// Your endpoints will go here
}
};
SIR('registerAdapter', adapter);Add the tickets endpoint handler to your adapter. This function receives request arguments and a callback to return results.
const adapter = {
endpoints: {
// NOTE: The `tickets` endpoint is one of several adapter endpoints.
// Implement additional endpoints (event, eventMarkets, availableMarketsForEvent, etc.)
// as documented in the Adapter Types documentation based on your widget requirements.
tickets: (args, callback) => {
// Implementation continues below
}
}
};Request Parameters (args):
endCustomerId (string) — The user's unique identifierevents (SelectionEvent[], optional) — Events to filter tickets bypage (number, optional) — Page number for paginationuseCashOut (boolean, optional) — Include cash out informationRetrieve user bets from your backend system and apply filtering based on request arguments.
tickets: (args, callback) => {
// Fetch user's bets from your backend API or tickets system
fetchUserBets(args.endCustomerId, (error, allBets) => {
if (error) {
return callback(error);
}
Transform your bet data into the BetSlip format (part of BetShareResponse) and invoke the callback with the formatted response.
tickets: (args, callback) => {
fetchUserBets(args.endCustomerId, (
The response must conform to the BetShareResponse type: { bets: BetSlip[] }
The response object must include the bets property and not include a tickets property. The BetShareResponse type explicitly excludes tickets (defined as tickets?: never).
For the frontend implementation that allows users to interact with and copy bets in the UI, see the Copy Bet Button documentation.
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier for the bet (required) |
betSlipId | string | Optional secondary identifier for client-side matching |
betType | string | Bet type (e.g., "single", "multibet") |
currency | string | Currency code (e.g., "USD") |
combinedOdds | { decimalValue: number; displayValue: string } | Combined odds for the bet |
stake | { value: string } | Stake amount as a string |
payout | { value: string } | Potential payout as a string |
cashOut | { value: string } | Cash out value as a string |
bets | Bet[] | Array of bets within the slip (market, outcome, event details) |