Skip to main content
Logo
Explore APIsContact Us
  • Home
  • Match Preview
  • Tournament Preview
  • Virtual Stadium
  1. Resources
  2. Widgets
  3. Data Adapter

Data Adapter

This type of integration offers more flexibility but does require more work on the client side. How and when you fetch data is up to you, we only expect that the data returned is in correct format.

Data Adapter Overview
  1. Widget will request data by executing functions provided to widget by DataAdapterProviderConfig parameter. Detailed flow of data can be seen in chart below.
  2. Widget will call getOffering function every 30s to update offering.
  3. Transform offering data to OfferingResponse format, then execute callback from getOffering function getOfferingCallback in order to pass data back to widget.
  4. Widget will call calculate function whenever selection within widget is updated.
  5. Calculate odds and remaining markets available for selection
  6. Transform calculated data to CalculateResponse format, then execute callback from getOffering function calculateCallback in order to pass data back to widget.
  7. When user clicks on "Add to bet slip" button, addToBetSlip function is executed.
  8. We recommend that you check if provided selection is still valid.
  9. If validation passed, add outcomes to your bet slip and execute addToBetSlip setting succeeded property to true.
  10. If you wish to reject adding selection, set succeeded property to false and add localized reason to be displayed in the widget.

#Data Flow Chart

Data Adapter Flow Chart

#Custom Views Integration Tutorial

For a comprehensive step-by-step guide on creating custom views for the Custom Bet widget using Data Adapter functions, check out the Creating Custom Views tutorial. This tutorial will walk you through the process, making it easier to design and implement custom views.

#Integration Example

Data Adapter Integration Example - for dataProviderConfig example check DataAdapterProviderConfig

html
<script>
    (function (a, b, c, d, e, f, g, h, i) {
      a[e] || (i = a[e] = function () {
        (a[e].q = a[e].q || []).push(arguments)
      }, i.l = 1 * new Date, i.o = f,
        g = b.createElement(c), h = b.getElementsByTagName(c)[0], g.async = 1, g.src = d, g
          .setAttribute("n", e), h.parentNode.insertBefore(g, h)
      )
    })(window, document, "script",
      "https://master-cb.review.widgets.bets-stg.euc1.srcloud.io/betradarsolid/widgetloader", "SIR", {
      language: "en",
      oddsType: "eu" // eu, uk, us is accepted
    });

    SIR("addWidget", ".sr-widget", "customBet", {
      matchId: 32015685,
      dataProvider: 'custom',
      dataProviderConfig: {
        getOffering,
        calculate,
        addToBetSlip
      }
    });
</script>
<div id="sr-widget"></div>

#Type Definitions

#CalculateResponse

Type: Object

PropertyTypeRequiredDescription
cbMarketsCalculationMarket[]YesArray of available markets based on already selected outcomes
oddsstringNoCalculated odds
errorstringNoError to be displayed instead of odds.

#Example

javascript
{
    cbMarkets: [
    {
        // id: 267674245,
        id: '1',
        status: {
            isActive: true
        },
        srMarket: {
            id: '1'
        },
        outcomes: [
        {
            // id: 619793109,
            srOutcomeId: '1',
            status: {
                isActive: true
            }
        },
        {
            // id: 619793110,
            srOutcomeId: '2',
            status: {
                isActive: true
            }
        },
        {
            // id: 619793111,
            srOutcomeId: '3',
            status: {
                isActive: true
            }
        }
        ]
    }
    ],
    odds: '1.23'
}

#CalculationMarket

Type: Object

The calculate function is called whenever a selection within the widget is updated. The cbMarkets array in CalculateResponse must be populated with CalculationMarket entries to display available markets and outcomes in Custom Bet views. For markets and outcomes to appear, every entry must define at minimum a status and an outcomes array.

PropertyTypeRequiredDescription
idstring | numberNo
srMarketSRMarketNoIf you are using srMarket and srOutcome in OfferingResponse then provide this property
statusStatusYes
outcomesCalculationOutcome[] | SRCalculationOutcome[]YesIf you are using srMarket and srOutcome in OfferingResponse then provide SRCalculationOutcome type.

#Example

javascript
{
    id: "99",
    status: {
        isActive: true
    },
    outcomes: [
        { id: "1", status: { isActive: true } },
        { id: "2", status: { isActive: true } }
    ]
}

#CalculationOutcome

Type: Object

PropertyTypeDescription
idstring | numberOutcome id you are using in OfferingResponse
statusStatus

#DataAdapterProviderConfig

Type: Object

Collection of functions used for communication between widget and client code. Examples can be found in corresponding type definitions.

PropertyTypeDescription
getOfferinggetOfferingFunction called to get market offering.
calculatecalculateFunction called to get check for conflicts in selected markets, to get calculated odds for selection and to get which markets are still available with current selection
addToBetSlipaddToBetSlipThis function is called when the user clicks "Add to bet slip" button.

#Market

Type: Object

PropertyTypeRequiredDefaultDescription
idstring | numberYesUnique id for category
statusStatusYes
namestringYesMarket name to be displayed
fullNamestringNoThe full name of the market (usually for player markets) displayed in the tooltip on mouse hover.
outcomesOutcome[]YesArray of outcomes for market
srMarketSRMarketNoIf given we will try to match it with recommended configuration
srAllowMultipleOutcomesbooleanNoSet to true if you wish to enable selection of multiple outcomes of this market. CAUTION: Using this setting might not work with custom bet
srMarketLayout'list' | 'grid' | 'accordion'No'list'Layout used to display outcomes
iconUrlstringNoUrl to for custom icon of market

