Skip to main content

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 }]
warning

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​

TypeMessageAccess
151Subscribe / unsubscribeAnonymous
100Subscription resultAnonymous
114HMAC login, and its replyAnonymous
991Connection messageAnonymous
401All tickersAnonymous
402Pair tickerAnonymous
422TradeAnonymous
431Full order bookAnonymous
432Order book differenceAnonymous
201Balance updatedAuthenticated
423User tradeAuthenticated
441Order matchedAuthenticated
451Order insertedAuthenticated
452Order cancelledAuthenticated

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​

Meaning451 / 452 (order inserted / cancelled)441 (order matched)423 (user trade)
Message typetypetypenone (identify 423 by the first array element)
Order idididorderId
User iduserIduser—
PairpairId, symbolpair, symbolnumeratorSymbol, denominatorSymbol
SideorderType: 0 = buy, 1 = sellisBid: true = buyorderType: buy / sell
Your client idnewOrderClientIdclientIdorderClientId
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.