Skip to content

WebSocket Real-time Push

Connection Information

Connection Endpoint: wss://{host}/ws/maker/v1?types=order_status_change

Description: Provides real-time order status change push notifications for Makers. When order status changes, the system automatically pushes notifications to relevant Makers.

Authentication: Authorization header with JWT token

Query Parameters

ParameterTypeRequiredDescription
typesstringYesURL query parameter for subscribing to specified message types, multiple types separated by commas

Order Status Change Notification

When order status changes, you will receive messages in the following format:

json
{
  "type": "order_status_change",
  "timestamp": "2024-01-01T12:00:00Z",
  "data": {
    "order_hash": "0x1234567890abcdef...",
    "maker": "0x1111111111111111111111111111111111111111",
    "from_status": "pending",
    "to_status": "locked",
    "metadata": {
      "taker_address": "0xabcdef1234567890...",
      "expires_at": "2024-01-01T13:00:00Z",
      "lock_id": "uuid-string"
    }
  }
}

Message Field Description

FieldTypeDescription
typestringMessage type
timestampstringTimestamp
dataobjectOrder status change data
data.order_hashstringOrder hash
data.makerstringMaker address
data.from_statusenumOriginal status (may be null)
data.to_statusenumNew status
data.metadataobjectAdditional information (optional)

Status Change Trigger Scenarios

1. Order Creation

  • nullpending: Order created successfully
  • nullrejected: Order validation failed

2. Taker Operations

  • pendinglocked: Taker locks order
  • lockedpending: Taker unlocks order
  • lockedrejected: Taker rejects order
  • pending/lockedpartially_filled: Order partially filled
  • partially_filledfilled: Order fully filled

3. Maker Operations

  • pendingcancelled: Maker cancels order

4. System Operations

  • pendingexpired: Order automatically expires
  • Any status → suspended: System exception, requires manual intervention

Browser Support

Due to browser WebSocket security policies, Authorization header is not supported, but can be passed through subprotocols:

javascript
const ws = new WebSocket(
  `wss://${host}/ws/maker/v1?types=order_status_change`, 
  ['jwt', jwt]
);

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  console.log('Received:', message);
};

Server Heartbeat

The server sends heartbeat messages to the connection at regular intervals:

json
{
  "type": "heartbeat",
  "timestamp": 1763722070521
}

Enum Types

WebSocketDataType - WebSocket Message Type

EnumDescription
heartbeatServer-side heartbeat notification
order_status_changeOrder status change