Real-time results: the SSE stream, event by event
How to receive every round the moment it is stored: the /stream events, reconnecting with Last-Event-ID, and why SSE instead of a webhook or WebSocket.
Published on October 30, 2026 · updated on November 14, 2026 · 11 min read
Every live results API answers the same question — "what was the last round?" — in one of two ways. Either you ask periodically, or the API tells you. LynxMetrics' GET /v1/{api}/stream is the second way: an HTTP connection that stays open and delivers every round the moment it is stored, with no polling interval in between.
This article is the stream's reference, identical for every API in the catalogue. Each game's article shows the same mechanism with that table's numbers: Bac Bo Live, Lightning Baccarat and Baccarat 1.
Why SSE, and not a webhook or WebSocket
| Stream (SSE) | Polling /latest | Webhook | WebSocket | |
|---|---|---|---|---|
| Delay beyond the API's own | none | half your interval, on average | none | none |
| Per-minute limit spent | 1 on open | 1 per request | — | — |
| Needs a public address | no | no | yes | no |
| Goes through proxies and CDNs | yes, it is plain HTTP | yes | yes | sometimes not |
| Exists at LynxMetrics | yes | yes | no | no |
Webhooks do not exist, and that is not an oversight. They would require you to publish an address on the internet, and on our side a table of destinations, request signing and a retry queue — parts that can fail on their own. For anyone who already has a process running, the stream delivers the same thing with fewer parts and without exposing anything.
WebSocket was ruled out because it brings a return channel we do not use: you never need to send us anything after opening the connection. SSE is plain HTTP, with one header and a response that does not end, so it goes where WebSocket sometimes stumbles and works in any client that can read a response incrementally.
No open connection: ?wait= on /latest
If your environment cannot keep a connection open (a script that runs and exits, a serverless function, a simple PHP loop), there has been a middle ground since November 14, 2026: request /latest with ?wait=20 and say which round you already have. The response stays open until the next round closes and arrives with it, at the same moment the stream would deliver it. If nothing closes within 20 seconds, you get a 304 and ask again.
curl "https://api.lynxmetrics.com/v1/bacbo-live/latest?wait=20" \ -H "x-api-key: YOUR_KEY" \ -H 'if-none-match: "ETAG_OF_THE_LAST_RESPONSE"'
If you do not keep the ETag, send &after= with the id of the last round you have. It is one request per round instead of one every few seconds, and your client timeout must be longer than wait. Ready-made code in Python, Node.js and PHP, for both the stream and this wait, is in each API's documentation.
Opening the connection
curl -N https://api.lynxmetrics.com/v1/bacbo-live/stream \ -H "x-api-key: YOUR_KEY" \ -H "accept: text/event-stream"
The -N turns off curl's buffering, otherwise the terminal would only show everything at the end. Swap bacbo-live for the slug of the API you subscribed to — a key opens a single API.
The events
The default flow has three events — ready, round and closed — plus a fourth, phase, which only arrives if you ask for it with ?phases=1.
On the wire, each event is a name, sometimes an id, and one data: line with compact JSON:
event: phase
data: {"roundId":"v1793371825421","game":"bacbo-live","phase":"resolving","at":"2026-10-30T18:10:49.903Z","sentAt":"2026-10-30T18:10:53.903Z"}
event: round
id: v1793371825421
data: {"data":{"id":"v1793371825421","outcome":"banker","settledAt":"2026-10-30T18:10:58.903Z","...":"..."},"timing":{"receivedAt":"2026-10-30T18:11:02.803Z","sentAt":"2026-10-30T18:11:02.853Z"}}| Event | When it arrives | What to do with it |
|---|---|---|
ready | Once, on open | Carries the last settled round in data, so you start in sync, and on a reconnect also what you missed. Not a new round |
phase | Optional (?phases=1), when the table starts resolving the round | Carries the roundId the round will have, seconds before the result |
round | One per new round | The round in data and the delivery timestamps in timing. The only event with an id: |
closed | Another connection opened with the same key | End of life for this process: reconnecting would drop the new connection |
On top of that, every 20 silent seconds a line starting with a colon goes out. It is the heartbeat that stops a proxy in the middle from closing an idle connection; it is not an event and can be ignored.
What phase is, and what it is not
phase exists because our source is the table itself, and the reader knows the moment it starts resolving the round — the close-up of the dice in the shaker, the cards on the felt. At that instant bets have closed, the result does not exist yet, and the round's id is already defined. In Bac Bo that heads-up arrives about 8 seconds before the result.
It is optional on purpose: open the connection with ?phases=1 to receive it. And let us be blunt about what it does not solve: to know which round a result belongs to, you do not need phase. The round's id, the guaranteed order within the connection and last-event-id already answer that with no ambiguity. The phase only moves that binding a few seconds earlier — useful if you record something before the result, and dead weight if you just want the right result.
What it is not: a promise of a result. A cut close-up, a gap in the feed or an unsafe read means the round is discarded on purpose — better missing than guessed — and then no round arrives with that roundId. If you keep state per phase, you need to expire a phase that never became a round.
A detail that saves you 35 seconds of waiting: if you asked for phases and open the connection in the middle of a round being resolved, the open phase arrives right after ready, instead of you waiting for the next one.
The timestamps, to measure the delay instead of estimating it
The round carries four timestamps, from two different clocks:
| Field | Clock | What it marks |
|---|---|---|
data.startedAt | table | Start of the round, when betting opened |
data.settledAt | table | End of the round: the result was settled at the source |
timing.receivedAt | our API | The result became ready on our side |
timing.sentAt | our API | This event was written to your connection |
With them, each leg of the trip is measured separately, and you can tell whose delay it is:
receivedAt − settledAtis table to us: the part that is in our hands. Today it sits around 4 seconds.sentAt − receivedAtis this connection's queue, usually a few milliseconds.- Whatever is left until your code runs is your network.
from datetime import datetime
def delays(event):
t = lambda iso: datetime.fromisoformat(iso.replace("Z", "+00:00"))
round_, timing = event["data"], event["timing"]
return {
"table_to_us": (t(timing["receivedAt"]) - t(round_["settledAt"])).total_seconds(),
"queue": (t(timing["sentAt"]) - t(timing["receivedAt"])).total_seconds(),
"to_you": (datetime.now(tz=t(timing["sentAt"]).tzinfo) - t(timing["sentAt"])).total_seconds(),
}timing sits outside data on purpose: that way the round object stays identical, byte for byte, to what /latest and /results return, and the same code handles a round that came from the stream and one that came from history.
Reconnecting without losing a round
Open connections drop: network, deploys, restarts, and the 6-hour lifetime every connection has. What solves that is Last-Event-ID, the standard SSE mechanism: you say which round you received last, and the API returns what closed while you were away.
curl -N https://api.lynxmetrics.com/v1/bacbo-live/stream \ -H "x-api-key: YOUR_KEY" \ -H "accept: text/event-stream" \ -H "last-event-id: v1793371825421"
ready then comes back like this:
{
"data": { "id": "v1793372118404", "outcome": "player", "...": "..." },
"missed": [
{ "id": "v1793371962117", "...": "..." },
{ "id": "v1793372118404", "...": "..." }
]
}missedcarries the rounds that closed while you were away, oldest first, up to 50.datais still the last settled round, which is usually the last item inmissed— so handle everything byidto avoid counting twice.- Because the
id:only goes on theroundevent, the cursor you store is always a round that really exists. That is whyphasehas noid:: it would point to a round that might never exist.
In the browser, EventSource sends Last-Event-ID by itself when reconnecting — but it cannot send headers, so the key cannot travel there and the stream belongs on the server. Outside the browser, you send the header or ?last_event_id=.
When recovery is not possible
The connection opens either way — a reconnect cannot fail because of a stale cursor. missed comes back null and a resyncError appears explaining why (it only exists when something went wrong):
resyncError | What happened | What to do |
|---|---|---|
bad_cursor | The value is neither a round id nor an ISO 8601 date | Fix what you are storing |
unknown_round | The id belongs to no round in this API | It may be another API's id, or a round discarded after a phase |
plan_limit | The round is older than your plan's history | Carry on from what the plan covers |
too_many_missed | More than 50 rounds closed while you were away | Paginate /results?after= until you are in sync |
In other words: the stream handles a short absence by itself, and a long absence is still /results' job, which paginates. Both ceilings — the 50 rounds of recovery and the one on a slow connection's queue — exist for the same reason: not holding rounds indefinitely for a client that is no longer there.
A client that survives a full day
Putting it together: reading the events, storing the cursor, reconnecting and never repeating a round.
stream.py
import json
import time
import httpx
API = "bacbo-live"
URL = "https://api.lynxmetrics.com/v1/" + API + "/stream?phases=1" # without ?phases=1 there is no event: phase
KEY = "YOUR_KEY"
last_id = None # cursor: the last round we handled
def handle(round_):
global last_id
if round_["id"] == last_id:
return # ready repeats the last one on purpose
last_id = round_["id"]
print(round_["settledAt"], round_["outcome"])
def follow():
headers = {"x-api-key": KEY, "accept": "text/event-stream"}
if last_id:
headers["last-event-id"] = last_id
with httpx.stream("GET", URL, headers=headers, timeout=None) as response:
response.raise_for_status()
event = None
for line in response.iter_lines():
if line.startswith("event:"):
event = line.split(":", 1)[1].strip()
elif line.startswith("data:"):
body = json.loads(line.split(":", 1)[1])
if event == "ready":
if body.get("resyncError"):
print("no recovery:", body["resyncError"]) # handle too_many_missed with /results
for round_ in body.get("missed") or []:
handle(round_)
if body["data"]:
handle(body["data"])
elif event == "round":
handle(body["data"])
elif event == "phase":
print("resolving", body["roundId"])
elif event == "closed":
return "closed"
while True:
if follow() == "closed":
print("another connection took this key's slot")
break
time.sleep(2)Three details in that code that are not decoration:
- The cursor comes from the round's
id, not from a counter of your own. It is fixed and never changes. handleis idempotent.readyrepeats the last round on purpose, and a client that does not check the id publishes the same round twice on every reconnect.closedstops the loop. Reconnecting after acloseddrops the connection that took your place, and the two copies keep evicting each other forever.
Limits and caveats
- Connections per key: 1 on the Pro plan and 3 on Business. Going over does not raise an error: the oldest connection for that key is closed with
closedand the new one takes its place — that way a process that died without warning never locks you out of your own slot. - A 6-hour lifetime, even on a healthy connection. Anyone running all day reconnects about four times a day, and with
Last-Event-IDthat is invisible in the end result. - A read timeout above 20 seconds in your client, otherwise it cuts the connection during the silence between rounds. In Python,
timeout=None. - Cost: opening the connection spends 1 request from your per-minute limit; the rounds that arrive afterwards spend nothing. Following the stream weighs far less than polling
/latestevery 3 seconds. - The key stays on the server. In the browser it would be visible to any visitor — see API security.
Where to see this working
Each API's documentation lists the events, the fields and your plan's limits, and each game has its own article with the table's numbers: Bac Bo Live, Lightning Baccarat and Baccarat 1. To build something on top of it, the Telegram bot is the shortest path from the stream to a message in a group.
Frequently asked questions
- What is the LynxMetrics /stream endpoint?
It is an HTTP connection that stays open (Server-Sent Events) and delivers every round the moment it is stored, instead of you polling the API. Opening the connection spends one request from your per-minute limit, and the rounds that arrive afterwards spend nothing.
- Does LynxMetrics have webhooks?
No. A webhook would require a public address of yours and, on our side, request signing and a retry queue. The /stream endpoint covers the same case with fewer parts and without exposing anything, so it is the recommended way to receive rounds in real time.
- How do I reconnect to the stream without losing rounds?
Send the id of the last round you received in the last-event-id header. The ready event comes back with missed, the rounds that closed while you were away, oldest first, up to 50. Beyond that you get resyncError too_many_missed and you paginate /results?after= to catch up.
- What is the phase event and how do I receive it?
It is the heads-up that the table started resolving a round, when bets have closed and the result does not exist yet, and it is optional: it only arrives if you open the connection with ?phases=1. It carries the roundId the round will have, in Bac Bo about 8 seconds before the result. To know which round a result belongs to you do not need it: the round's id, the guaranteed order and last-event-id are enough.
- What are the timing fields for?
To measure the delay instead of estimating it. settledAt is the end of the round on the table's clock, receivedAt is when the result became ready on our side and sentAt is when the event was written to your connection. The difference between receivedAt and settledAt is the leg that is in our hands, today around 4 seconds.
- Why is the stream connection closed every 6 hours?
By design: connections that die without warning exist, and that deadline stops one from holding a slot forever. With Last-Event-ID a reconnect costs no rounds, so anyone running all day reconnects about four times a day without losing anything.
Read also
- What an API is and how to connect to one for the first time
APIs explained without the jargon: what they are, how REST, JSON and keys work, and how to make your first call in the browser, the terminal, Python and JavaScript.
- Where to host a bot 24/7: bot hosts, a VPS or serverless
What a bot that runs non-stop actually needs, what each hosting option costs, and why serverless does not go with an open connection.
- API errors and limits: 429, backoff and what to do
A practical guide to a data API's errors: what each HTTP status means, how to handle 429 with Retry-After and backoff, and the code that keeps your bot alive.