Documentation Index
Fetch the complete documentation index at: https://4cx.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Streaming API (Socket.IO)
Documentation only. Real-time feeds use Socket.IO over WebSockets, not the HTTP requests underhttps://api.4cx.io in the rest of this documentation.
Relationship to the REST API
- Use Log in to obtain a session token for REST.
- Published streaming docs use
wss://api.4cx.io/wssproduction. Confirm with your team whether your 4cx product reuses this host and token, or different endpoints.
Recommended Socket.IO clients
- JavaScript: socket.io-client
- Java: socket.io-client-java
- C++: socket.io-client-cpp
Server
Authentication
A valid REST token (from/user/login, see Authentication) is required. Pass it in the subscription query object as described below.
Public mode
Node.js clients should sendextraHeaders: { 'X-API-Version': 'public' } on the handshake. Browser clients should pass query: { apiVersion: 'public' } so payloads use sweepstakes field names (risk, take, requestID) instead of legacy names.
Subscriptions (channels)
SUB /
Root channel subscription. Query object:
token(string, required) — auth token from the REST API.
SUB /priceUpdates
Price feed. After subscribing, you receive messages of type Order Update or Game Update (see Incoming messages).
SUB /v2/user/{username}
- Path:
username= your 4Cx username (not email). - Messages: Position Update when your orders are placed, matched, or cancelled.
Incoming messages
1. Order Update
Emitted when a price changes in a single market (e.g. a new order on a line). Note: a future V2 may simplify updates to only the relevant order. Payload fields include:gameID, type (moneyline | spread | total | moneyline1x2), sideOrders (array), optional spread, total, side, market, and other properties.
Example:
2. Game Update
Emitted when a game is created, betting opens or closes, or the start time changes. Payload includes:id, parentGameID, league, sport, start, ended, participants, awayMoneylines, homeMoneylines, awaySpreads, homeSpreads, over, under, mainHomeSpread, mainAwaySpread, mainTotal, messageType (marketOpen | marketClosed), and other fields.
A full generated JSON example is too large to duplicate here—ask your integration contact for a complete sample.
3. Position Update
Emitted when one of your orders is cancelled, matched, or placed.matched: present when matched; includestxID(use REST matched-play lookup with the sametxID),filled,odds(always in your odds; if you offered another user -105 you may see +105).unmatched:filled(amount filled in this event, not cumulative across partials),offered,remaining,orderID(REST order lookup),odds. Whenremainingis 0 the order is fully matched; whenofferedis 0 the order was cancelled.- Also:
gameID,eventName,parentGameID,league,sport,origin(offer|wager).
