Viewing: Depth

Real-time WebSocket - Depth

Stream real-time level-by-level bid/ask depth updates through the depth channel.

WS /ws/v1/market/depth/

Pro+

Real-time depth channel for level-by-level bid/ask streaming.

Endpoint

wss://api.sahmk.sa/ws/v1/market/depth/?api_key=YOUR_API_KEY

Data availability by plan:

Connected message

json
{
  "type": "connected",
  "channel": "depth",
  "symbol": null,
  "plan": "enterprise",
  "entitled_levels": 20,
  "limits": {
    "max_symbols_per_connection": 200,
    "max_symbols_per_call": 20,
    "wildcard_allowed": true
  },
  "timestamp": "2026-07-09T15:05:37.840967+00:00"
}

Optional: add symbol=2222 to receive connected followed by an initial depth_snapshot.

Client actions

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

Use symbols for subscribe/unsubscribe. For single-symbol requests, the server also accepts symbol.

Depth message ordering

  • Explicit symbols: one depth_snapshot per symbol, then subscribed.
  • Enterprise wildcard: subscribed first, then the initial snapshot burst.
  • Ongoing depth updates are also depth_snapshot messages.

Subscribed message

json
{
  "type": "subscribed",
  "symbols": ["1120", "2222"],
  "total": 2,
  "limit": 200
}

Depth snapshot message

200 OKapplication/json
{
  "type": "depth_snapshot",
  "symbol": "2222",
  "available": true,
  "updated_at": "2026-07-09T15:05:37.840967+00:00",
  "session": "postmarket",
  "book_state": "normal",
  "levels": 20,
  "best_bid": 26.68,
  "best_ask": 26.72,
  "spread": 0.04,
  "spread_bps": 14.99,
  "total_bid_quantity_top5": 29085,
  "total_ask_quantity_top5": 504644,
  "total_bid_quantity": 29085,
  "total_ask_quantity": 504644,
  "level_imbalance": -0.891,
  "level_imbalance_top5": -0.891,
  "bids": [
    {
      "level": 0,
      "price": 26.68,
      "quantity": 79,
      "order_count": 10
    }
  ],
  "asks": [
    {
      "level": 0,
      "price": 26.72,
      "quantity": 41188,
      "order_count": 38
    }
  ],
  "entitled_levels": 20,
  "timestamp": "2026-07-09T15:05:37.872738+00:00"
}

Last updated on