Snapshot, then replay
- Read
/v1/snapshotfor public books, or/v1/me/snapshotwith a session orreadcredential for your open orders, open fills and quote identities. Store itscursorwith that state. - Replay events after the cursor over HTTP or WebSocket.
- Apply each page in order, then persist your state and
next_cursortogether.
- Each event carries its resource’s
revision: skip revisions already applied. - Its
datais rendered when it is published, never older than the snapshot it follows. - Events signal changes; a state can change more than once between two events.
- Snapshot and event rows are summaries. Read
GET /v1/orders/{id}forlast_sequence,available_to_quoteandquote_setbefore preparing a set. - Above 1,000 rows a snapshot answers
503 SNAPSHOT_TOO_LARGE: stop quoting. History pages cannot replace its cursor.
changes does all three, WebSocket first and HTTP replay between connections.
HTTP replay
- A page can hold zero events with
has_more: true: each request scans at most 1,000 journal positions. Always continue fromnext_cursor. - Cursors are globally ordered decimal strings, with gaps between a subscriber’s events.
- A cursor below the retained range or ahead of the journal answers
410 RESYNC_REQUIRED: replace local state from a fresh snapshot.
WebSocket
Connect towss://api.lamarge.trade/v1/stream and send, within five seconds:
- Omit
tokenfor public events only. - Frames have the HTTP page shape. The server sends a page at least every 500 ms, even if empty.
- Any client message other than a ping or pong closes the stream, as does a frame that cannot be sent within five seconds. An invalid subscription closes it without a control frame.
reason can precede closure:
After a disconnection, resume from the last processed page’s cursor, not the last received. Each
balance.changed only says to refetch /v1/balances: a replay may omit a venue balance’s earlier ones that moved no funds, never its latest. Only the initial authentication counts against the request budget. During a stream outage, stop renewing quotes on stale state: let the lease expire, or cancel.
Event kinds
occurred_atis the originating change’s time.- Private streams include public events. A credential sees only its own identity’s orders, maker fills and lease.
- Streams never carry bearers, transaction bytes, signatures or secrets.
order.changednotlive, or with a nullsequence: the order is off the book. Once it islive, reread it and publish a new set. A newcancel_epochvoids drafts prepared before it.fill.changedwithrole: "maker": a reservation or its outcome changed the order’s inventory; reread the order before sizing the next set.lease.changedwithactive: false: the lease lapsed, the credential ended or LaMarge disabled its quoting (renewal answers403 FORBIDDEN). Renew the lease, which advances the generation, and publish again; or stop.fill.changedfor a Lighter or Aster pool withmaker_accept_byset andmaker_accepted_atnull: accept it beforemaker_accept_byif you can deliver it; oncePAID, deliver it (bot loop).
History
Order, fill, withdrawal and trade history pages use opaque backward cursors, unrelated to event cursors. Rows show current state: useGET /v1/orders/{id} or GET /v1/takes/{id} for signing and transaction details, and event replay for forward changes.
GET /v1/takes/history, with a master session, pages whole takes with all their fills: use it for complete transfer receipts. GET /v1/fills lists only open fills and the last 50 final ones. A transfer’s take_final tells when its take has ended.