Skip to main content
Logo
Explore APIsContact Us
  • Home
  1. Resources
  2. Virtual Stadium
  3. Copy Bet

Copy Bet

Copy Bet Button Demo

The Copy Bet functionality allows you to implement betslip copying for your users. While the backend handles the core count logic, you have complete control over what happens when a user clicks the button. This is managed through the onAction callback.


#Setup

#1. Enable the Copy Bet Button

To enable the Copy Bet Button within your Virtual Stadium widget, set the enableCopyBetButton property to true during widget initialization:

enableCopyBetButton boolean optional

Enables the Copy Bet Button functionality.

Enable Copy Bet Button:

javascript
SIR('addWidget', '#sr-vs-widget', 'virtualStadium', {
    enableCopyBetButton: true,
    // ... other configuration
});

#2. Handle Copy Bet Action

When a user clicks on a copy bet button, an action is triggered. This action invokes the onAction callback and returns the following data structure:

onAction (type: string, data: object) => void optional

Callback function triggered when specific events occur in the widget.

Parameters:

type string required

Action type: "CopyBet".

data object required

Action data containing bet information.

data.betslip BetSlip required

The complete betslip data to be copied.

Handling Copy Bet Actions:

javascript
function onAction(type, data) {
    switch (type) {
        case 'CopyBet': {
            // Transform the data as needed
            console.log('Copied BetSlip:', data);
            // Additional logic here
            break;
        }
        default: {
            console.log('Unhandled action type:', type);
        }
    }
}

SIR('addWidget', '#sr-vs-widget', 'virtualStadium', {
    copyBetButton: true,
    onAction: onAction,
    // ... other configuration
});

#Bet Data Structure

#BetSlip Object

Representation of a betting ticket that contains one or more individual bets. Users can share these tickets in chat, allowing others to copy and place the same bets.

A ticket containing one individual bet on a single market.

Single Bet Example

#BetSlip Properties

id string required

Unique identifier for the ticket.

betSlipId string optional

Client-specific identifier for matching to existing bet slips.

betType string optional

Type of bet slip. Possible values: "single" for a single bet on one market, "multi" for a multi-bet across different events, "sameGameMulti" for multiple bets on the same event (also known as a bet builder).

currency string optional

Currency code (e.g., "USD", "EUR").

combinedOdds Odds optional

Combined odds for the entire bet slip.

stake object optional

The amount of money wagered on the bet slip.

payout object optional

Potential payout amount for the bet slip.

bets Bet[] required

Array of individual bets within the bet slip.

#Bet Properties

id string required

Unique identifier for the individual bet.

betType string optional

Type of the individual bet.

event Event optional

Event information including teams, date, and venue. See Event object for details.

markets Market[] optional

Array of markets for this bet. See Market object for details.

odds Odds optional

Odds for this individual bet. See Odds object for details.

Single Bet Example:

json
{
  "id": "sr:bet-share-event:single",
  "betSlipId": "sr:bet-share-event:single",
  "betType": "single",
  "currency": "USD",
  "combinedOdds": {
    "decimalValue": 2.55,
    "displayValue": "2.55"
  },
  "stake": {
    "value": "50.00"
  },
  "payout": {
    "value": "127.50"
  },
  "bets": [
    {
      "id": "bet-123",
      "betType": "single",
      "event": {
        "id": "event-456",
        "name": "Manchester United vs Liverpool",
        "date": "2024-01-15T15:00:00Z",
        "isLive": false,
        "teams": [
          { "name": "Manchester United" },
          { "name": "Liverpool" }
        ]
      },
      "markets": [
        {
          "id": "market-789",
          "name": "Total Goals",
          "outcomes": [
            {
              "id": "outcome-101",
              "name": "Under 2.5",
              "odds": "1.85"
            }
          ]
        }
      ],
      "odds": {
        "decimalValue": 1.85,
        "displayValue": "1.85"
      }
    }
  ]
}

#Odds Object

The Odds represents odds information for markets and bets.

#Odds Properties

decimalValue number optional

Numeric EU representation of odds (decimal number) displayed on market outcome.

displayValue string optional

String representation of odds displayed on UI as is, meaning NO FORMATTING.

Odds Example:

json
{
  "decimalValue": 2.55,
  "displayValue": "2.55"
}

#Event Object

Represents a single sporting event (e.g., match, race, or stage).

#Event Properties

id string required

Unique identifier for the event. This must match the event IDs used in your bet data.

srEventId string | number optional

Sportradar event identifier.

