Skip navigation links

Unified Odds SDK 1.5.3.0 API

The Unified Odds SDK provides a simple and efficient way to access Sportradar's odds and sport information for a bookmaker.

See: Description

Packages 
Package Description
com.sportradar.unifiedodds.sdk  
com.sportradar.unifiedodds.sdk.oddsentities  
com.sportradar.unifiedodds.sdk.replay  
com.sportradar.unifiedodds.sdk.sportentities  
The Unified Odds SDK provides a simple and efficient way to access Sportradar's odds and sport information for a bookmaker. It combines subscription of messages and RESTful API calls into a unified Java interface that hides most of the complexity including recovery.

A Basic way to use the OddsFeed

First you implement an OddsFeedListener that will receive a callback for each message.

Then to actually connect and start receiving messages you do the following:

       MyOddsFeedListener listener = new MyOddsFeedListener();
       OddsFeedConfiguration config = new OddsFeedConfiguration();  
           config.setBookmakerId(your-bookmaker-id);
           config.setAccessToken(your-access-token);       
           OddsFeedSessionBuilder builder = OddsFeedSessionBuilder(myListener, config);
           OddsFeedSession session = builder.setListener(myListener).setMessageInterest(MessageInterest.AllMessages).build();
           

See OddsFeedListener and OddsFeedSessionBuilder for details.

That should be about it! If you want to get available sport events, active tournaments, or all sports you can get the SportsInfo from the OddsFactory:

              SportsInfo sportsInfo = session.getSportsInfo();
              for (String sport : sportsInfo.getSports()) {
                     System.out.println(sport);
              }
              for (Tournament tournament : sportsInfo.getActiveTournaments("soccer")) {
                     System.out.println(tournament);
              }

              // Get all sportEvents scheduled for today
              for (SportEvent sportEvent : sportsInfo.getSportEventsFor(new Date())) {
                     
              }

              // Get all live sportEvents 
              for (SportEvent sportEvent : sportsInfo.getLiveSportEvents()) {
                     
              }

More Advanced Usage

Note that there is one thread handling message reception and calling your registered listener per session, so the processing within your listener should be as quick as possible to not prevent following messages from being processed.

Another more scalable way of listening to events is to have two different sessions one for high-priority messages and another for low-priority-messages. This means that the low priority messages will not prevent high-priority messages from getting processed. (BetSettlement is considered low-priority, OddsChanges and FixtureChange are considered high-priority events). To create two different sessions for the high and low-priority events you do the following:

       MyOddsFeedListener listener = new MyOddsFeedListener();
       OddsFeedConfiguration config = new OddsFeedConfiguration();  
           config.setBookmakerId(your-bookmaker-id);
           config.setAccessToken(your-access-token);       
           OddsFeedSessionBuilder builder = OddsFeedSessionBuilder(myListener, config);
       builder.setListener(listener).setMessageInterest(MessageInterest.HiPrioMessagesOnly).build();
           builder.setListener(listener).setMessageInterest(MessageInterest.LoPrioMessagesOnly).build();
Note that the same listener is used for both channels, but when creating the two different sessions, different MessageInterest levels are provided. In this case, you will get two different threads doing the processing of the different types of messages.

Live Only Processing

If you wish to only process live events in your system and maybe process prematch events in completely different system, you can do this in a similar manner.
           builder.setListener(listener).setMessageInterest(MessageInterest.LiveMessagesOnly).build();
This kind of session will receive all messages except OddsChanges happening before the game starts (you will start receiving OddsChanges some minutes before the game starts) and BetSettlement resulting from confirmed results (you will still receive BetSettlments when the game ends, but not when Sportradar some 15minutes or later after the game confirms the match results).

Localization

By default all messages are in English. You can yourself decide what the default language should be in UnifiedOddsConfiguration and you can request other languages by specifying that Locale in most get operations.

System Failures

The Unified Odds SDK is designed to help you handle various networking outages and Sportradar subsystem failures. If some Sportradar subsystem stops working, the SDK will detect this and bet stop all sportevents currently handled by that subsystem. When the subsystem reappears the SDK will automatically reconnect and request the most recent odds information and any missed betsettlement information. If your system crashes or if you take down your system and restarts it you need to provide the UnifiedOdds SDK with a timestamp when you restart if you want to recover any betsettlements that you should have received in the meantime.

References

See OddsFeedListener and OddsFeedSessionBuilder for details.
Skip navigation links

Copyright © 2016–2017. All rights reserved.