Skip to content

Latest commit

 

History

History
250 lines (218 loc) · 7.85 KB

File metadata and controls

250 lines (218 loc) · 7.85 KB

Websocket API for Bitkub (2023-04-19)

Change log

  • 2026-05-18 market.trade.<symbol> stream will be permanently closed on 18 May 2026. Please migrate to Private WebSocket.
  • 2023-04-19 Changed the webSocket market.trade.<symbol>. Field bid, sid changed type from Integer to String.
  • 2023-01-16 Update Live Order Book, added a new event info.
  • 2022-08-31 Deprecated the authentication to Live Order Book websocket.

Table of contents

Websocket endpoint

  • The websocket endpoint is: wss://api.bitkub.com/websocket-api/<streamName>

Stream name

Stream name requires 3 parts: service name, service type, and symbol, delimited by dot (.), and is case-insensitive.

Stream name format:

<serviceName>.<serviceType>.<symbol>

Stream name example:

market.trade.thb_btc

Above example stream name provides real-time data from the market service, type trade, of symbol THB_BTC.

Multiple streams subscription:

You can combine multiple streams by using comma (,) as the delimeter.

Multiple stream names format:

<streamName>,<streamName>,<streamName>

Multiple stream names example:

market.trade.thb_btc,market.ticker.thb_btc,market.trade.thb_eth,market.ticker.thb_eth

Above subscription provides real-time data from trade and ticker streams of symbols THB_BTC and THB_ETH.

Symbols

Refer to RESTful API for all available symbols and symbol ids).

Websocket API documentation

Refer to the following for description of each stream

Trade stream

Deprecation Notice: The market.trade.<symbol> stream will be permanently closed on 18 May 2026. Please migrate to the Private WebSocket before this date to avoid service interruption. As of 2023-04-19, response fields bid and sid changed type from Integer to String.

Name:

market.trade.<symbol>

Description:

The trade stream provides real-time data on matched orders. Each trade contains buy order id and sell order id. Order id is unique by the order side (buy/sell) and symbol.

Response:

{
  "stream": "market.trade.thb_eth", // stream name
  "sym":"THB_ETH", // symbol
  "txn": "ETHSELL0000074282", // transaction id
  "rat": "5977.00", // rate matched
  "amt": 1.556539, // amount matched
  "bid": "2048451", // buy order id (string since 2023-04-19)
  "sid": "2924729", // sell order id (string since 2023-04-19)
  "ts": 1542268567 // trade timestamp
}

Ticker stream

Name:

market.ticker.<symbol>

Description:

The ticker stream provides real-time data on ticker of the specified symbol. Ticker for each symbol is re-calculated on trade order creation, cancellation, and fulfillment.

Response:

{
  "stream": "market.ticker.thb_btc",
  "id": 1,
  "last": 2883194.85,
  "lowestAsk": 2883194.9,
  "lowestAskSize": 0.0070947,
  "highestBid": 2881000.31,
  "highestBidSize": 0.00470253,
  "change": 60622.33,
  "percentChange": 2.15,
  "baseVolume": 89.25334259,
  "quoteVolume": 256768588.16,
  "isFrozen": 0,
  "high24hr": 2916959.99,
  "low24hr": 2819009.05,
  "open": 2822572.52,
  "close": 2883194.85
}

Stream Demo

The demo page is available here for testing streams subscription.

Live Order Book

Live Order Book stream

Name:

orderbook.<symbol-id>

Description:

Use symbol id (numeric id) to get real-time data of order book: wss://api.bitkub.com/websocket-api/orderbook/<symbol-id>.

There are 5 event types: bidschanged, askschanged, tradeschanged, depthchanged, and global.ticker

  • bidschanged occurs when any buy order has changed on the selected symbol (opened/closed/cancelled). Data is array of buy orders after the change (max. 30 orders).
  • askschanged occurs when any sell order has changed on the selected symbol (opened/closed/cancelled). Data is array of sell orders after the change (max. 30 orders).
  • tradeschanged occurs when buy and sell orders have been matched on the selected symbol. Data is array containing 3 arrays: array of latest trades, array of buy orders, and array of sell orders (each max. 30 orders). You get this event as the initial data upon successful subscription.
  • depthchanged occurs when the order book depth has changed on the selected symbol. Data contains two arrays — bids and asks — each entry with price, base_volume, and quote_volume.
  • ticker occurs every time when either bidschanged, askschanged, or tradeschanged is fired on the selected symbol.
  • global.ticker occurs every time when either bidschanged, askschanged, or tradeschanged is fired on any symbol in the exchange.

Message data:

{
    "data": (data),
    "event": (event type)
}

Example response (bidschanged or askschanged):

{
   "data":[
      [
         121.82, // vol
         112510.1, // rate
         0.00108283, // amount
         0, // reserved, always 0
         false, // is new order
         false // user is owner (deprecated)
      ]
   ],
   "event":"bidschanged",
   "pairing_id":1
}

Example response (tradeschanged):

{
   "data":[
      [
         [
            1550320593, // timestamp
            113587, // rate
            0.12817027, // amount
            "BUY", // side
            0, // reserved, always 0
            0, // reserved, always 0
            true, // is new order
            false, // user is buyer (available when authenticated)
            false // user is seller (available when authenticated)
         ]
      ],
      [
         [
            121.82, // vol
            112510.1, // bid rate
            0.00108283, // bid amount
            0, // reserved, always 0
            false, // is new order
            false // user is owner (available when authenticated)
         ]
      ],
      [
         [
            51247.13, // vol
            113699, // ask rate
            0.45072632, // ask amount
            0, // reserved, always 0
            false, // is new order
            false // user is owner (available when authenticated)
         ]
      ]
   ],
   "event":"tradeschanged",
   "pairing_id":1
}

Example response (depthchanged):

{
   "data":{
      "bids":[
         {
            "price": 2466650.35, // bid price
            "base_volume": 0.0002027, // amount in base currency
            "quote_volume": 500 // amount in quote currency
         },
         {
            "price": 2466650.33,
            "base_volume": 0.00299999,
            "quote_volume": 7399.93
         }
      ],
      "asks":[
         {
            "price": 2467772.05, // ask price
            "base_volume": 0.003, // amount in base currency
            "quote_volume": 7403.32 // amount in quote currency
         },
         {
            "price": 2468266.95,
            "base_volume": 0.03140643,
            "quote_volume": 77519.46
         }
      ]
   },
   "event":"depthchanged",
   "pairing_id":1
}

Example response (global.ticker):

{
   "data":{
      "id": 1,
      "last": "1500000.00",
      "percentChange": "2.45",
      "baseVolume": "123.456",
      "quoteVolume": "185184000.00",
      "high24hr": "1520000.00",
      "low24hr": "1460000.00",
      "highestBid": "1499900.00",
      "lowestAsk": "1500100.00"
    },
   "event":"global.ticker" // event name
}