For the complete documentation index, see llms.txt. This page is also available as Markdown.

Getting started

This guide explains how to establish and maintain a WebSocket connection to the Soccer Football API real-time service.

Connection URL

There is two connection urls:

wss://ws-eu.soccerfootball.info/?token=YOUR_WEBSOCKET_TOKEN

wss://ws-as.soccerfootball.info/?token=YOUR_WEBSOCKET_TOKEN

You must use the connection URL in response of /v1/ws/new call.

Connection flow

  1. GET /v1/ws/new → Obtain WebSocket token

  2. Connect to WSS → Establish WebSocket connection

  3. Subscribe to channels → Start receiving events

  4. Handle events → Process incoming messages

  5. Renew token → Before expiration (every ~25 minutes)


Step-by-step guide

Step 1 — Obtain a WebSocket token

Call the /v1/ws/new endpoint to generate a new WebSocket token.

The response contains everything you need to connect:

Save the token and use the server URL to connect. Note the expires_at timestamp — you will need to renew the token before this time.

Step 2 — Connect to WebSocket

Use the server URL from the previous response to establish a WebSocket connection:

Step 3 — Subscribe to a channel

Once connected, subscribe to the channels you need. For example, to receive all match events on the MAIN channel:

You can also subscribe to a specific match or league:

The server confirms each subscription:

Step 4 — Handle events

Process incoming messages based on their type:

Step 5 — Renew token before expiration

WebSocket tokens expire after approximately 25 minutes. You must call the /v1/ws/renew endpoint before the token expires to keep your connection alive.

Best practice: set a timer to renew 5 minutes before the expires_at timestamp.


Complete example

A full working example combining all steps: obtain token, connect, subscribe, handle events, keep-alive ping, and token renewal.


MAIN_REALTIME channel (MEGA plan 🟩 only)

If you subscribe to the MAIN_REALTIME channel, the messages contain IDs that are specific to the realtime data source and differ from the standard REST API IDs. To map these realtime IDs to the corresponding REST IDs, use the following endpoints:

All other channels (MAIN, STATS, ODDS, STATS_REALTIME, ODDS_REALTIME) already use REST IDs — no mapping is needed.

Last updated