API reference, Market data

WebSocket replay

Replay a past window over the same WebSocket, in exactly the live frames: a bot written for the live stream runs unchanged on the past. For backtests, debugging and demos.

Connect

Add the window to the WebSocket URL. Without replay_from the socket is the live one.

wss://api.femtos.xyz/v1/ws?ticket=$TICKET&replay_from=<ms|ISO>&replay_to=<ms|ISO>&speed=1|10|100|max
ParameterMeaning
replay_fromrequiredStart of the window: Unix ms or ISO 8601.
replay_tooptionalEnd of the window: Unix ms or ISO 8601. Default: replay_from + your tier's longest window, never past now.
speedoptional1 (real time, the default), 10, 100 or max (as fast as you read, book frames at their byte rate below; paid tiers only).

The ticket is the live socket's: POST /v1/ws-ticket with your key (single use, valid 30 s).

What you receive

  • Subscribe as on the live socket: same channels, same filters, same "batch":"block".
  • Each subscription first gets its snapshot: the state at replay_from, with the live semantics (last candles, last trades, last events).
  • The clock starts on {"op":"replay.start"}, or 500 ms after your last subscribe.
  • Frames are the live ones plus "replay":{"session","clock"}. ts.source is the original block time, ts.sent the replay clock: the node's data as it happened, no network latency added.
  • Events of the two layers come in time order; at the same time HyperCore, then Elysium, then by block and log index.
  • The replay waits for you when you read slower than it sends: it never cuts a slow reader.

Controls

Frames you send. Each is answered with a replay.status frame.

FrameWhat it does
{"op":"replay.start"}Starts the clock.
{"op":"replay.pause"}Stops the clock. The session stays open.
{"op":"replay.resume"}Starts it again where it stopped.
{"op":"replay.speed","speed":100}Changes the speed: 1, 10, 100 or "max".
{"op":"replay.seek","to":"2026-10-20T12:30:00Z"}Jumps forward to a time (Unix ms or ISO 8601): every subscription gets a fresh snapshot at the new time, then its stream. Forward only, one seek at a time: another before its replay.status answer is refused (rate_limited).
{"op":"replay.status"}Asks where the replay is.

Frames the server sends about the replay itself. Each carries session and clock.

FrameWhen
{"op":"replay.started","from","to","speed"}The clock started.
{"op":"replay.status","state","from","to","speed","effective_speed","messages","subscriptions"}The answer to a control. state: waiting, running, paused, seeking or ended. effective_speed is there when the replay runs slower than the speed asked.
{"op":"replay.gap","from_block","to_block","from_time","to_time","streams"}A range is missing from the HyperCore tables: announced when the clock reaches it.
{"op":"replay.gap","coin","reason","from_block","to_block","from_time","to_time","streams","resume_block","resume_time"}A book stops: no hc.book, hc.bbo or hc.book.named frame of that coin until resume_time, a checkpoint, then a fresh snapshot (both null: none in the window). reason: ingest_gap (blocks not stored, known or shown by the stored rows), inconsistent (a stored block does not apply, a checkpoint is not whole, or two stored rows disagree), mismatch (the state rolled does not reach the closing checkpoint: none of the interval was sent; found at a crossing, rows that changed after their check: frames since from_block are not vouched for), no_checkpoint (none closes the interval yet, or the diffs up to it are not all stored yet: the book ends at from_time), read_failed (a read of the check timed out or hit its memory limit: nothing is said of the rows, the next interval is tried; resume_time is null while the next checkpoint itself cannot be read) or interval_too_long (more than 30 minutes between two checkpoints: not checked, not sent).
{"op":"replay.end","to","messages","reason"}The end: completed, paused_timeout, not_started, no_subscription or source_error. The server then closes with code 1000.

Channels

14 channels are replayed. A subscribe to any other channel is refused with invalid_param.

