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.
RapidAPI clients connecting from Asia: MAIN_REALTIME is not available on the Asian node
The MAIN_REALTIME channel is currently served only from the European node (wss://ws-eu.soccerfootball.info).
If you are a RapidAPI customer connecting from Asia, the /v1/ws/new response will route you to the Asian node and the server URL will point to wss://ws-as.soccerfootball.info. On that node the MAIN_REALTIME channel will * not* be available.
If you need MAIN_REALTIME in this situation, please email [email protected]. We will set up a parallel, working token for you so you can connect to the European node and use the channel without issues.
Connection flow
GET /v1/ws/new → Obtain WebSocket token
Connect to WSS → Establish WebSocket connection
Subscribe to channels → Start receiving events
Handle events → Process incoming messages
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.
Last updated