Documentation · Immersive Roulette
Immersive Roulette API
Spins from Evolution's Immersive Roulette table: the number, color, odd or even, low or high, dozen and column of every spin. This page shows how the Immersive Roulette API responds, with every field explained.
https://api.lynxmetrics.com/v1/immersive-roulette
Authentication
Send a key created in the dashboard for Immersive Roulette in the x-api-key header, since a key from another API gets key_wrong_api.
curl https://api.lynxmetrics.com/v1/immersive-roulette/latest \ -H "x-api-key: YOUR_KEY"
Keys, the trial and subscriptions (you can subscribe to the same API several times, each with its own keys) work the same on every API and are explained in the general documentation.
Code examples
Ready-to-copy examples in Python, Node.js and PHP. Replace YOUR_KEY with the key from your dashboard and run it: each one calls the on_round function (onRound in Node.js) on every new Immersive Roulette round, and that is where your code goes.
Real time over the stream (recommended)
One open connection that receives every round the moment it closes. Only opening the connection costs a request, so you never hit the per-minute limit, and it is the fastest way to get the data. The example reconnects on its own, sends last-event-id to receive in missed whatever closed while it was away, and stops when closed arrives.
import json
import time
import requests
API = "https://api.lynxmetrics.com/v1/immersive-roulette"
KEY = "YOUR_KEY"
def on_round(r):
print(r["id"], r["outcome"], r["data"])
def listen():
last_id = None
while True:
headers = {"x-api-key": KEY, "accept": "text/event-stream"}
if last_id:
headers["last-event-id"] = last_id
try:
with requests.get(API + "/stream", headers=headers, stream=True, timeout=(10, 60)) as res:
if res.status_code != 200:
print("HTTP", res.status_code, res.text)
time.sleep(int(res.headers.get("retry-after", 10)))
continue
res.encoding = "utf-8"
event, data = None, []
for line in res.iter_lines(chunk_size=1, decode_unicode=True):
if line.startswith("event:"):
event = line[6:].strip()
elif line.startswith("data:"):
data.append(line[5:].strip())
elif line == "":
if event and data:
body = json.loads("\n".join(data))
if event == "ready":
for r in body.get("missed") or []:
on_round(r)
if body.get("data"):
last_id = body["data"]["id"]
elif event == "round":
on_round(body["data"])
last_id = body["data"]["id"]
elif event == "closed":
return
event, data = None, []
except requests.RequestException as error:
print("reconnecting:", error)
time.sleep(3)
listen()const API = "https://api.lynxmetrics.com/v1/immersive-roulette";
const KEY = "YOUR_KEY";
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
function onRound(r) {
console.log(r.id, r.outcome, r.data);
}
async function listen() {
let lastId = null;
for (;;) {
try {
const headers = { "x-api-key": KEY, accept: "text/event-stream" };
if (lastId) headers["last-event-id"] = lastId;
const res = await fetch(API + "/stream", { headers });
if (!res.ok) {
console.error("HTTP", res.status, await res.text());
await sleep(Number(res.headers.get("retry-after") ?? 10) * 1000);
continue;
}
const decoder = new TextDecoder();
let buffer = "";
for await (const chunk of res.body) {
buffer += decoder.decode(chunk, { stream: true });
let end;
while ((end = buffer.indexOf("\n\n")) >= 0) {
const block = buffer.slice(0, end);
buffer = buffer.slice(end + 2);
const event = /^event: (.+)$/m.exec(block)?.[1];
const data = block
.split("\n")
.filter((line) => line.startsWith("data:"))
.map((line) => line.slice(5).trim())
.join("\n");
if (!event || !data) continue;
const body = JSON.parse(data);
if (event === "ready") {
for (const r of body.missed ?? []) onRound(r);
if (body.data) lastId = body.data.id;
} else if (event === "round") {
onRound(body.data);
lastId = body.data.id;
} else if (event === "closed") {
return;
}
}
}
} catch (error) {
console.error("reconnecting:", error.message);
}
await sleep(3000);
}
}
listen();<?php
$api = "https://api.lynxmetrics.com/v1/immersive-roulette";
$key = "YOUR_KEY";
function on_round(array $r): void
{
echo $r["id"], " ", $r["outcome"], " ", json_encode($r["data"]), PHP_EOL;
}
$lastId = null;
while (true) {
$headers = ["x-api-key: $key", "accept: text/event-stream"];
if ($lastId) $headers[] = "last-event-id: $lastId";
$buffer = "";
$closed = false;
$ch = curl_init("$api/stream");
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => $headers,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_WRITEFUNCTION => function ($ch, $chunk) use (&$buffer, &$lastId, &$closed) {
$buffer .= $chunk;
while (($end = strpos($buffer, "\n\n")) !== false) {
$block = substr($buffer, 0, $end);
$buffer = substr($buffer, $end + 2);
if (!preg_match('/^event: (.+)$/m', $block, $event)) continue;
preg_match_all('/^data: ?(.*)$/m', $block, $data);
$body = json_decode(implode("\n", $data[1]), true);
if (!is_array($body)) continue;
if ($event[1] === "ready") {
foreach ($body["missed"] ?? [] as $r) on_round($r);
if (!empty($body["data"])) $lastId = $body["data"]["id"];
} elseif ($event[1] === "round") {
on_round($body["data"]);
$lastId = $body["data"]["id"];
} elseif ($event[1] === "closed") {
$closed = true;
return 0;
}
}
return strlen($chunk);
},
]);
curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($closed) break;
if ($status !== 200) fwrite(STDERR, "HTTP $status" . PHP_EOL);
sleep($status === 200 ? 3 : 10);
}Latest with wait (no open connection)
For those who prefer to ask instead of keeping a connection open. ?wait=20 holds the response until the next Immersive Roulette round closes, for at most 20 seconds, so the round arrives the moment it closes and the example makes a few requests per minute instead of asking all the time. It sends the ETag of the last response in if-none-match: while nothing changes, the wait ends in a bodiless 304, and on a 429 it waits for the time in the retry-after header instead of insisting.
import time
import requests
API = "https://api.lynxmetrics.com/v1/immersive-roulette"
session = requests.Session()
session.headers["x-api-key"] = "YOUR_KEY"
def on_round(r):
print(r["id"], r["outcome"], r["data"])
etag = None
last_id = None
while True:
try:
res = session.get(
API + "/latest",
params={"wait": 20},
headers={"if-none-match": etag} if etag else {},
timeout=30,
)
except requests.RequestException as error:
print("retrying:", error)
time.sleep(5)
continue
if res.status_code == 200:
etag = res.headers.get("etag")
r = res.json()["data"]
if r and r["id"] != last_id:
if last_id:
on_round(r)
last_id = r["id"]
elif res.status_code == 429:
time.sleep(int(res.headers.get("retry-after", 5)))
continue
elif res.status_code != 304:
print("HTTP", res.status_code, res.text)
time.sleep(10)
continue
time.sleep(2)const API = "https://api.lynxmetrics.com/v1/immersive-roulette";
const KEY = "YOUR_KEY";
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
function onRound(r) {
console.log(r.id, r.outcome, r.data);
}
async function poll() {
let etag = null;
let lastId = null;
for (;;) {
let res;
try {
const headers = { "x-api-key": KEY };
if (etag) headers["if-none-match"] = etag;
res = await fetch(API + "/latest?wait=20", { headers, signal: AbortSignal.timeout(30_000) });
} catch (error) {
console.error("retrying:", error.message);
await sleep(5000);
continue;
}
if (res.status === 200) {
etag = res.headers.get("etag");
const { data } = await res.json();
if (data && data.id !== lastId) {
if (lastId) onRound(data);
lastId = data.id;
}
} else if (res.status === 429) {
await sleep(Number(res.headers.get("retry-after") ?? 5) * 1000);
continue;
} else if (res.status !== 304) {
console.error("HTTP", res.status, await res.text());
await sleep(10_000);
continue;
}
await sleep(2000);
}
}
poll();<?php
$api = "https://api.lynxmetrics.com/v1/immersive-roulette";
$key = "YOUR_KEY";
function on_round(array $r): void
{
echo $r["id"], " ", $r["outcome"], " ", json_encode($r["data"]), PHP_EOL;
}
$etag = null;
$lastId = null;
while (true) {
$headers = ["x-api-key: $key"];
if ($etag) $headers[] = "if-none-match: $etag";
$received = [];
$ch = curl_init("$api/latest?wait=20");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_TIMEOUT => 30,
CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$received) {
$parts = explode(":", $line, 2);
if (count($parts) === 2) $received[strtolower(trim($parts[0]))] = trim($parts[1]);
return strlen($line);
},
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status === 200) {
$etag = $received["etag"] ?? null;
$round = json_decode($body, true)["data"] ?? null;
if ($round && $round["id"] !== $lastId) {
if ($lastId) on_round($round);
$lastId = $round["id"];
}
} elseif ($status === 429) {
sleep((int) ($received["retry-after"] ?? 5));
continue;
} elseif ($status !== 304) {
fwrite(STDERR, "HTTP $status $body" . PHP_EOL);
sleep(10);
continue;
}
sleep(2);
}Send every round to Telegram
Replace the on_round function of any example above with this one, using your bot token (the one @BotFather gives you) and the id of the chat or channel. outcome and everything inside data are explained further down, in Fields of each round.
BOT_TOKEN = "123456:ABC..."
CHAT_ID = "-1001234567890"
def on_round(r):
text = f"{r['outcome'].upper()} · {r['id']}"
requests.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
json={"chat_id": CHAT_ID, "text": text},
timeout=10,
)const BOT_TOKEN = "123456:ABC...";
const CHAT_ID = "-1001234567890";
function onRound(r) {
fetch(`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ chat_id: CHAT_ID, text: `${r.outcome.toUpperCase()} · ${r.id}` }),
signal: AbortSignal.timeout(10_000),
}).catch((error) => console.error("telegram:", error.message));
}$botToken = "123456:ABC...";
$chatId = "-1001234567890";
function on_round(array $r): void
{
global $botToken, $chatId;
$ch = curl_init("https://api.telegram.org/bot$botToken/sendMessage");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_POSTFIELDS => ["chat_id" => $chatId, "text" => strtoupper($r["outcome"]) . " · " . $r["id"]],
]);
curl_exec($ch);
curl_close($ch);
}What breaks bots most often
- Do not poll faster than the table plays. With less than 1 second between requests you only burn your limit and get
429: the new round does not arrive any sooner. If you need the result within the same second, use/stream. - On a
429, read theretry-afterheader and wait that long, because retrying right away does not help. Every response carriesx-ratelimit-remainingandx-ratelimit-reset, which tell you how much still fits in the minute. - A
401on every call means the key is wrong, revoked or was rotated in the dashboard: copy the key again. Many attempts in a row with an invalid key make your IP receive429for a while, even after you fix it. trial_expiredmeans the trial hours are over. Subscribe to a plan in the dashboard and the same key works again, with no code change.- If your bot was down, do not guess what it missed: call
/results?after=with theidof the last round you have and receive, in order, every round that closed after it. - Each key has a number of stream connections, shown in the limits table. Go over it and the oldest connection is ended with
closed. To run several bots, create one key for each in the dashboard.
GET /v1/immersive-roulette/latest
The latest Immersive Roulette round, or null if there is none yet.
waitnumberSeconds the response may wait for the next round, up to 20. It only waits if you already have the latest one: send its
ETaginif-none-matchor itsidinafter. When a round closes, the response comes right away with it; if the time runs out first, you get304(with ETag) or the same round (withafter). It counts as a single request, and your client timeout must be longer thanwait.afteridThe
idof the last round you have. Only used together withwait, for clients that do not keep theETag.
Response
{
"data": {
"id": "e18ead84abb69ba7b2",
"game": "immersive-roulette",
"tableId": "evolution-immersive-roulette",
"startedAt": null,
"settledAt": "2026-11-20T22:38:40.253Z",
"outcome": "red",
"data": {
"number": 5,
"color": "red",
"parity": "odd",
"half": "low",
"dozen": 1,
"column": 2
}
}
}GET /v1/immersive-roulette/results
Immersive Roulette rounds from newest to oldest. To fetch the next page, pass the response's nextCursor as before, and when it comes back null there are no more results.
limitnumberHow many rounds to return, 50 by default and 250 to 1000 at most.
beforeISO 8601Returns only rounds settled before this date, like the
nextCursorof the previous page, and how far back you can go depends on the plan.afterISO 8601 | idTo sync without repeating or skipping rounds, pass the
settledAtor theidof the last round you already have, and the response brings only the rounds settled after it, from oldest to newest, up tolimit. When the page comes back full, pass itsnextCursoras the nextafter, and when it comes backnullyou are up to date. It also follows the plan's history limit and can be combined withbefore.
GET /v1/immersive-roulette/results?limit=1
{
"data": [
{
"id": "e18ead84abb69ba7b2",
"game": "immersive-roulette",
"tableId": "evolution-immersive-roulette",
"startedAt": null,
"settledAt": "2026-11-20T22:38:40.253Z",
"outcome": "red",
"data": {
"number": 5,
"color": "red",
"parity": "odd",
"half": "low",
"dozen": 1,
"column": 2
}
}
],
"nextCursor": "2026-11-20T22:38:40.253Z"
}GET /v1/immersive-roulette/stream
Live Immersive Roulette rounds over a connection that stays open (SSE, Server-Sent Events): every round arrives the moment it is saved, with no polling on your side. It is the fastest path, because it removes the gap between your requests. It is plain HTTP, so it goes through proxies and CDNs and works with any client that can send a header and read continuously.
curl -N https://api.lynxmetrics.com/v1/immersive-roulette/stream \ -H "x-api-key: YOUR_KEY" \ -H "accept: text/event-stream"
Response
event: round
data: {
data: "data": {
data: "id": "e18ead84abb69ba7b2",
data: "game": "immersive-roulette",
data: "tableId": "evolution-immersive-roulette",
data: "startedAt": null,
data: "settledAt": "2026-11-20T22:38:40.253Z",
data: "outcome": "red",
data: "data": {
data: "number": 5,
data: "color": "red",
data: "parity": "odd",
data: "half": "low",
data: "dozen": 1,
data: "column": 2
data: }
data: },
data: "timing": {
data: "receivedAt": "2026-11-20T22:38:44.153Z",
data: "sentAt": "2026-11-20T22:38:44.203Z"
data: }
data: }
What arrives on the connection
readyeventArrives once, as soon as the connection opens, carrying the latest settled round so you start in sync. It is not a new round: compare its
idwith the last one you have and don't count it twice.datacomesnullwhile there is no round yet. On a reconnect it also carries, inmissed, the rounds that settled while you were away.roundeventOne per new round, carrying in
datathe same object/latestreturns, the delivery timestamps intimingand, when the round had a phase, itsref. The eventidis the round id, and onlyroundcarries anid, because it is the resume point on a reconnect.correctionoptionalOptional: it only arrives if you ask for it with
?corrections=1. It tells you that a round already delivered asroundhas changed: in Bac Bo, about once every 2,000 rounds the table re-shakes one cup after the dice had settled, and the die that was published no longer counts. It carriesdata, the round as it now stands (sameidand same timestamps),previous, with theoutcomeanddatathat had been delivered, andsentAt. It has no eventid, solast-event-iddoes not move. It arrives when that round ends on the table, from 30 seconds to 3 minutes after theround. Even if you don't ask for it,/latest,/resultsand/statsstart returning the corrected round.gapeventThis connection's queue overflowed and rounds were dropped: your client wasn't keeping up. It carries
resyncError: too_many_missed, the same code as a reconnect that went long. The connection stays open, and this is the only case where a round is missing mid-stream, always announced, because the ids aren't sequential and you'd have no way to notice. To close the hole, ask/results?after=with the id of the last round you received.closedeventYour connection was ended because a newer one was opened with the same key. It carries
reason: "replaced". This is not a network drop, so do not reconnect automatically: reconnecting here would only kill the newer connection, which would then reconnect and kill yours, with no end to it.: pingcommentEvery 20 seconds without a round, a line starting with a colon goes out. It is not an event and can be ignored; it only stops a proxy in between from closing an idle connection.
Timestamps and delay
Events carry the timestamps of each leg of the trip, so you measure the real delay instead of estimating it. The round's timestamps are on the table's clock; the delivery ones are on our API's clock. The delay for Immersive Roulette is measured against the table and shows up in each event's own timestamps, round by round.
data.startedAtISO 8601Always null in this API: a spin only has the moment the ball stopped, which is settledAt.
data.settledAtISO 8601End of the round on the table's clock: the moment the result was settled at the source. It is also the date used for ordering, for
beforeand forafter.timing.receivedAtISO 8601When the result was ready on our side. The gap between it and
settledAtis the delay from the source to us, which is the part that is in our hands.timing.sentAtISO 8601When this event was written to your connection. The gap between it and
receivedAtis how long the round waited in this connection's queue, usually a few milliseconds; the rest of the delay to your code is network.
Reconnecting without losing a round
When reconnecting, send the id of the last round you received in the last-event-id header: an SSE client that reconnects on its own already sends that header, and if you drive the reconnect yourself you send either the header or ?last_event_id=, whichever suits you. ready comes back with missed: the rounds that settled while you were away, oldest to newest. The stream covers absences of up to 50 rounds; if more than that settled, it does not hand you the most recent ones and does not even try: missed comes null with too_many_missed, and you close the gap with /results?after=. data is still the latest settled round, which is normally the last item of missed. When recovery isn't possible, missed comes null and resyncError says why; the connection opens either way, because a reconnect must never fail over a stale cursor.
curl -N https://api.lynxmetrics.com/v1/immersive-roulette/stream \ -H "x-api-key: YOUR_KEY" \ -H "accept: text/event-stream" \ -H "last-event-id: e18ead84abb69ba7b2"
bad_cursorresyncErrorThe value sent is neither a round id nor an ISO 8601 date.
unknown_roundresyncErrorThat id is not one of our rounds on this API. It may be from another API, or from a round we ended up dropping: a
phaseis no guarantee that the round will exist.plan_limitresyncErrorThe round is older than your plan's history.
too_many_missedresyncErrorMore than 50 rounds settled while you were away, which means you were out too long for the stream to sort it out on its own. Ask
/results?after=with the id you have and page through until you are in sync.
Keeping the connection
- Within a connection, events go out one at a time and in chronological order: a round's phases always before its result (
betting,resolvingandround, carrying the sameref), and eachroundwith asettledAtlater than the previous one. A round'sbettingmay arrive just before the previous round'sround, because one comes from the table and the other from the database; what holds is the order within each round. No round arrives twice on the same connection. If your connection gets slow and its queue overflows, the oldest rounds are dropped and anevent: gapgoes out to tell you. - Each plan allows a number of simultaneous connections per key, shown in the limits table below. Going over it is not an error: the oldest connection on that key is ended with an
event: closedand the new one takes its place. That way a process that died without the system telling us never locks you out of your own slot. - Every connection ends after 6 hours, even a healthy one, and the client is expected to reconnect. That ending carries no event: the connection simply closes, and
closedis only about replacement, so a read that ends for no reason after hours open is this deadline. This is deliberate: connections do die silently, and this deadline is what stops one from holding a slot forever. Something running all day reconnects about four times a day. - If your client has a read timeout, keep it above 20 seconds, or it will cut the connection during the silence between rounds.
- Opening the connection spends one request from your per-minute limit. The rounds that arrive afterwards cost nothing, so following the stream weighs less on the limit than polling
/latest. - The key is only accepted in the
x-api-keyheader, never in the URL, which would end up in proxy logs and browsing history. That is why the browser'sEventSourcewon't do: it cannot send headers. In the browser, the way in is afetchreading the body as it arrives; better still is your own server listening to the stream and passing it on, because a key in the browser would be visible to every visitor.
GET /v1/immersive-roulette/stats
Immersive Roulette statistics computed on the fly over the latest rounds.
samplenumberHow many recent rounds to compute over, 100 by default and 250 to 1000 at most.
GET /v1/immersive-roulette/stats (excerpt)
{
"data": {
"total": 100,
"counts": { "red": 48, "black": 49, "green": 3 },
"percentages": { "red": 48, "black": 49, "green": 3 },
"currentStreak": { "outcome": "black", "length": 2 },
"categories": {
"parity": { "even": 50, "odd": 47 },
"half": { "low": 46, "high": 51 },
"dozen": { "1": 33, "2": 31, "3": 33 }
},
"sample": {
"from": "2026-11-20T21:24:10.000Z",
"to": "2026-11-20T22:38:40.253Z"
}
}
}Round fields
Shape of each Immersive Roulette round in latest and results.
idstringRound id, unique and stable. It is generated by us, not by the provider, so use it only to compare and as a cursor (in after and last-event-id), without parsing its content.
gamestringAPI slug, always "immersive-roulette" here.
tableIdstring | nullTable id at the provider, or null when the source does not provide it.
startedAtstring | nullAlways null in this API: a spin only has the moment the ball stopped, which is settledAt.
settledAtstringRound end in UTC, which is the date used for ordering and for before.
outcome"red" | "black" | "green"The color of the number: red, black or green, which is zero.
data.numbernumberThe number that came up, from 0 to 36.
data.color"red" | "black" | "green"The same color as outcome.
data.parity"even" | "odd" | nulleven or odd, or null on zero.
data.half"low" | "high" | nulllow (1 to 18) or high (19 to 36), or null on zero.
data.dozen1 | 2 | 3 | nullThe dozen: 1 (1 to 12), 2 (13 to 24) or 3 (25 to 36), or null on zero.
data.column1 | 2 | 3 | nullThe table column: 1, 2 or 3, or null on zero.
Statistics fields
totalnumberHow many spins went into the count, equal to sample or fewer if there are still few.
counts{ red, black, green }How many times red, black and zero came up in the sample.
percentages{ red, black, green }The same counts as percentages, with one decimal place.
currentStreak{ outcome, length } | nullThe color repeating right now and for how many spins, or null with no spins.
outcomes{ red, black, green }One block per color: count (how many times it came up), percent, longestStreak (the longest run in the sample) and sinceLast (spins since the last time, 0 for the latest spin and null if it did not come up in the sample). It has the same shape in every API.
categories{ number, parity, half, dozen, column }Counts per group: number (each number that came up), parity, half, dozen and column. A value that did not come up in the sample is left out.
sample{ from, to } | nullSample period: the settledAt of the oldest spin (from) and of the newest (to), or null with no spins.
Plans and limits
Limits of the Immersive Roulette API on each plan. A parameter above the maximum is lowered to the maximum, and a before older than the plan's history returns plan_limit. The per minute column is the requests per minute limit of each subscription, adding up all of its keys, and the connections column is how many /stream connections the same key can keep open at once.
| Plan | Price | Per minute | Connections | limit | sample | before |
|---|---|---|---|---|---|---|
| Trial | 24 hours, no card | 60 | 1 | 250 | 250 | 7 days |
| Pro | ≈ $3.84/month | 60 | 1 | 250 | 250 | 7 days |
| Business | ≈ $8.75/month | 400 | 5 | 1000 | 1000 | full |
Errors have the same format on every API and are listed in the general documentation.