Skip to content

How to integrate a live sports data feed

Guide6 min read

Opening the connection is the easy part. The work is in what your code does when a message arrives twice, an event is corrected or the socket drops mid-match. Here's the order we'd build an integration in.

Field names and connection details below are examples. The exact schema comes with your sample feed.

Start with reference data over REST

Before you open a socket, pull what the live feed will refer to: sports, competitions, fixtures, teams and players, each with a stable id. Live messages carry ids, not names. Your system needs the records behind those ids before the first message arrives.

Store the reference data on your side and refresh it as often as it changes: fixtures and line-ups move during the week, competition and team ids rarely do. When a live message names an id you don't have yet, fetch that record instead of dropping the message.

One rule we'd hold to: REST is for reference data and results, the socket is for live events. Polling the REST API for live scores leaves you behind the feed and adds load on both sides.

Connect, authenticate, subscribe

Open the WebSocket from your backend, not from your users' browsers or apps. Anything shipped to a device can be read, credentials included. One server-side connection that fans out to your own services is easier to secure and far easier to debug.

Authenticate when the connection opens, then subscribe. Your credentials cover the sports, competitions and territories in your contract and nothing else, so a subscription outside them is refused. Log that refusal as a configuration error. Retrying it won't help.

Subscribe by fixture id. A scores section in an OTT app may want every licensed match; a broadcaster's graphics only need the matches it shows. Start narrow and your early logs stay readable.

Use the protocol's ping frames to detect a dead connection. A socket can sit open and silent after the network behind it has gone, and you want to know before a goal goes missing.

Handle the five message types

Each message carries a type, a fixture id, a sequence number and a payload that depends on the type.

  • Fixture: the match was created or changed, such as a new start time or a confirmed line-up. Update your listings.
  • Score: the current score, for the match and for the current period. Write it straight to your display.
  • Event: something happened in play, such as a goal, a card, a point, a kill or a round won. Events drive your timeline, notifications and overlays.
  • Period: a period started or ended. Halves, quarters, sets, maps and rounds all come through here.
  • Status: the state of the match itself, from scheduled and live to interrupted, delayed, finished, postponed or canceled. Wire these to whatever shows the match as live on your side.

An event message, field by field

An illustrative goal in a football match might carry these fields:

  • type: event
  • fixture id: the match the event belongs to
  • sequence: this message's position in your stream
  • event id: the event's own id, which a later correction will point to
  • event: goal, with the team, the scorer's player id and the match minute
  • timestamp: when the event was logged

Events can change after you've processed them. A goal is ruled out on review, a card goes to a different player, a kill is credited to someone else. The correction refers to the original event id. Look the event up by that id and update or remove it. If you append the correction as a new event, your timeline shows a goal that never stood.

Sequence numbers and reconnects

Store the last sequence number you processed, and store it after the message is applied, not when it arrives. If your process crashes between the two, you'd rather see a message twice than miss it.

So make processing idempotent: a message whose sequence number you've already applied gets skipped. Duplicates are normal after a reconnect. A duplicate goal on a scoreboard costs far more than a skipped line in a log.

When the connection drops:

  1. Reconnect with a delay that grows after each failed attempt, so a brief outage on either side doesn't turn into a flood of connection requests.
  2. Authenticate and send the last sequence number you applied.
  3. Process the resent messages in order, before anything new.
  4. If you can't trust your stored state, pull the fixture's current score and status from the REST API and carry on from there.

Watch for gaps while connected too. If the sequence jumps, something went missing between the feed and your code. Log it and recover the same way.

Test against the sample feed

A sample feed gives you real messages from live matches before anything depends on your code. Use it to break the integration on purpose.

  • Follow a full match and compare your final state with the official result.
  • Kill your connection mid-match, reconnect, and check that nothing was lost or applied twice.
  • Find a match with a correction in it, such as a goal ruled out, and trace it through your system.
  • Cover the awkward statuses: a delayed start, an interruption, a postponement.
  • For esports, include a long series with technical pauses and a map change.

Run the stream next to the data for at least one match as well, and check that both line up on the same fixture id.

Go-live checklist

  • Credentials live on your servers only, never in a client app.
  • The last applied sequence number is persisted, and duplicates are skipped.
  • Reconnects have been tested by dropping the connection during a live match.
  • Corrections update the original event instead of adding a new one.
  • Status changes, such as a delay or an interruption, update your listings and player.
  • Alerts fire on a silent connection and on sequence gaps.
  • You know who to call on the supplier's operations team during a match.

On this topic

Whichever your stack parses best. Both carry the same messages and ids, so the choice doesn't change what you receive.

Yes. They share fixture ids, so the video and the events of one match line up in your player and your data layer without a mapping table.

It comes with your sample feed, together with the documentation on ids, reconnection and error handling. Ask for one through the contact page and name the sport you want to start with.
Next step

Go live

Tell us your sports, platforms and markets. We reply with a sample feed and a plan for going live.