ChannelLayerIn a replay
hc.tradesHyperCorefilter.coin required, as live
hc.candlesHyperCorefilter.coin and filter.tf required, as live; without includeUsd: the candles in their quote
hc.bboHyperCorefilter.coin required, as live; from 2026-11-06 03:12 UTC, the first book checkpoint; each 10-minute interval is checked against the checkpoint closing it before any frame of it goes out; one that fails sends none (replay.gap with coin), then a fresh snapshot at a later checkpoint; a fault found only while sending (rows changed after their check) stops the book from there, with the same frame; with no closing checkpoint yet, or its diffs not all stored yet, the book ends at the last one; our node's top only: the race with Hyperliquid's public feed is not replayed; block is null on a snapshot when the book's last change is not known
hc.bookHyperCorefilter.coin required, as live; from 2026-11-06 03:12 UTC, the first book checkpoint; each 10-minute interval is checked against the checkpoint closing it before any frame of it goes out; one that fails sends none (replay.gap with coin), then a fresh snapshot at a later checkpoint; a fault found only while sending (rows changed after their check) stops the book from there, with the same frame; with no closing checkpoint yet, or its diffs not all stored yet, the book ends at the last one
hc.book.namedHyperCorefilter.coin required, as live; from 2026-11-06 03:12 UTC, the first book checkpoint; each 10-minute interval is checked against the checkpoint closing it before any frame of it goes out; one that fails sends none (replay.gap with coin), then a fresh snapshot at a later checkpoint; a fault found only while sending (rows changed after their check) stops the book from there, with the same frame; with no closing checkpoint yet, or its diffs not all stored yet, the book ends at the last one; entity is today's label, not the one at that time; no walls or position, which live say as of now
hc.ordersHyperCorefilter.coin required
hc.ledgerHyperCoreAs live
hc.liquidationsHyperCoreAs live
hc.positionsHyperCoreAs live
prices.hypeHyperCoreThe stored samples only, see Good to know
hyperevm.tradesAs live
elysium.tradesElysiumAs live
elysium.launchesElysiumAs live
hyperevm.launchesLaunch rows as launched: the fields that describe the token today, such as mcapUsd or holders, are null; new launches only, no change frames

Not replayed yet: bridge.transfers, hyperevm.creator.sells, elysium.creator.sells and wallet.

Limits

Per key, by tier: the replay sessions open at once, those of them holding a book channel (hc.book, hc.bbo, hc.book.named), the longest window one replays, and its fastest speed.

TierSessions at onceWith a book channelLongest windowFastest speed
Free111 hour100x
Starter116 hoursmax
Builder1124 hoursmax
Pro337 daysmax
Scale10430 daysmax
  • Past them the upgrade answers replay_limit (429) or replay_window_too_large (400).
  • A session takes a book place at its first book channel and gives it back at its last unsubscribe, or at its end. Past the limit that subscription gets an error frame, replay_book_limit with max_book_sessions: the session and its other channels go on.
  • Across all keys, the replay engine holds 20 sessions at once (8 of free keys), of which 8 with a book channel (3 of free keys). A book channel past those gets replay_book_limit too. A session past those gets its connection, then an error frame replay_unavailable and replay.end.
  • A session with a book channel seeks once per 2 seconds at most: sooner gets rate_limited with retryAfter, as a seek still in progress does.
  • speed=max is for paid tiers: a free key, or one past its credits, gets replay_speed_not_allowed (403 at the upgrade, an error frame on replay.speed) and replays at 100x at most.
  • A session paused, not started, or running with no subscription for 5 minutes ends. A seek does not count as activity.
  • The usual connection and subscription limits apply: 64 subscriptions per connection.
  • The limits of your key: GET /v1/account, quotas.replay.

Billing

A replay counts as the live socket does: each frame by its bytes (1 credit per 48 KiB, uncompressed). A "batch":"block" frame counts as any other: its size grows with the events it carries. The replay.* frames, errors and pongs count nothing.