externalId string | number optional

Your external system identifier for the event.

date string optional

Scheduled date and time of the event as will be displayed.

sport Sport optional

Sport information. See Sport object for details.

category Category optional

Geographical or organizational grouping for sports events. (e.g., country or region). See Category object for details.

tournament Tournament optional

Tournament or competition information. See Tournament object for details.

name string optional

Display name of the event. If not provided, it will be generated from team names.

teams [Team, Team] optional

The home team followed by the away team. See Team object for details.

isLive boolean optional

Whether the event is currently live.

liveCurrentTime string | number optional

Current time in the live event, displayed as text (e.g., '1st Quarter').

result1 Result optional

Primary result information. For soccer, this represents the full-time score (e.g., home and away goals). For basketball, this is the final score. For tennis, this is the final set scores.

result2 Result optional

Secondary result information. For soccer, this represents the half-time score. For basketball, this is the score at the end of the first half. For tennis, this is the current set score.

result3 Result optional

Tertiary result information. For soccer, this may represent extra-time score if applicable. For basketball, this is the score at the end of the third quarter. For tennis, this is the previous set score.

Event Example:

json
{
  "id": "sr:event:98765",
  "srEventId": "sr:match:123456",
  "externalId": "ext-789",
  "date": "2024-01-15T15:00:00Z",
  "sport": {
    "id": "sr:sport:1",
    "name": "Football",
    "icon": "https://example.com/football-icon.png"
  },
  "category": {
    "id": "sr:category:1",
    "name": "England",
    "cc": {
      "a2": "EN"
    }
  },
  "tournament": {
    "id": "sr:tournament:1",
    "name": "Premier League"
  },
  "name": "Manchester United vs Liverpool",
  "teams": [
    {
      "id": "sr:team:42",
      "name": "Manchester United"
    },
    {
      "id": "sr:team:43",
      "name": "Liverpool"
    }
  ],
  "isLive": false
}

#Market Object

The Market object represents a betting market within individual bets.

#Market Properties

id string | number required

Unique identifier for the market.

externalId string | number optional

Your external system identifier for the market.

status MarketStatus optional

Current status of the market. See MarketStatus object for details.

name string required

Display name of the market.

specifier object optional

The specifier object defines the specific parameters or conditions for the market in the Unified Odds Feed (UOF), such as the threshold value in over/under markets (e.g., "2.5" for Over/Under 2.5 Goals). For more information see UOF documentation.

outcomes Outcome[] required

Array of possible outcomes for this market. See Outcome object for details.

srMarket SRMarket optional

Sportradar representation of the Market object. See Market object for details.

odds Odds optional

Sportradar representation of the Odds object. See Odds object for details.

Market Example:

json
{
    "id": "market-789",
    "externalId": "ext-market-789",
    "status": "active",
    "name": "Total Goals",
    "specifier": {
        "total": "2.5"
    },
    "outcomes": [
        {
            "id": "outcome-101",
            "name": "Under 2.5",
            "odds": "1.85"
        }
    ],
    "srMarket": {
        "id": "sr:market:789",
        "specifiers": "total=2.5"
    },
    "odds": {
        "decimalValue": 1.85,
        "displayValue": "1.85"
    }
}

#SRMarket Object

Sportradar representation of the Market object. See Market object for details.

#SRMarket Properties

id string required

Unique Sportradar identifier for the market.

specifiers string optional

Additional specifiers for the market (e.g., specific conditions or parameters).

SRMarket Example:

json
{
  "id": "sr:market:789",
  "specifiers": "total=2.5"
}

#Sport Object

The Sport object represents a sporting discipline or category.

#Sport Properties

id string optional

The unique SR identifier.

name string optional

The name of the sport.

icon string optional

URL where icon is located.

Sport Example:

json
{
  "id": "sr:sport:1",
  "name": "Football",
  "icon": "https://example.com/football-icon.png"
}

#Category Object

The Category object represents a geographical or organizational grouping for sports events.

#Category Properties

id string optional

The unique identifier assigned to the category.

name string optional

The name of the category.

cc object optional

Country code object with a2 property containing ISO 3166-1-alpha-2 country codes. Supports both uppercase and lowercase variants of all standard ISO codes plus non-standard codes for UK countries. Supported values include:

