Snapshot, then replay

  1. Read /v1/snapshot for public books, or /v1/me/snapshot with a session or read credential, and store its cursor with the state.
  2. Replay events after that cursor over HTTP or WebSocket.
  3. Apply each page in order, then persist your state and next_cursor atomically.
Events after a snapshot’s cursor carry current previews; an older mutation never overwrites newer snapshot state. Events are not a ledger of every transition. If a snapshot fails with 503 SNAPSHOT_TOO_LARGE, stop quoting: history pages cannot replace a snapshot cursor.

HTTP replay

A page can hold zero events with has_more: true: each scan of the shared journal covers at most 1,000 cursor positions. Always advance to next_cursor. Cursors are globally ordered decimal strings, not consecutive per subscriber. A cursor below the retained floor or ahead of the journal returns 410 RESYNC_REQUIRED: replace local state from a fresh snapshot. This also covers a reinitialized deployment.

WebSocket

Connect to wss://api.lamarge.trade/v1/stream and send within five seconds:
Frames have the HTTP page shape. A control frame with a reason can precede closure: After a socket failure, resume from the last processed page’s cursor, not the last received. Replaying a page is safe: ignore revisions already applied. Revalidation does not consume the request budget; the initial authentication does. A stream outage is no reason to keep renewing quotes on stale state: let the lease expire or cancel.

Event kinds

occurred_at is the originating mutation time; data is rendered at publication and may include later changes. Private streams include public events. A credential sees its own identity’s orders, maker fills and lease only. Streams never carry bearers, transaction bytes, signatures or secrets. Keep an admission-deadline timer and reconcile periodically even while connected.

History pages

Order, fill, withdrawal and trade history pages use opaque backward cursors, independent of event cursors. Rows show current state: use the resource’s GET for signing and transaction details, and event replay for forward changes. For complete transfer receipts, use GET /v1/takes/history with a master session. It pages takes by creation time and ID and includes all their fills; a page never splits a take. The live /fills snapshot contains only the last 50 final fills and cannot establish a complete receipt or the outcome of an absent take. Transfer intents expose take_final for that purpose.