Skip to main content

Streaming

Marking supports multiplexed WebSocket feeds.

wss://api.marking.fyi/v1/streams?feedIds=btc-usd,eth-usd,sol-usd&format=json

Server-side clients authenticate with an API key in the WebSocket upgrade header:

import WebSocket from "ws";

const socket = new WebSocket(
"wss://api.marking.fyi/v1/streams?feedIds=btc-usd,eth-usd,sol-usd&format=json",
{ headers: { authorization: `Bearer ${process.env.MARKING_API_KEY}` } },
);

Autonomous paid agents authenticate with an x402-created lease:

wss://api.marking.fyi/v1/streams?leaseId=<lease-id>&feedIds=btc-usd,eth-usd

Message types

TypeMeaning
readyConnection accepted and subscribed feeds confirmed
snapshotCurrent latest signed state at connection time
updateNew canonical signed update
candle_snapshotLatest candle state for requested candle intervals
candleLive candle update
replayBounded replay response
errorStream or authorization problem

Reconnect and replay

Keep the last accepted sequence per feed. On reconnect, send a replay request or use the after cursor pattern supported by the edge path:

{
"btc-usd": "219870676620297556",
"eth-usd": "219870676624445669"
}

Consumers should treat duplicate or reordered frames as transport artifacts, not automatic feed failure.