Viewing: Trades

Real-time WebSocket - Trades

Stream live trades through the trades channel. On subscribe, you receive a snapshot, then live trade updates.

WS /ws/v1/market/trades/

Pro+

Real-time trades channel for live trade updates.

Endpoint

wss://app.sahmk.sa/ws/v1/market/trades/?api_key=YOUR_API_KEY

Optional: add symbol=2222 to auto-subscribe on connect.

Connected message

json
{
  "type": "connected",
  "channel": "trades",
  "plan": "pro",
  "delivery_profile": "standard",
  "limits": {
    "max_symbols_per_connection": 60,
    "max_symbols_per_call": 20,
    "snapshot_limit_max": 200
  },
  "message": "Connected to SAHMK real-time trades stream",
  "timestamp": "2026-07-28T09:31:58.197050+00:00"
}

Client actions

json
{"action":"subscribe","symbols":["2222","1120"]}
{"action":"unsubscribe","symbols":["1120"]}
{"action":"snapshot","symbol":"2222","limit":50}
{"action":"ping"}
{"action":"subscribe","symbols":["*"]} // Enterprise only

Snapshot limit defaults to 50 (max 200).

Snapshot message

200 OKapplication/json
{
  "type": "trades_snapshot",
  "symbol": "2222",
  "updated_at": "2026-07-28T09:31:55+00:00",
  "count": 2,
  "events": [
    {
      "event_time": "2026-07-28T09:31:55+00:00",
      "price": 26.3,
      "quantity": 40,
      "value": 1052.0
    },
    {
      "event_time": "2026-07-28T09:31:47+00:00",
      "price": 26.3,
      "quantity": 5000,
      "value": 131500.0
    }
  ],
  "summary": {
    "event_count": 2,
    "trade_quantity": 5040,
    "trade_value": 132552.0,
    "latest_event_time": "2026-07-28T09:31:55+00:00"
  },
  "timestamp": "2026-07-28T09:31:58.300000+00:00"
}

Trade message

200 OKapplication/json
{
  "type": "trade",
  "symbol": "2222",
  "event_time": "2026-07-28T09:31:58+00:00",
  "price": 26.32,
  "quantity": 10,
  "value": 263.2,
  "market_session": "REGULAR",
  "timestamp": "2026-07-28T09:31:58.774829+00:00"
}