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

Data Adapter

#What Is an Adapter?

An adapter is a piece of code that acts as a bridge between two systems. In the context of Bet Suggestions, an adapter connects your data source (such as a backend API or database) to the betting widgets displayed to users.

It listens for requests from the widget, processes them, fetches the necessary data, and then sends a response back to the widget. Think of the adapter as a translator that ensures seamless communication between your backend and the widget, ensuring real-time data synchronization for odds and outcomes.

#What Is the Purpose of an Adapter?

The adapter ensures that the data shown in the widget is always:

  • Accurate: Displays the latest active markets and odds.
  • Real-time: Updates markets and live odds.
  • Interactive: Enables users to engage with bets, outcomes, and markets directly from the widget.

In short, it ensures that what the user sees reflects the most up-to-date information from your backend system.

#How Does an Adapter Work?

When you register an adapter, it listens for specific types of requests from the widget:

Request TypeDescription
betConcierge.marketsProvides betting suggestions based on conversation with the AI assistant. Receives MarketsRequest with matchId and expects MarketsResponse in the callback.
betSlipMatches selections to the user's bet slip. Receives BetSlipRequest with userId and expects BetSlipResponse in the callback.
calculateCbXmlPrepares custom bet XML payload for UOF odds calculation. Receives CustomBetCalculateRequest and expects CustomBetCalculateResponse in the callback.

Each request type has a handler function that processes incoming data, formats it properly, and sends a response back to the widget.

#How to Register an Adapter

You register an adapter by calling the SIR global function:

javascript
SIR('registerAdapter', onRequest);

onRequest is a function that handles different types of requests by listening for events and responding accordingly.

#Handling Requests

Here's the general structure for handling incoming requests:

javascript
const onRequest = (requestName, args, callback) => {
  switch (requestName) {
    case 'betConcierge.markets':
      handleMarkets(args, callback);
      break;
    case 'betSlip':
      handleBetSlip(args, callback);
      break;
    case 'calculateCbXml':
      handleCustomBetCalculate(args, callback);
      break;
    default:
      callback(new Error('Unknown request'), undefined);
  }
};

#Responding to Requests

The adapter sends back a response using the callback function:

  • First argument: error | undefined
  • Second argument: The data response object.

For example:

javascript
callback(undefined, response);

If there is an error:

javascript
callback(new Error('Something went wrong'), undefined);

#Unsubscribing

The adapter can return an unsubscribe function for cleaning up event listeners or timers:

javascript
return () => {
  // Cleanup logic if needed
};
info

The Adapter documentation provides a complete example of how to implement the adapter.

The client has the possibility to have an adapter implemented by the Sportradar team. Please contact your Sportradar representative for more information.

#Type Definitions

#BetConciergeAdapter

Used to configure the adapter that retrieves and displays the information from the client's API.

ParameterTypeDescription
requestNamestringName of the requested adapter
argsMarketsRequest | BetSlipRequest | CustomBetCalculateRequestArguments for individual request
callbackOnRequestCallbackFunction that should be executed whenever data for the request changes

Example:

javascript
function onRequest(requestName, args, callback) {
    // adapter implementation
}

SIR('registerAdapter', onRequest);

#OnRequestCallback

Callback argument in the adapter onRequest function.

ParameterTypeDescription
errorObject | undefinedError object or undefined if there is no error
dataMarketsResponse | BetSlipResponse | CustomBetCalculateResponseShape of this object is defined by requestName

Returns: void

#MarketsRequest

Arguments for the markets request.

PropertyTypeDescription
matchIdstring | numberSportradar ID of the match

Example:

json
{
  "matchId": 50955897
}

#MarketSpecifier

PropertyTypeDescription
valuestring | numberSpecifier value

Example:

json
{
  "value": "total=2.5"
}

#MarketStatus

PropertyTypeDescription
status'active' | 'deactivated'Market status. If not active, market will not be displayed in the widget

Example:

json
{
  "status": "active"
}

#Outcome

Individual outcome within a market.

PropertyTypeRequiredDescription
idstring | numberYesSportradar outcome ID
namestringYesDisplayed outcome name
isSelectedbooleanYesUsed to mark outcomes as selected in the bet suggestions in the chat
oddsstring | numberNoString or number representation of odds displayed as is (NO FORMATTING)
oddsDecimalnumberNoNumeric EU representation of odds (decimal number) displayed on market outcome
statusObjectYes
status.isActivebooleanYesOutcome status. If not active, it will not be displayed in the widget
isRecommendedbooleanNoWhen true, the outcome will be highlighted as a recommended outcome

Example:

json
{
  "id": "1",
  "name": "PSG",
  "odds": "1.44",
  "isSelected": false,
  "status": {
    "isActive": true
  }
}

