Connection & Message Format
The BtcTurk Global API has a WebSocket feed for realtime market data and, once authenticated, for your own order, trade and balance events. The feed is a standard WebSocket connection carrying JSON messages in a compact array envelope.
WSS wss://ws.global.btcturk.com
The feed accepts WebSocket connections over HTTP/1.1. Clients that negotiate HTTP/2 are rejected with
400, so force HTTP/1.1 in your WebSocket library if needed.
Use it instead of polling Get Tickers, Get OrderBook and Get Trades when you need continuous updates.
Message envelope
Every message - in both directions - is a JSON array with exactly two elements:
[<type>, <payload>]
<type>is an integer message type.<payload>is a JSON object.
[151, { "type": 151, "channel": "ticker", "event": "BTCUSDT", "join": true }]
A message that is not valid JSON, is not an array, or does not have exactly two elements gets no
reply. A repeated login on an authenticated connection gets no reply either. A join to an unknown
channel is acknowledged with ok: true but delivers nothing. If you send a subscription and receive
nothing at all, check the envelope shape and the channel name first.
Messages the server sends normally repeat the type inside the payload as a type field, so you can
read it from either place. The one exception is
User Trade, whose payload has no type field - read
the array element there.
Message types
| Type | Message | Access |
|---|---|---|
151 | Subscribe / unsubscribe | Anonymous |
100 | Subscription result | Anonymous |
114 | HMAC login, and its reply | Anonymous |
991 | Connection message | Anonymous |
401 | All tickers | Anonymous |
402 | Pair ticker | Anonymous |
422 | Trade | Anonymous |
431 | Full order book | Anonymous |
432 | Order book difference | Anonymous |
201 | Balance updated | Authenticated |
423 | User trade | Authenticated |
441 | Order matched | Authenticated |
451 | Order inserted | Authenticated |
452 | Order cancelled | Authenticated |
New message types may be added; ignore any type you do not recognise.
Connection message
Right after you connect, the server sends:
[991, { "type": 991, "current": "…", "min": "…" }]
It is informational. You do not need to reply, and you can ignore it.
Field names in private messages
| Meaning | 451 / 452 (order inserted / cancelled) | 441 (order matched) | 423 (user trade) |
|---|---|---|---|
| Message type | type | type | none (identify 423 by the first array element) |
| Order id | id | id | orderId |
| User id | userId | user | — |
| Pair | pairId, symbol | pair, symbol | numeratorSymbol, denominatorSymbol |
| Side | orderType: 0 = buy, 1 = sell | isBid: true = buy | orderType: buy / sell |
| Your client id | newOrderClientId | clientId | orderClientId |
| Time | — | timestamp (string, ms) | timestamp (number, ms) |
In 451 and 452, numLeft is the unfilled amount in the base asset and denomLeft the order value in the quote asset.