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

Global SIR API

The SIR API is exposed as a global SIR function that provides the primary interface for integrating and managing Sportradar widgets on your page.

#Global Configuration Options

The following options can be configured in the widgetloader script initialization:

OptionTypeDescription
languagestringLanguage code for widget content. See Languages for supported codes.
clockTypestringClock format: '12' or '24'. Controls time display across widgets.
oddsTypestringOdds format: 'eu' (decimal), 'uk' (fractional), or 'us' (american).
themestring | falseTheme identifier or false for no theme. Available public themes: 'betradar', 'sportradar', 'betradardark', 'sportradardark'. Create custom themes on the Widgets demo page.
s5ClientAliasstringStatistics client alias for widgets like tournament preview and match preview.
logLevelstringLogging level: 'warn', 'info', or 'error'. Works with debug option.
unitTypestringUnit system: 'metric' or 'imperial'. Affects length, height, weight, temperature, and speed displays. Init-only — there is no changeUnitType runtime method; changing units requires re-initializing the widget loader.
debugbooleanEnable debug mode. When true, sets logLevel to 'warn'. When false, disables logging.
adapterDataSourcestringEnable integrated adapter. String value will be given to you by setup team.

#Initialization

Initialize the widget framework with configuration options. Commands executed before the framework loads are queued and run after initialization completes.

View Initialization Code

html
<script type="text/javascript">
    (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://widgets.sir.sportradar.com/YOUR_CLIENT_ID/widgetloader","SIR", {
        language: 'en',
        debug: true
    });
</script>
warning

Replace YOUR_CLIENT_ID in the URL with your actual Client ID.

Adding a Widget:

html
<script>
     // Syntax: SIR(<methodName>[, ...arguments]);
     SIR('addWidget', '#my-div', 'match.scoreboard');
</script>
<div id="my-div"></div>

#API Methods

All methods are invoked using the global SIR function with the method name as the first parameter, followed by method-specific arguments.

tip

API method names are case-insensitive at runtime — they are lowercased internally before dispatch. SIR('addWidget', ...) and SIR('AddWidget', ...) are equivalent.

#addWidget

Adds a widget to a specified DOM element or selector.

warning

This method replaces the entire content of the target element with the widget.

#Parameters

NameTypeAttributesDescription
method'addWidget'<required>Method name.
domElOrSelectorstring | DomElement<required>Widget DOM element or selector. For widget integrations within ShadowDOM, check shadowDOM mutation observer example.
namestring<required>Widget name.
propsobjectWidget configuration properties. See sub-properties below.

props sub-properties:

NameTypeAttributesDescription
silentbooleanWhen true, suppresses widget error displays.
onTrackfunctionEvent tracking callback. See Event Tracking Guide for details.
widgetProps*<repeatable>Additional widget-specific properties passed through to the widget.
callbackfunctionTriggered only once, when widget is rendered (does not trigger on widget changes due to user action or async data loading.)

#updateWidget

Updates a widget on given DOM element or selector.

#Parameters

NameTypeAttributesDescription
method'updateWidget'<required>Method name.
domElOrSelectorstring | DomElement<required>Widget DOM element or selector. For widget integrations within ShadowDOM, check shadowDOM mutation observer example.
propsobjectWidget props.
callbackfunctionTriggered only once, when widget is rendered (does not trigger on widget changes due to user action or async data loading.)
onlyServerRenderbooleanIf true, server will render the widget and populate the given element. User interaction will not work.

#removeWidget

Removes a widget on given DOM element or selector.

#Parameters

NameTypeDescription
method'removeWidget'Method name.
domElOrSelectorstring | DomElementWidget DOM element or selector. For widget integrations within ShadowDOM, check shadowDOM mutation observer example.

#registerAdapter

Registers a data adapter for retrieving information from your page or custom APIs.

info

Adapters enable widgets to access client-specific data sources and integrate with your existing infrastructure.

Parameters

NameTypeDescription
method'registerAdapter'Method name.
adapterAdapterObjectHosted adapter name provided by us or your own implementation.

#check

Scans the DOM for elements with the data-sr-widget attribute and initializes any uninitialized widgets. Also destroys widget instances when their DOM nodes are removed.

tip

Use this method after dynamically adding widget elements to the page or when using declarative HTML integration.

#Parameters

NameTypeDescription
method'check'Method name.
callbackfunctionCallback triggered with array of all widgets instantiated. Each array item is an object with following properties: widgetDomElement, widgetInstance, widgetClass.

#changeLanguage

Changes the display language for all widgets.

warning

Forces a complete reload of all widgets. Internal widget state will be lost.

#Parameters

NameTypeDescription
method'changeLanguage'Method name.
languagestringFor available languages see Languages.

#changeClockType

Changes the clock format between 12-hour and 24-hour display.

warning

Forces a complete reload of all widgets. Internal widget state will be lost.

#Parameters

NameTypeDescription
method'changeClockType'Method name.
clockTypestring'12' or '24'

#changeOddsType

Changes the odds display format across all widgets.

warning

Forces a complete reload of all widgets. Internal widget state will be lost.

#Parameters

NameTypeDescription
method'changeOddsType'Method name.
oddsTypestringMust be one of 'eu', 'us' or 'uk'.

#changeTeamInvert

Controls the left/right positioning of home and away teams in widget displays.

info

By default, home teams appear on the left and away teams on the right, except for NFL and baseball which are inverted.

warning

Forces a complete reload of all widgets. Internal widget state will be lost.

#Parameters

NameTypeDescription
method'changeTeamInvert'Method name.
teamInvertobjectExample: { sid: { 3: true }} inverts teams for all baseball matches.
allbooleanInvert all matches.
sidObject.<string, boolean>Dictionary of sport ids to invert.
rcidObject.<string, boolean>Dictionary of real category ids to invert.
utidObject.<string, boolean>Dictionary of unique tournament ids to invert.

Example:

javascript
// Invert all baseball matches (sport ID 3)
SIR('changeTeamInvert', { sid: { 3: true } });

// Invert all matches across every sport
SIR('changeTeamInvert', { all: true });

// Invert matches in a specific real category (rcid)
SIR('changeTeamInvert', { rcid: { 44: true } }); // e.g. UEFA Champions League

// Invert matches in a specific unique tournament (utid)
SIR('changeTeamInvert', { utid: { 1: true, 17: true } }); // e.g. specific competitions

// Combine multiple scopes
SIR('changeTeamInvert', { sid: { 3: true }, utid: { 1: true } });

#changeLogLevel

Changes the logging verbosity level for debugging purposes.

tip

Use higher log levels (like 'info') when troubleshooting widget issues.

#Parameters

NameTypeDescription
method'changeLogLevel'Method name.
logLevelstring'error''warn''info'

#setClientTheme

Dynamically loads and applies a widget theme.

info

You can use a theme URL or a client alias configured in your client setup.

#Parameters

NameTypeAttributesDescription
method'setClientTheme'<required>Method name.
themestring<required>Theme to load. Can be url (https) or client alias which exists in client setup (e.g. betradar).
callbackfunctionTriggered when theme is loaded.
Last updated 9 days ago
Is this site helpful?
Widgets, Engagement Tools
Widget ErrorsBET Utility API
On this page
  • Global Configuration Options
  • Initialization
  • API Methods
  • addWidget
  • updateWidget
  • removeWidget
  • registerAdapter
  • check
  • changeLanguage
  • changeClockType
  • changeOddsType
  • changeTeamInvert
  • changeLogLevel
  • setClientTheme