Good to know

  • prices.hype replays the stored samples: the oracle and mark prices written every 30 s, and the exchange candles. What the live channel sends between them (the spot mid of each block, the oracle and mark as pushed) is not replayed.
  • Order statuses (hc.orders) and the book channels (hc.book, hc.bbo, hc.book.named) older than 7 days are read from slower storage: their replay runs at 10x at most.
  • The book channels replay from 2026-11-06 03:12 UTC, the first book checkpoint. A subscription at an earlier position is refused with replay_before_checkpoints and first_available, the first time it replays from; your other subscriptions go on.
  • A book is checked before it is sent. Book checkpoints come every 10 minutes. Before any frame of one of those intervals goes out, the book is rolled silently from the checkpoint opening it to the one closing it and must match the latter order for order; the interval must hold no known hole and no block its stored rows show missing. If not, none of its frames go out: replay.gap with coin says so, and a fresh snapshot comes at a later checkpoint.
  • The newest 10 minutes or so have no closing checkpoint yet: the book ends at the last checkpoint, with replay.gap and reason no_checkpoint, whose from_time says up to when. A position there gets that frame and no snapshot. The other channels go on to the end of the window.
  • What the check cannot see: a loss in our stored rows that leaves no trace. Rows lost at the very end of a block's rows, or whole blocks (at most 5 in a row) where no order came to rest and no trade took one, when their effect on the book is undone before the interval closes, since the closing state must still match. A size stored wrong and overwritten before the close is the same. What you could then see, with no replay.gap: a missing frame and, on that price level, a wrong size or order count in the frames of other orders, for as long as the lost change would have lasted. It cannot outlast the interval: the state is exact again at its closing checkpoint at the latest.
  • A live hc.book can send a new snapshot when its source resyncs. A replay does not: it sends a new hc.book snapshot only after a replay.gap. hc.book.named also sends a new snapshot when a wallet label changes, with no gap, as live does. A live hc.bbo races our node against Hyperliquid's public feed: a replay sends our node's top of each block, with its block. So it can differ where the feed won: a frame the feed sent first, or a block's top live skipped because the feed was already past that block. Every top a replay sends is the book's at its block. Its snapshot holds the time and block of the book's last change; when that change is not known, the position and a null block.
  • Book frames go at about 1 MiB/s per session, whatever the speed: at speed=max the clock waits for them, as for a slow reader, and every channel of the session with it. What is sent does not change. On BTC in a busy half hour that is about 16 times real time for hc.book alone, about 5 times for its three channels.
  • A book subscription reads and checks its interval before its snapshot, and the replay starts once every snapshot is there. Seconds for the first subscription to an interval, less once it is checked; the checks of all keys run two reads at a time, so a session of many coins can wait minutes while many others replay at speed=max.
  • A book replay is heavy. Measured on BTC: hc.book about 35 MB per 30 minutes of market (710 credits), hc.bbo about 7 MB (140 credits), hc.book.named about 235 MB (4,800 credits). A quiet coin is a thousand times less.
  • replay_unavailable: replay is off on this server (503 at the upgrade), or the engine is full or cannot answer now, or the replays of free keys hold their whole share of it (the upgrade succeeds, then this error frame and replay.end). The live socket is not affected.

Backtest example

Python (pip install websockets requests): one hour of BTC 1-minute candles at 100x (speed=max with a paid key), a moving average crossover.

import asyncio, json, os, requests, websockets

API, KEY = "https://api.femtos.xyz/v1", os.environ["FEMTOS_KEY"]

async def backtest():
    ticket = requests.post(f"{API}/ws-ticket", headers={"Authorization": f"Bearer {KEY}"}).json()["ticket"]
    url = f"wss://api.femtos.xyz/v1/ws?ticket={ticket}&replay_from=2026-10-20T12:00:00Z&replay_to=2026-10-20T13:00:00Z&speed=100"
    closes, position, pnl = [], 0, 0.0
    async with websockets.connect(url, max_size=None) as ws:
        await ws.send(json.dumps({"op": "subscribe", "channel": "hc.candles", "filter": {"coin": "BTC", "tf": "1m"}}))
        await ws.send(json.dumps({"op": "replay.start"}))
        async for raw in ws:
            m = json.loads(raw)
            if m.get("op") == "replay.end":
                break
            if m.get("channel") != "hc.candles" or m.get("snapshot"):
                continue
            c = m["data"]
            if closes and closes[-1][0] == c["t"]:
                closes[-1] = (c["t"], float(c["c"]))     # the open candle, updated
                continue
            closes.append((c["t"], float(c["c"])))
            px = [x for _, x in closes]
            if len(px) < 21:
                continue
            fast, slow = sum(px[-6:-1]) / 5, sum(px[-21:-1]) / 20
            target = 1 if fast > slow else -1
            if target != position:
                pnl -= (target - position) * px[-2]
                position = target
    print("pnl (1 BTC):", pnl + position * closes[-1][1])

asyncio.run(backtest())

More

Agent guide (agents.md)llms.txtOpenAPIMCP serverGet an API keyChangelog