Standard ISO 3166-1-alpha-2 codes: AF, AX, AL, DZ, AS, AD, AO, AI, AQ, AG, AR, AM, AW, AU, AT, AZ, BS, BH, BD, BB, BY, BE, BZ, BJ, BM, BT, BO, BQ, BA, BW, BV, BR, IO, BN, BG, BF, BI, KH, CM, CA, CV, KY, CF, TD, CL, CN, CX, CC, CO, KM, CG, CD, CK, CR, CI, HR, CU, CW, CY, CZ, DK, DJ, DM, DO, EC, EG, SV, GQ, ER, EE, ET, FK, FO, FJ, FI, FR, GF, PF, TF, GA, GM, GE, DE, GH, GI, GR, GL, GD, GP, GU, GT, GG, GN, GW, GY, HT, HM, VA, HN, HK, HU, IS, IN, ID, IR, IQ, IE, IM, IL, IT, JM, JP, JE, JO, KZ, KE, KI, KR, KP, KW, KG, LA, LV, LB, LS, LR, LY, LI, LT, LU, MO, MK, MG, MW, MY, MV, ML, MT, MH, MQ, MR, MU, YT, MX, FM, MD, MC, MN, ME, MS, MA, MZ, MM, NA, NR, NP, NL, NC, NZ, NI, NE, NG, NU, NF, MP, NO, OM, PK, PW, PS, PA, PG, PY, PE, PH, PN, PL, PT, PR, QA, RE, RO, RU, RW, BL, SH, KN, LC, MF, PM, VC, WS, SM, ST, SA, SN, RS, SC, SL, SG, SX, SK, SI, SB, SO, ZA, GS, SS, ES, LK, SD, SR, SJ, SZ, SE, CH, SY, TW, TJ, TZ, TH, TL, TG, TK, TO, TT, TN, TR, TM, TC, TV, UG, UA, AE, GB, US, UM, UY, UZ, VU, VE, VN, VG, VI, WF, EH, YE, ZM, ZW

Non-standard codes: GB-ENG, GB-NIR, GB-SCT, GB-WLS

Category Example:

json
{
  "id": "sr:category:1",
  "name": "England",
  "cc": {
    "a2": "EN"
  }
}

#Tournament Object

The Tournament object represents a competition or league.

#Tournament Properties

id string optional

The unique identifier assigned to the tournament.

externalId string | number optional

Your unique identifier for the tournament.

name string optional

The name of the tournament.

Tournament Example:

json
{
  "id": "sr:tournament:1",
  "name": "Premier League"
}

#Team Object

The Team object represents a sports team or competitor.

#Team Properties

id string optional

The unique SR identifier assigned to the team.

name string required

The name of the team.

Team Example:

json
{
  "id": "sr:team:42",
  "name": "Manchester United"
}

#Result Object

The Result object represents the score or outcome of an event.

#Result Properties

result Array<number | string> required

The result of the event.

label string optional

Optional label for the result.

Result Example:

json
{
  "result": [2, 1],
  "label": "Final Score"
}

#Outcome Object

The Outcome object represents a possible result or selection within a market.

#Outcome Properties

id string | number required

Unique identifier for the outcome.

externalId string | number optional

Your external system identifier for the outcome.

name string optional

Display name of the outcome.

odds number | string optional

Odds for this outcome.

oddsDecimal number optional

Decimal representation of odds for displaying odds change indicator.

competitor string optional

A competitor associated with the outcome.

status OutcomeStatus optional

Current status of the outcome. See OutcomeStatus object for details.

isSelected boolean optional

Whether the outcome is currently selected.

srOutcomeId string optional

Sportradar outcome identifier.

isRecommended boolean optional

Whether the outcome is recommended.

Outcome Example:

json
{
  "id": "outcome-101",
  "name": "Under 2.5",
  "odds": "1.85",
  "oddsDecimal": 1.85,
  "status": {
    "isActive": true
  },
  "isSelected": false,
  "isRecommended": true
}

#OutcomeStatus Object

The OutcomeStatus object represents the status of an outcome.

#OutcomeStatus Properties

isActive boolean required

Whether the outcome is currently active and available for betting.

OutcomeStatus Example:

json
{
  "isActive": true
}
Last updated 13 days ago
Is this site helpful?
Virtual Stadium, Moderation, Engagement Tools
Bet ShareFlash Bet
On this page
  • Setup
  • 1. Enable the Copy Bet Button
  • 2. Handle Copy Bet Action
  • Bet Data Structure
  • BetSlip Object
  • Odds Object
  • Event Object
  • Market Object
  • SRMarket Object
  • Sport Object
  • Category Object
  • Tournament Object
  • Team Object
  • Result Object
  • Outcome Object
  • OutcomeStatus Object