Self Service Implementation

What is a Self-Service Adapter?

A Self-Service Adapter is a custom integration layer that connects SIR Widgets to your betting data sources. Instead of using Sportradar's hosted adapter, you implement the data fetching logic yourself, giving you complete control over:

  • Data Sources – Connect to any odds/betting API

  • Data Transformation – Map your API responses to the widget-expected format

  • Caching Strategy – Implement your own caching and optimization

  • Real-Time Updates – Control how and when data refreshes

Understand the Adapter Structure

The adapter object consists of two primary properties:

  • config: Contains static configuration for widgets, such as layout options and filtering rules.

  • endpoints: A collection of functions that the widget calls to request data (e.g., event details, markets, odds).

const adapter = {
  config: {
    widget: {
      'betRecommendation.eventList': {
        layout: { /* EventListMarketsConfig */ },
        allowedMarkets: { /* SportMarketsMap */ }
      },
      // ... other widgets
    }
  },
  endpoints: {
    event: (args, callback) => {
      // Fetch and return event data
      // Return optional unsubscribe function
    },
    eventMarkets: (args, callback) => {
      // Fetch and return markets for event
    },
    market: (args, callback) => {
      // Fetch and return specific market
    }
    // ... other endpoints
  }
};

See full type definitions for all endpoints →

Understand the Adapter Data Flow

The following diagram illustrates how data flows from your backend API through the adapter and into the widget.

The adapter acts as a bridge, ensuring that whatever format your API returns is converted into the structure the widget expects.

Workflow Breakdown

The widget starts by asking the adapter which markets are available for each event using the availableMarketsForEvent endpoint. Example: The widget requests available markets for Event A, Event B, and Event C.

The adapter responds to each request with the available markets for that event. Example: For Event A, the adapter returns "1x2" and "Spread" markets. For Event B, only "1x2" is available. For Event C, no data is returned (e.g., event expired). The widget displays placeholders while it loads detailed data.

Data Retrieval Phase: The widget now requests all the data it needs in parallel. It calls the market endpoint for odds and outcomes, the event endpoint for event details (like team names and scores), and the betSlipSelection endpoint to check the user's current selections. Example: For Event A, the widget requests both "1x2" and "Spread" markets. For Event B, it requests "1x2". It also fetches event details for both events and checks the user's bet slip selections.

When the widget receives data from the event endpoint, it fills in the placeholders with event information. Example: Team names, scores, match period, and start time are displayed.

When the widget receives data from the market endpoint, it fills in the odds and outcomes for each market. Example: The widget displays the latest odds for each outcome.

When the widget receives data from the betSlipSelection endpoint, it updates the UI to reflect the user's current selections. Example: If the user has already selected outcome 1 for the "1x2" market in Event A, the widget marks it as selected.

Once all endpoint requests have returned data (or timed out), the widget displays the complete information to the user.

The sequence above is a general example. Each widget has its own unique data pattern, which is detailed in its specific documentation.

Base Implementation Example

Start with this basic HTML structure to implement your self-service adapter.

Adapter Implementation

The adapter is a JavaScript object that serves as the interface between your application's data layer and the SIR Widgets. It defines how widgets request data and how your application provides it.

Implementing the Adapter Endpoints

Now implement the complete adapter with all core endpoints. Here's the full adapter implementation with mock data:

Example: Mocked Data Adapter

Here's the complete HTML file with all pieces assembled:

Code Block

Connect to Your API

To connect to your actual betting API, you need to replace the mock data with actual network requests. This typically involves fetching data from your backend and transforming it to match the structure expected by the widget.

Adding Real-Time Updates

For live events, it is crucial to keep odds and market status up to date. You can achieve this using polling or WebSockets. Here is an example using polling:

Further Reading

Widget-Specific Tutorials

Once you've completed this general integration tutorial, refer to widget-specific guides for detailed implementation patterns:

  • Bet Insights Widget – Coming soon

  • Bet Recommendation Widgets – Coming soon

  • Swipe Bet Widget – Coming soon

Last updated

Was this helpful?