Betting Entertainment Tools

UOF Proxy

Overview

UOF proxy integration requires and expects responses from the unified odds feeds. So a working integration of the UOF is required. Documentation on UOF can be found here!

Prerequisites

  • UOF API Key → To access the API you must visit Betradar.com and generate an application key associated with Betradar.com 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


  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 bellow.
  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


Example

Proxy Integration Example - for dataProviderConfig example check Widgets.CustomBet.UOFProxy.UOFDataProviderConfig

<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: 'uofProxy',
        // for dataProviderConfig props check type definitions
        dataProviderConfig: {
            getFixture,
            getMarkets,
            calculate,
            getAvailableMarkets,
            getProfile,
            addToBetSlip
        }
    });
</script>
<div id="sr-widget"></div>

Type Definitions

# UOFDataProviderCallback(error, data)

Parameters
Name Type Description
error CBError Widgets.CustomBet.CustomBet.CBError | string | undefined

Error object or UOF forwarded xml as string.

data string

Forwarded UOF xml data as string.

Object

# UOFDataProviderConfig

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

Properties:
Name Type Description
getFixture getFixture Widgets.CustomBet.UOFProxy.getFixture

Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/Static%20sport%20event%20information/fixturesForEvent.

getMarkets getMarkets Widgets.CustomBet.UOFProxy.getMarkets

Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/Betting%20descriptions/markets.

calculate calculate Widgets.CustomBet.UOFProxy.calculate

Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/CustomBet%20API/calculateProbability.

getAvailableMarkets getAvailableMarkets Widgets.CustomBet.UOFProxy.getAvailableMarkets

Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/CustomBet%20API/availableSelections.

getProfile getProfile Widgets.CustomBet.UOFProxy.getProfile

Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/Entity%20descriptions/competitorInformation.

addToBetSlip addToBetSlip Widgets.CustomBet.CustomBet.addToBetSlip

This function is called when the user clicks "Add to bet slip" button.

# calculate(args, callback)

Parameters
Name Type Description
args CalculateArgs Widgets.CustomBet.CustomBet.CalculateArgs

Given data needed to call UOF api data from https://iodocs.betradar.com/#/CustomBet%20API/calculateProbability.

callback UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback

Callback function to be executed with data received from UOF api.

Example
function calculate(args, callback) {
    var postContent =
        args.selectedOutcomes.length > 0 &&
        `<?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="${args.matchId}">
                    ${args.selectedOutcomes.map((outcome) => {
                        //getSelection function is a helper function that will create the xml object for you
                        return outcome.getSelection();
                    }).join(' ')}
                </selection>
        </filterSelections>`;

    //call to backend API, replace apiUrl
    fetch('https://${apiUrl}/v1/custombet/calculate-filter', {
        headers: { 'Content-Type': 'application/xml' },
        method: 'POST',
        body: postContent
    })
    .then( response => {
        if (response.ok) {
            return response.text()
        } else {
            throw response;
        }
    })
    .then( xmlString => {
        callback(false, xmlString)
    })
    .catch( error => {
        callback(
            {
                message: 'Could not get fixture data',
                error_code: '400'
            }
        );
    })
}

# getAvailableMarkets(args, callback)

Parameters
Name Type Description
args MatchArgs Widgets.CustomBet.CustomBet.MatchArgs

Given data needed to call UOF api data from https://iodocs.betradar.com/#/CustomBet%20API/availableSelections.

callback UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback

Callback function to be executed with data received from UOF api.

Example
function getAvailableMarkets(args, callback) {
   //call to backend API, replace apiUrl and matchId
   fetch('$(apiUrl)/v1/custombet/{matchId}/available_selections')
   .then( response => {
       if (response.ok) {
           return response.text()
       } else {
           throw response;
       }
   })
   .then( xmlString => {
       callback(false, xmlString)
   })
   .catch( error => {
       callback(
           {
               message: 'Could not get fixture data',
               error_code: '400'
           }
       );
   })
}

# getFixture(args, callback)

Function called when UOF fixture data is requested. It is given Widgets.CustomBet.CustomBet.MatchArgs and expects callback function Widgets.CustomBet.UOFProxy.UOFDataProviderCallback to be executed with UOF data.

Parameters
Name Type Description
args MatchArgs Widgets.CustomBet.CustomBet.MatchArgs

Given data needed to call UOF api data from https://iodocs.betradar.com/#/Static%20sport%20event%20information/fixturesForEvent.

callback UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback

Callback function to be executed with data received from UOF api.

Properties:
Name Type Description
getMarkets getMarkets Widgets.CustomBet.UOFProxy.getMarkets

Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/Betting%20descriptions/markets.

Example
function getFixture(args, callback) {
   // call to backend API, replace apiUrl and matchId. MatchId is given in args parameter
   fetch('${apiUrl}/v1/sports/{language}/sport_events/{matchId}/fixture.xml')
    .then( response => {
       if (response.ok) {
           return response.text()
       } else {
           throw response;
       }
   })
   .then( xmlString => {
       callback(false, xmlString)
   })
   .catch( error => {
       callback(
               {
                   message: 'Could not get fixture data',
                   error_code: '400'
               }
           );
   })
}

# getMarkets(args, callback)

Function called when UOF markets data is requested. Expects callback function Widgets.CustomBet.UOFProxy.UOFDataProviderCallback to be executed with UOF data.

Parameters
Name Type Description
args undefined | null

No arguments needed for UOF api data from https://iodocs.betradar.com/#/Betting%20descriptions/markets.

callback UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback

Callback function to be executed with data received from UOF api.

Example
function getMarkets(args, callback) {
    // call to backend API, replace apiUrl
    fetch('$(apiUrl)/v1/descriptions/{language}/markets.xml?include_mappings=true')
    .then( response => {
        if (response.ok) {
            return response.text()
        } else {
            throw response;
        }
    })
    .then( xmlString => {
        callback(false, xmlString)
    })
    .catch( error => {
        callback(
            {
                message: 'Could not get markets data',
                error_code: '400'
            }
        );
    })
}

# getProfile(args, callback)

Parameters
Name Type Description
args TeamArgs Widgets.CustomBet.CustomBet.TeamArgs

Given data needed to call UOF api data from https://iodocs.betradar.com/#/Entity%20descriptions/competitorInformation.

callback UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback

Callback function to be executed with data received from UOF api.

Example
function getProfile(args, callback) {
   // call to backend API, replace apiUrl and teamId
   fetch('$(apiUrl)/v1/sports/{language}/competitors/{teamId}/profile.xml')
   .then( response => {
       if (response.ok) {
           return response.text()
       } else {
           throw response;
       }
   })
   .then( xmlString => {
       callback(false, xmlString)
   })
   .catch( error => {
       callback(
           {
               message: 'Could not get fixture data',
               error_code: '400'
           }
       );
   })