Live updates
Connecting
Use this page to open a WebSocket connection and authorise a private channel. The server speaks the Pusher protocol through Laravel Reverb, so any Pusher client works.
1. Check your key can connect
Live updates need a key with the stream:read ability. Business includes it, and Main lines, Full depth and Player props get it with the WebSocket add-on. Every plan with the WebSocket can follow all live games, and stream:firehose is the ability for the channels that carry every live match at once. See Plans and access.
Each account can hold a set number of connections at once: 1 on Main lines and Full depth, 2 on Player props and 5 on Business. Opening one more closes the account's oldest connection with the error code 4004, so a client that reconnects after losing its network is never locked out by its own old connection.
2. Connect
Create a Pusher client with your WebSocket host and app key, and point its channel authorisation at https://odds-feed.on-forge.com/broadcasting/auth with your API key as the bearer token. The WebSocket host and app key shown are the ones for this server, and the bearer token is your own key.
import Pusher from 'pusher-js';
const pusher = new Pusher('75f6d3a4cc8f73610c0c351d9199cf5a', {
cluster: 'mt1',
wsHost: '127.0.0.1',
wsPort: 443,
wssPort: 443,
forceTLS: true,
enabledTransports: ['ws', 'wss'],
channelAuthorization: {
endpoint: 'https://odds-feed.on-forge.com/broadcasting/auth',
headers: { Authorization: 'Bearer YOUR_KEY' },
},
});3. See how a channel is authorised
Before a client joins a private channel it sends the channel name to the authorisation endpoint. A key that may read the channel gets an auth signature back, and any other key gets 403. You do not make this request yourself, but you can see it. Then subscribe to a channel from Channels.
curl -X POST "https://odds-feed.on-forge.com/broadcasting/auth" \
-H "Authorization: Bearer YOUR_KEY" \
-d "socket_id=1234.5678" \
-d "channel_name=private-match.0199c5a0-7b1e-7c3a-9f4e-2d6b8a1c4e70.odds"{
"auth": "docs-key:3f1c0b9d5e0c4a7e2b8e9a1d6c4f5b7a8e9d0c1b2a3f4e5d6c7b8a9f0e1d2c3b"
}Reference
| Setting | Value |
|---|---|
| Protocol | Pusher, over a secure WebSocket |
| Authorisation endpoint | https://odds-feed.on-forge.com/broadcasting/auth |
| Authorisation header | Authorization: Bearer YOUR_KEY |
| Cluster | mt1, which the client needs but the server ignores |
| Connections at once | 1 on Main lines and Full depth, 2 on Player props, 5 on Business |
Error 4004 |
Closed because the account opened a newer connection over its limit |
Error 4009 |
Closed because the plan no longer includes the WebSocket |