Entities

1. When a value in a specific language is requested, a "null" value is returned

  • Check whether the HTTP request associated with the entity on which the request was made, failed (review the REST traffic log)

  • Is the specified language part of the "desired languages" / "supported languages"?

  • Was the language passed to the method used to retrieve the entity higher in the hierarchy tree? e.g. requesting a language for the outcome name from the market that was requested for a different language will return a null outcome name.

  • There are cases where the requested entity does not exist on the server. e.g. requesting a tournament schedule for the tournament which currently does not have an associated schedule.

2. When retrieving a property on an entity constructed from data return from the Sports API a null is returned

Some entities (sport hierarchy (sports, categories, tournaments, sport events), market names, outcome names, ....) are constructed from data obtained via an HTTP request (one of the endpoints found on iodocs). A null value will be returned to the associated method call if the request fails. For failed HTTP requests review the REST traffic log. (See: SDK - Error Handling)

3. A SportEvent entity passed to SDK callbacks/events does not contain a method to retrieve information which should be there

A SportEvent entity is a "base" for more specific entities (match, race, tournament, ...). If the SportEvent entity does not contain the required method, the SportEvent entity must be "type-casted" to a more specific type. For more details on the sport event derived types see the diagram in the (See: Java SDK - SportEvent and .Net SDK - SportEvent)

4. How to access the EventTimeline in the context of oddsChange?

The following is the code snippet (java and .net respectively) that can help log the EventTimeline information.

if(oddsChange.getEvent() instanceof Match){
        Match match = (Match) oddsChange.getEvent();
        EventTimeline eventTimeline = match.getEventTimeline(Locale.ENGLISH);
        if (match.getEventTimelineIfPresent(Locale.ENGLISH).isPresent()) {
            logger.info("scoreHistory: ");
            for (TimelineEvent timelineEvent : eventTimeline.getTimelineEvents()) {
                logger.info("scoreHistory Entry (id): " + timelineEvent.getId());
                logger.info("scoreHistory Entry (sequenceNo): --------");
                logger.info("scoreHistory Entry (matchTime): " + timelineEvent.getMatchClock());
                logger.info("scoreHistory Entry (player): " + timelineEvent.getPlayer().getName(Locale.ENGLISH));
                logger.info("scoreHistory Entry (scoringTeam): " + timelineEvent.getTeam());
                logger.info("scoreHistory Entry (Score Home): " + timelineEvent.getHomeScore());
                logger.info("scoreHistory Entry (Score Away): " + timelineEvent.getAwayScore());
                logger.info("scoreHistory Entry (canceled): " + timelineEvent.getMatchStatusCode());
            }
        }
    }

5. How to get Soccer Statistics from SoccerEvent in context of oddsChange?

You should add the following code snippet to your EventListener implementation.

if(oddsChange.getEvent() instanceof SoccerEvent){
            SoccerEvent soccerEvent1 = (SoccerEvent) oddsChange.getEvent();
            SoccerStatus soccerStatus = soccerEvent1.getStatus();
            SoccerStatistics soccerStatusStatistics = soccerStatus.getStatistics();
            List<PeriodStatistics> periodStatistics = soccerStatusStatistics.getPeriodStatistics ();
            List<TeamStatistics> totalStatistics = soccerStatusStatistics.getTotalStatistics();
}

6. How to access the fixtureChange API endpoint via the SDK and get fixtureChanges?

Inorder to access and get fixtureChanges, use the following

SportsInfoManager sportsInfoManager = oddsFeed.getSportsInfoManager();
 
List<FixtureChange> fixtureChanges = sportsInfoManager.getFixtureChanges();
for (FixtureChange fixtureChange : fixtureChanges){
 
    Urn sportEventId = fixtureChange.getSportEventId();
    Date updateTime = fixtureChange.getUpdateTime();
    Competition competition = sportsInfoManager.getCompetition(sportEventId);
 
    if(competition instanceof Match){
        Match match = (Match) competition;
 
        Fixture fixture = match.getFixture();
        MatchStatus status = match.getStatus();
 
    }
}

7. How to get an event score via feed message (e.g. odds_change)?

The following depicts the code snippet to get the event score via odds_change messages. You can use this as a base to write code to get the same via other feed messages.

if(oddsChanges.getEvent() instanceof Match) {
    Match match = (Match)oddsChanges.getEvent();
    MatchStatus matchStatus = match.getStatus();
    BigDecimal awayScore = matchStatus.getAwayScore();
    BigDecimal homeScore = matchStatus.getHomeScore();
    List<PeriodScore> periodScores = matchStatus.getPeriodScores();
}

8. How to get match status?

LocalizedNamedValue matchStatus = match.getStatus().getMatchStatus();

9. How to get current_server?

Most common properties recieved in the sport event status are directly exposed on the status object via a dedicated method. All others can be obtained through properties list. You can refer this - Java / .Net

match.getStatus().getPropertyValue("CurrentServer")

10. How to check if a match is Pre-match only or Live?

To check if a match is pre-match only or live, you'll need to consider the bookingStatus availability

BookingStatus bookingStatus = match.getBookingStatus();
if(bookingStatus.equals(BookingStatus.Unavailable)) {
    // this match is pre-match only (at least for now)
}
else {
    // this match will be covered by live
}

11. How do I book live events for the following hour?

SportDataProvider sportDataProvider = uofSdk.getSportsDataProvider();
BookingManager bookingManager = uofSdk.getBookingManager();
 
Date today = new Date();
List<Competition> competitionsToday = sportDataProvider.getCompetitionsFor(today);
for (Competition competition : competitionsToday) {
    Date scheduledTime = competition.getScheduledTime();
    Instant scheduledTimeInstant = scheduledTime.toInstant();
 
    // if difference is negative, the event is scheduled before now
    long hoursDifference = Duration.between(Instant.now(), scheduledTimeInstant).toHours();
 
    if(hoursDifference <= 1 && hoursDifference > -1) {
        boolean booked = bookingManager.bookLiveOddsEvent(competition.getId());
        if(booked) {
            logger.info(competition.getId().toString() + "Scheduled at: " + scheduledTime.toString());
        }
    }
}

12. How to get referenceIDs for events and competitors (e.g. AAMS id)?

SportDataProvider sportDataProvider = uofSdk.SportDataProvider();
 
Competition comp = sportDataProvider.getCompetition(Urn.parse("sr:match:15160287"));
if(comp instanceof Match) {
    Match match = (Match) comp;
    Fixture fixture = match.getFixture();
    Reference fixtureReferences = fixture.getReferences();
    Integer fixtureAamsId = fixtureReferences.getAamsId();
 
    TeamCompetitor homeCompetitor = match.getHomeCompetitor();
    Reference homeCompetitorReferences = homeCompetitor.getReferences();
    Integer homeCompetitorsAamsId = homeCompetitorReferences.getAamsId();
}

Last updated

Was this helpful?