: ping) arrives every 15 s. There are no event ids, so after a reconnect, fill the gap with the matching REST route. At most 2 streams per key.
Events
event
event
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Server-Sent Events: the markets whose positions changed in each finalized batch, and crypto strike updates.
GET https://codex-api.nomos.trade/v1/stream
: ping) arrives every 15 s. There are no event ids, so after a reconnect, fill the gap with the matching REST route. At most 2 streams per key.
retry: 2000
event: markets
data: {"block":94812406,"conditions":["0x8db33416a2d1ebde7438c80129e898f89a5deb3852ca64b37c4bf46513204409"]}
: ping
event: strike
data: {"slug":"btc-updown-15m-1790862300","asset":"btc","timeframe":"15m","start":1790862300,"state":"confirmed","strike":112611.4}
curl -N "https://codex-api.nomos.trade/v1/stream" \
-H "Authorization: Bearer $CODEX_KEY"
import json, os, requests
with requests.get(
"https://codex-api.nomos.trade/v1/stream",
headers={"Authorization": f"Bearer {os.environ['CODEX_KEY']}"},
stream=True,
timeout=(10, 60),
) as r:
r.raise_for_status()
event = None
for line in r.iter_lines(decode_unicode=True):
if line.startswith("event: "):
event = line[7:]
elif line.startswith("data: "):
print(event, json.loads(line[6:]))
// Node 18+
const res = await fetch("https://codex-api.nomos.trade/v1/stream", {
headers: { Authorization: `Bearer ${process.env.CODEX_KEY}` },
});
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 = block.match(/^event: (.*)$/m)?.[1];
const data = block.match(/^data: (.*)$/m)?.[1];
if (event && data) console.log(event, JSON.parse(data));
}
}