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

UOF Proxy

UOF proxy integration requires and expects responses from the unified odds feeds. So a working integration of the UOF is required. See UOF for more information.

#Prerequisites

  • UOF API Key → To access the API you must visit Betradar and generate an application key associated with Betradar user details. This API key has to be sent as an HTTP header on every request towards the service.
  • Store account → Sales need to submit a trial request through a customer account in Salesforce with all required products, sports, tournaments, and domains. After that, Jira issue will be generated, and order can be created.

#Unified Odds Feeds

The following UOF's are required to process over UOF infrastructure:

  • Available Selections
    Will return all available (and allowed) markets for the selected sport event.
  • Calculate
    Calculate probability (odds) for your selected outcomes. This is the same list as the one from available_selections, excluding the already picked markets and markets that aren't compatible with your selected outcomes.
  • Markets
    Will return descriptions of all available markets
  • Fixture
    Lists the fixture for a specified event
  • Profile
    Name and details about a competitor (team, race driver, tennis player etc).

#Overview

Custom Bet Proxy
  1. Widget will request data every 30 seconds by executing functions provided to widget by UOFDataProviderConfig parameter. Widget will then update accordingly upon receiving necessary data by callback parameters. Detailed flow of data can be seen in chart below.
  2. Those functions then calls proxy which needs to be implemented on clients side.
  3. Proxy then needs to make requests to the Sportradar UOF API.
  4. Response from the UOF API.
  5. Response content from the UOF API is forwarded as string to the Custom Bet Widget.

#Data Flow Chart

Custom Bet Flow Proxy

#Proxy Integration Example

html
<script>
  (function (a, b, c, d, e, f, g, h, i) {
    /* SIR function code */
  })(
    window,
    document,
    "script",
    "https://widgets.sir.sportradar.com/betradar/widgetloader",
    "SIR",
    {
      language: "en",
      oddsType: "eu", // 'uk' or 'us' is also accepted
    },
  );

  SIR("addWidget", ".sr-widget", "customBet", {
    matchId: 123456789,
    dataProvider: "uofProxy",
    dataProviderConfig: {
      getFixture,
      getMarkets,
      calculate,
      getAvailableMarkets,
      getProfile,
      addToBetSlip,
    },
  });
</script>
<div id="sr-widget"></div>

#UOFDataProviderConfig

Collection of functions used for communication between the widget and client code. The widget calls these functions every 30 seconds to refresh data.

PropertyTypeDescription
getFixturegetFixtureFetches fixture data from Fixture API
getMarketsgetMarketsFetches market descriptions from Markets API
calculatecalculateCalculates odds from Calculate API
getAvailableMarketsgetAvailableMarketsFetches available selections from Available Selections API
getProfilegetProfileFetches competitor profile from Competitor Profile API
addToBetSlipaddToBetSlipCalled when the user clicks "Add to bet slip" button

#Types

#UOFDataProviderCallback

Callback function shared by all data provider functions. Pass UOF XML response as a string.

ParameterTypeDescription
errorCBError | string | undefinedError object, or false on success
datastringForwarded UOF XML data as string

Example:

javascript
// Success
callback(false, xmlString);

// Error
callback({ type: 1, message: "Could not fetch data" });

#getFixture

Fetches fixture data for a given match. It is given matchId and expects callback function UOFDataProviderCallback to be executed with UOF data.

ParameterTypeDescription
argsMatchArgsMatch identifier
callbackUOFDataProviderCallbackCallback with UOF XML response
javascript
function getFixture(args, callback) {
  fetch(`${apiUrl}/v1/sports/${lang}/sport_events/${args.matchId}/fixture.xml`)
    .then((res) => (res.ok ? res.text() : Promise.reject(res)))
    .then((xml) => callback(false, xml))
    .catch(() => callback({ type: 1, message: "Could not get fixture data" }));
}

#getMarkets

Fetches all market descriptions. No arguments are required. Expects callback function UOFDataProviderCallback to be executed with UOF data.

ParameterTypeDescription
args-No arguments required
callbackUOFDataProviderCallbackCallback with UOF XML response
javascript
function getMarkets(args, callback) {
  fetch(`${apiUrl}/v1/descriptions/${lang}/markets.xml?include_mappings=true`)
    .then((res) => (res.ok ? res.text() : Promise.reject(res)))
    .then((xml) => callback(false, xml))
    .catch(() => callback({ type: 1, message: "Could not get markets data" }));
}

#calculate

Calculates probability (odds) for selected outcomes. It is given matchId and selectedOutcomes, and expects callback function UOFDataProviderCallback to be executed with UOF data. Sends selections as XML via POST.

ParameterTypeDescription
argsCalculateArgsMatch ID and array of selected outcome objects
callbackUOFDataProviderCallbackCallback with UOF XML response
javascript
function calculate(args, callback) {
  var body = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <filterSelections xmlns="http://schemas.sportradar.com/custombet/v1/endpoints">
      <selection id="${args.matchId}">
        ${args.selectedOutcomes.map((o) => o.getSelection()).join(" ")}
      </selection>
    </filterSelections>`;

  fetch(`${apiUrl}/v1/custombet/calculate-filter`, {
    method: "POST",
    headers: { "Content-Type": "application/xml" },
    body: body,
  })
    .then((res) => (res.ok ? res.text() : Promise.reject(res)))
    .then((xml) => callback(false, xml))
    .catch(() => callback({ type: 3, message: "Could not calculate odds" }));
}
info

Each UniqueOutcome object exposes helper methods — getSelection() builds the XML element for the UOF endpoint, equals() and isSameMarket() compare outcomes, and toString() returns a string representation. See UniqueOutcome Methods for details.

#getAvailableMarkets

Fetches all available (and allowed) markets for a match. It is given matchId and expects callback function UOFDataProviderCallback to be executed with UOF data.

ParameterTypeDescription
argsMatchArgsMatch identifier
callbackUOFDataProviderCallbackCallback with UOF XML response
javascript
function getAvailableMarkets(args, callback) {
  fetch(`${apiUrl}/v1/custombet/${args.matchId}/available_selections`)
    .then((res) => (res.ok ? res.text() : Promise.reject(res)))
    .then((xml) => callback(false, xml))
    .catch(() =>
      callback({ type: 1, message: "Could not get available markets" }),
    );
}

#getProfile

Fetches competitor (team/player) profile data. It is given teamId and expects callback function UOFDataProviderCallback to be executed with UOF data.

ParameterTypeDescription
argsTeamArgsCompetitor identifier
callbackUOFDataProviderCallbackCallback with UOF XML response
javascript
function getProfile(args, callback) {
  fetch(`${apiUrl}/v1/sports/${lang}/competitors/${args.teamId}/profile.xml`)
    .then((res) => (res.ok ? res.text() : Promise.reject(res)))
    .then((xml) => callback(false, xml))
    .catch(() => callback({ type: 1, message: "Could not get profile data" }));
}
Last updated 13 days ago
Is this site helpful?
Widgets, Engagement Tools
OverviewData Adapter
On this page
  • Prerequisites
  • Unified Odds Feeds
  • Overview
  • Data Flow Chart
  • Proxy Integration Example
  • UOFDataProviderConfig
  • Types
  • UOFDataProviderCallback
  • getFixture
  • getMarkets
  • calculate
  • getAvailableMarkets
  • getProfile