#MarketsResponse

Arguments for the markets response.

PropertyTypeRequiredDescription
marketsArray<Object>YesArray of supported markets. AI will suggest bets out of these markets
markets.idstring | numberYesSportradar market ID
markets.namestringYesDisplayed market name
markets.outcomesArray<[Outcome](#outcome)>YesArray of outcomes
markets.statusMarketStatusYesMarket status object
markets.specifierMarketSpecifierNoMarket specifier

Example:

json
{
  "markets": [
    {
      "id": "1",
      "name": "1x2",
      "outcomes": [
        {
          "id": "1",
          "name": "PSG",
          "odds": "1.44",
          "isSelected": false,
          "status": {
            "isActive": true
          }
        },
        {
          "id": "2",
          "name": "Draw",
          "odds": "4.80",
          "isSelected": false,
          "status": {
            "isActive": true
          }
        },
        {
          "id": "3",
          "name": "Nice",
          "odds": "7.50",
          "isSelected": false,
          "status": {
            "isActive": true
          }
        }
      ],
      "status": {
        "status": "active"
      }
    }
  ]
}

#BetSlipRequest

Arguments for the bet slip request.

PropertyTypeDescription
userIdstring | numberID of the user

Example:

json
{
  "userId": "user:12345"
}

#Bet

PropertyTypeDescription
idstring | number
eventObject
event.idstring | numberSportradar match id
marketsMarketsResponseArray of selected markets and outcomes (max 500)

Example:

json
{
  "id": "demo-bet",
  "event": {
    "id": 50955897
  },
  "markets": [
    {
      "id": "1",
      "name": "1x2",
      "outcomes": [
        {
          "id": "3",
          "name": "Nice",
          "isSelected": true,
          "status": {
            "isActive": true
          }
        }
      ],
      "status": {
        "status": "active"
      }
    }
  ]
}

#BetSlipResponse

Response containing user's current betting picks.

PropertyTypeRequiredDescription
picksArray<Object>YesUsers current betting picks. Used to match the selected outcomes form the picks array to the bet suggestions in the chat - Alternative to isSelected property in the market outcomes.
picks.eventIdstringYesSportradar match ID
picks.marketIdstringYesMarket ID of the selected outcome
picks.outcomeIdstringYesSelected outcome ID
picks.specifierstringNoMarket specifier of the selected outcome
combinedOddsnumber | stringNoCombined odds of the bets in the bet slip

Example:

json
{
  "picks": [
    {
      "eventId": "sr:match:50955897",
      "marketId": "1",
      "outcomeId": "3"
    },
    {
      "eventId": "sr:match:50955897",
      "marketId": "65",
      "outcomeId": "1712",
      "specifier": "hcp=0:2"
    }
  ],
  "combinedOdds": "21.50"
}

#CustomBetCalculateRequest

Arguments for the custom bet request.

PropertyTypeDescription
calculatePayloadstringCustom bet XML payload for UOF odds calculation

Example:

xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<filterSelections
    xmlns="http://schemas.sportradar.com/custombet/v1/endpoints"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://schemas.sportradar.com/custombet/v1/endpoints
    http://schemas.sportradar.com/custombet/v1/endpoints/Selections.xsd">
    <selection id="sr:match:50955897">
        <market market_id="1" outcome_id="3"/>
    </selection>
</filterSelections>

#CustomBetCalculateResponse

Arguments for the custom bet response.

PropertyTypeDescription
payloadstringCalculate custom bet XML response

Example:

xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<filtered_calculation_response generated_at="2025-04-16T13:29:08+00:00">
  <calculation odds="21.50303106727931" probability="0.030418715351118873" harmonization="false"/>
  <available_selections>
    <event id="sr:match:58265377">
      <markets>
        <market id="65" specifiers="hcp=0:2" conflict="false">
          <outcome id="1711" conflict="true"/>
          <outcome id="1712" conflict="true"/>
          <outcome id="1713" conflict="false"/>
        </market>
        ...
      </markets>
    </event>
  </available_selections>
</filtered_calculation_response>
Last updated 14 days ago
Is this site helpful?
Widgets, Engagement Tools
API and ExamplesMarket Mapping
On this page
  • What Is an Adapter?
  • What Is the Purpose of an Adapter?
  • How Does an Adapter Work?
  • How to Register an Adapter
  • Handling Requests
  • Responding to Requests
  • Unsubscribing
  • Type Definitions
  • BetConciergeAdapter
  • OnRequestCallback
  • MarketsRequest
  • MarketSpecifier
  • MarketStatus
  • Outcome
  • MarketsResponse
  • BetSlipRequest
  • Bet
  • BetSlipResponse
  • CustomBetCalculateRequest
  • CustomBetCalculateResponse