The SIR API is exposed as a global SIR function that provides the primary interface for integrating and managing Sportradar widgets on your page.
The following options can be configured in the widgetloader script initialization:
| Option | Type | Description |
|---|---|---|
language | string | Language code for widget content. See Languages for supported codes. |
clockType | string | Clock format: '12' or '24'. Controls time display across widgets. |
oddsType | string | Odds format: 'eu' (decimal), 'uk' (fractional), or 'us' (american). |
theme | string | false | Theme identifier or false for no theme. Available public themes: 'betradar', 'sportradar', 'betradardark', 'sportradardark'. Create custom themes on the Widgets demo page. |
s5ClientAlias | string | Statistics client alias for widgets like tournament preview and match preview. |
logLevel | string | Logging level: 'warn', 'info', or 'error'. Works with debug option. |
unitType | string | Unit 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. |
debug | boolean | Enable debug mode. When true, sets logLevel to 'warn'. When false, disables logging. |
adapterDataSource | string | Enable integrated adapter. String value will be given to you by setup team. |
Initialize the widget framework with configuration options. Commands executed before the framework loads are queued and run after initialization completes.
View Initialization Code
<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>Replace YOUR_CLIENT_ID in the URL with your actual Client ID.
Adding a Widget:
<script>
// Syntax: SIR(<methodName>[, ...arguments]);
SIR('addWidget', '#my-div', 'match.scoreboard');
</script>
<div id="my-div"></div>All methods are invoked using the global SIR function with the method name as the first parameter, followed by method-specific arguments.
API method names are case-insensitive at runtime — they are lowercased internally before dispatch. SIR('addWidget', ...) and SIR('AddWidget', ...) are equivalent.
addWidgetAdds a widget to a specified DOM element or selector.
This method replaces the entire content of the target element with the widget.
| Name | Type | Attributes | Description |
|---|---|---|---|
method | 'addWidget' | <required> | Method name. |
domElOrSelector | string | DomElement | <required> | Widget DOM element or selector. For widget integrations within ShadowDOM, check shadowDOM mutation observer example. |
name | string | <required> | Widget name. |
props | object | Widget configuration properties. See sub-properties below. |
props sub-properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
silent | boolean | When true, suppresses widget error displays. | |
onTrack | function | Event tracking callback. See Event Tracking Guide for details. | |
widgetProps | * | <repeatable> | Additional widget-specific properties passed through to the widget. |
callback | function | Triggered only once, when widget is rendered (does not trigger on widget changes due to user action or async data loading.) |
updateWidgetUpdates a widget on given DOM element or selector.
| Name | Type | Attributes | Description |
|---|---|---|---|
method | 'updateWidget' | <required> | Method name. |
domElOrSelector | string | DomElement | <required> | Widget DOM element or selector. For widget integrations within ShadowDOM, check shadowDOM mutation observer example. |
props | object | Widget props. | |
callback | function | Triggered only once, when widget is rendered (does not trigger on widget changes due to user action or async data loading.) | |
onlyServerRender | boolean | If true, server will render the widget and populate the given element. User interaction will not work. |
removeWidgetRemoves a widget on given DOM element or selector.
| Name | Type | Description |
|---|---|---|
method | 'removeWidget' | Method name. |
domElOrSelector | string | DomElement | Widget DOM element or selector. For widget integrations within ShadowDOM, check shadowDOM mutation observer example. |
registerAdapterRegisters a data adapter for retrieving information from your page or custom APIs.
Adapters enable widgets to access client-specific data sources and integrate with your existing infrastructure.
| Name | Type | Description |
|---|---|---|
method | 'registerAdapter' | Method name. |
adapter | AdapterObject | Hosted adapter name provided by us or your own implementation. |
checkScans 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.
Use this method after dynamically adding widget elements to the page or when using declarative HTML integration.
| Name | Type | Description |
|---|---|---|
method | 'check' | Method name. |
callback | function | Callback triggered with array of all widgets instantiated. Each array item is an object with following properties: widgetDomElement, widgetInstance, widgetClass. |
changeLanguageChanges the display language for all widgets.
Forces a complete reload of all widgets. Internal widget state will be lost.
| Name | Type | Description |
|---|---|---|
method | 'changeLanguage' | Method name. |
language | string | For available languages see Languages. |
changeClockTypeChanges the clock format between 12-hour and 24-hour display.
Forces a complete reload of all widgets. Internal widget state will be lost.
| Name | Type | Description |
|---|---|---|
method | 'changeClockType' | Method name. |
clockType | string | '12' or '24' |
changeOddsTypeChanges the odds display format across all widgets.
Forces a complete reload of all widgets. Internal widget state will be lost.
| Name | Type | Description |
|---|---|---|
method | 'changeOddsType' | Method name. |
oddsType | string | Must be one of 'eu', 'us' or 'uk'. |
changeTeamInvertControls the left/right positioning of home and away teams in widget displays.
By default, home teams appear on the left and away teams on the right, except for NFL and baseball which are inverted.
Forces a complete reload of all widgets. Internal widget state will be lost.
| Name | Type | Description |
|---|---|---|
method | 'changeTeamInvert' | Method name. |
teamInvert | object | Example: { sid: { 3: true }} inverts teams for all baseball matches. |
all | boolean | Invert all matches. |
sid | Object.<string, boolean> | Dictionary of sport ids to invert. |
rcid | Object.<string, boolean> | Dictionary of real category ids to invert. |
utid | Object.<string, boolean> | Dictionary of unique tournament ids to invert. |
Example:
// 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 } });changeLogLevelChanges the logging verbosity level for debugging purposes.
Use higher log levels (like 'info') when troubleshooting widget issues.
| Name | Type | Description | ||
|---|---|---|---|---|
method | 'changeLogLevel' | Method name. | ||
logLevel | string | 'error' | 'warn' | 'info' |
setClientThemeDynamically loads and applies a widget theme.
You can use a theme URL or a client alias configured in your client setup.
| Name | Type | Attributes | Description |
|---|---|---|---|
method | 'setClientTheme' | <required> | Method name. |
theme | string | <required> | Theme to load. Can be url (https) or client alias which exists in client setup (e.g. betradar). |
callback | function | Triggered when theme is loaded. |