ADVANCED

WebSocket Streams

WebSocket Streams

WebSocket URL (production):

1wss://ws.tradelayer.com/stream

Authentication process:

  1. Connect to WS URL
  2. Send an auth message with your API key, timestamp, and signature.

Auth Message

1{
2  "op": "auth",
3  "args": {
4    "api_key": "TLK_9d2f0f...",
5    "timestamp": 1700483073000,
6    "signature": "09b3f4f9a1c2..."
7  }
8}

Success response:

1{ "op": "auth", "success": true }

Subscribe to Channels

1{
2  "op": "subscribe",
3  "args": {
4    "channels": [
5      "ticker.BTCUSDT",
6      "orderbook.BTCUSDT",
7      "user.orders.tl_user_9e8127",
8      "user.positions.tl_user_9e8127"
9    ]
10  }
11}

Ticker Update

Channel: ticker.BTCUSDT

1{
2  "channel": "ticker.BTCUSDT",
3  "data": {
4    "symbol": "BTCUSDT",
5    "last_price": "92750.5",
6    "mark_price": "92749.0",
7    "best_bid": "92749.0",
8    "best_ask": "92750.0",
9    "timestamp": 1700483073500
10  }
11}

User Order Update

Channel: user.orders.tl_user_9e8127

1{
2  "channel": "user.orders.tl_user_9e8127",
3  "data": {
4    "event": "ORDER_FILLED",
5    "order": {
6      "order_id": "tl_ord_8192837",
7      "symbol": "BTCUSDT",
8      "side": "BUY",
9      "type": "LIMIT",
10      "status": "FILLED",
11      "filled_size": "0.01",
12      "avg_fill_price": "92000.0",
13      "timestamp": 1700483075000
14    }
15  }
16}