WebSocket API — Orders Channel

Live order lifecycle events for the authenticated account. Subscribe once; the server sends a snapshot of all live orders, then a stream of incremental updates.

wss://api.godarkdex.com/ws/v1

Authenticate with op: login first (see WebSocket Trading).

Subscribe

{ "id": "c-2", "op": "subscribe", "args": { "channel": "orders" } }

Response:

{ "id": "c-2", "op": "subscribe", "code": 0, "data": { "channel": "orders", "seq_start": 1 } }

Event Flow

snapshot → snapshot → ... → snapshot (snapshot_complete: true) → update → update → ...

The server first replays every currently live order as a snapshot frame, then emits update frames as state changes. The final snapshot frame carries snapshot_complete: true; that is the signal to start applying buffered updates.

Incremental updates that arrive while snapshot delivery is in progress should be buffered and replayed after snapshot_complete: true.

Frame Shape

Every frame on this channel:

{
  "channel": "orders",
  "type": "snapshot" | "update",
  "seq": 42,
  "snapshot_complete": false,
  "data": { /* order object — fields below */ }
}
FieldDescription
typesnapshot during initial replay; update afterward
seqMonotonic per subscription per session. Gaps mean a missed event.
snapshot_completetrue on the final snapshot frame; false on all others
dataThe order object — see field reference below

Order Object

Same schema as GET /orders/{orderId}, plus a message_type that classifies the event:

message_typeTriggered when
openOrder accepted and working in the book
partial_fillOrder partially filled; remainder working
filledOrder fully filled
cancelledOrder cancelled (see cancel_reason)
rejectedOrder rejected (see reject_reason)
modifiedModify applied
cancel_rejectedCancel request failed (e.g. order no longer live)
modify_rejectedModify request failed

Example — update / filled

{
  "channel": "orders",
  "type": "update",
  "seq": 128,
  "snapshot_complete": false,
  "data": {
    "message_type": "filled",
    "order_id": "ord_01HXYZ12345",
    "client_order_id": "my-order-001",
    "symbol": "BTC-USDC-PERP",
    "side": "buy",
    "type": "limit",
    "time_in_force": "GTC",
    "price": 95000,
    "quantity": 0.1,
    "filled_quantity": 0.1,
    "remaining_quantity": 0,
    "average_fill_price": 94998.5,
    "last_fill_qty": 0.07,
    "last_fill_price": 94998.0,
    "status": "FILLED",
    "in_time_ns": 1839975000775731091,
    "out_time_ns": 1839975000799293016,
    "cancel_reason": null,
    "reject_reason": null
  }
}

Field Reference

FieldTypeDescription
message_typestringSee table above
order_idstringVenue order id
client_order_idstring | nullIdempotency key set on placement
symbolstringInstrument id
sidestringbuy or sell
typestringmarket, limit, or peg
time_in_forcestringGTC, GTT, IOC, or FOK
pricenumber | nullLimit price
quantitynumberOriginal order size
filled_quantitynumberTotal filled so far
remaining_quantitynumberUnfilled remainder
average_fill_pricenumber | nullVolume-weighted average
last_fill_qtynumber | nullSize of the fill in this event
last_fill_pricenumber | nullPrice of the fill in this event
statusstringNEW, PARTIALLY_FILLED, FILLED, CANCELLED, REJECTED
in_time_nsintegerOrder entry timestamp (ns epoch)
out_time_nsintegerEvent emit timestamp (ns epoch)
cancel_reasonstring | nullPopulated on cancelled; see below
reject_reasonstring | nullPopulated on rejected / cancel_rejected / modify_rejected; see below

Rejection Reasons

Values for reject_reason when message_type is rejected:

ValueDescription
MARGIN_INSUFFICIENTPre-trade margin check failed
POSITION_LIMIT_EXCEEDEDWould exceed max position size
LEVERAGE_EXCEEDEDRequested leverage above instrument max
INSUFFICIENT_LIQUIDITYFOK order could not be fully filled
INVALID_PRICEPrice outside acceptable range
DUPLICATE_CLIENT_ORDER_IDAnother live order uses this client_order_id
INSTRUMENT_HALTEDInstrument not currently accepting orders
ACCOUNT_IN_LIQUIDATIONAccount is being liquidated; new orders blocked
RISK_CHECK_FAILEDGeneric risk check failure

Cancellation Reasons

Values for cancel_reason when message_type is cancelled:

ValueDescription
USER_REQUESTEDCancelled by user via REST or WS
IOC_REMAINDERUnfilled portion of an IOC order
FOK_NOT_FILLEDFOK order could not fully fill
GTT_EXPIREDReached expiry_time
SELF_TRADE_PREVENTIONWould have matched against the same account
LIQUIDATIONAccount entered liquidation
CANCEL_ON_DISCONNECTSocket disconnected with cancel_on_disconnect: true
SYSTEM_CANCELCancelled by the system (settlement, cluster migration, etc.)

Gap Recovery

Clients should track seq. If a gap appears (seq_n > seq_{n-1} + 1):

  1. op: unsubscribe { channel: "orders" }
  2. op: subscribe { channel: "orders" } — receive a fresh snapshot
  3. Resume applying updates from the new seq series

Unsubscribe

{ "id": "c-9", "op": "unsubscribe", "args": { "channel": "orders" } }