#Example

javascript
{
 id: oneXtwo,
 status: { isActive: true }
 name: '1x2',
 outcomes: [{ id: 1, status: { isActive: true }, name: 'Luton Town' }, ...]
 srMarket: { id: '1' }
}

#MarketCategory

Type: Object

PropertyTypeDescription
idstring | numberUnique id for category
namestringCategory name
cbCategoryItemsarray<string> | array<number>Array of market ids for category.

#Example

Market Category Example
javascript
{
 id: 1,
 name: 'Top Markets',
 cbCategoryItems: ['3way_market_UniqueId', 'doubleChance_market_UniqueId', ...]
}

#MarketMapping

Type: Object

Market mapping is configuration object that combines multiple markets into one view.

PropertyTypeRequiredDefaultDescription
idstring | numberYesUnique id for market mapping and market
statusStatusYes
namestringYesDisplayed market mapping name
marketListarray<string> | array<number>YesArray of market ids to be combined in this view.
cbViewLayout'row' | 'tabs'No'tabs'Layout used to display markets listed in marketList
srHideHeaderstringNoIf set to true it will hide either column or row header depending on the layout
iconUrlstringNoUrl to for custom icon of market

#OfferingResponse

Type: Object

PropertyTypeRequiredDescription
marketsMarket[]Yes
matchNamestringNoIf provided it will replace {teams.home} vs. {'teams.away'} derived from teams prop. If nether is present only product name will be displayed.
teamsobjectNo
teams.homestringYesHome team name
teams.awaystringYesAway team name
marketCategoriesMarketCategory[]NoRequired if you are not using sr ids. If provided it will also replace default settings for category.
metaMarketsMarketMapping[]NoMarket categories (metaMarkets) group markets together.

#Example

javascript
{
    teams: {
        home: England,
        away: Germany
    }
    markets: [
        {
            "id": 267674427,
            "status": {
                "isActive": true
            },
            "name": "Exact goals",
            "outcomes": [
                {
                    "id": 619793849,
                    "status": {
                        "isActive": true
                    },
                    "name": "0",
                    "srOutcomeId": "sr:exact_goals:5+:1336"
                },
                {
                    "id": 619793850,
                    "status": {
                        "isActive": true
                    },
                    "name": "1",
                    "srOutcomeId": "sr:exact_goals:5+:1337"
                },
                {
                    "id": 619793851,
                    "status": {
                        "isActive": true
                    },
                    "name": "2",
                    "srOutcomeId": "sr:exact_goals:5+:1338"
                },
                {
                    "id": 619793852,
                    "status": {
                        "isActive": true
                    },
                    "name": "3",
                    "srOutcomeId": "sr:exact_goals:5+:1339"
                },
                {
                    "id": 619793853,
                    "status": {
                        "isActive": true
                    },
                    "name": "4",
                    "srOutcomeId": "sr:exact_goals:5+:1340"
                },
                {
                    "id": 619793854,
                    "status": {
                        "isActive": true
                    },
                    "name": "5+",
                    "srOutcomeId": "sr:exact_goals:5+:1341"
                }
            ],
            "srMarket": {
                "id": "21",
                "specifiers": "sr:exact_goals:5+"
            }
        },
        ...
    ]
}

#Outcome

Type: Object

PropertyTypeRequiredDescription
idstring | numberYesOutcome unique id
statusStatusYes
namestringYesOutcome name
cbColumnstringNoIf present we will sort the outcomes in the given column, srOutcomeId will be ignored
srOutcomeIdstringNoSportradar outcome id

#Example

Outcome 'Other' will be placed in draw column:

Correct Score Example
javascript
{
 id: 'cs_other',
 status: { isActive: true }
 name: 'Other',
 cbColumn: 'Draw'
 srOutcomeId: '324'
}

#SRCalculationOutcome

Type: Object

PropertyTypeDescription
srOutcomeIdstringSportradar outcome id
statusStatus

#Callbacks

#calculate

ParameterTypeDescription
argsCalculateArgs
callbackcalculateCallback

#Example

javascript
function calculate(args, callback) {
    // Args parameter has data needed to call CustomBet calculate api.
    // Parse and convert calculate api response.
    callback(undefined, dataObject]
    });
};

#calculateCallback

ParameterTypeDescription
errorCBError | string | undefinedError object or UOF forwarded xml as string.
dataCalculateResponse

#getOffering

ParameterTypeDescription
argsMatchArgs
callbackgetOfferingCallback

#Example

javascript
function getOffering(args, callback) {
    // Get and convert data
    callback(undefined, dataObject]
    });
};

#getOfferingCallback

ParameterTypeDescription
errorCBError | string | undefinedError object or UOF forwarded xml as string.
dataOfferingResponse
Last updated 13 days ago
Is this site helpful?
Widgets, Engagement Tools
UOF ProxyCustom Views
On this page
  • Data Flow Chart
  • Custom Views Integration Tutorial
  • Integration Example
  • Type Definitions
  • CalculateResponse
  • CalculationMarket
  • CalculationOutcome
  • DataAdapterProviderConfig
  • Market
  • MarketCategory
  • MarketMapping
  • OfferingResponse
  • Outcome
  • SRCalculationOutcome
  • Callbacks
  • calculate
  • calculateCallback
  • getOffering
  • getOfferingCallback