WebSocket Data Interface (WebSocket API)

Interface URI: wss://www.quidax.com:8080
Return result format: JSON

WebSocket API

The WebSocket API provides developers with a more real-time data channel. The server can push the changes of the orderbook and the market transaction data to the users of the WebSocket API in real time through the websocket long connection.

Using the WebSocket API can be divided into three simple steps:

  1. 1. Establish a websocket connection
  2. 2. Use api token to verify identity
  3. 3. Receive and process data

Establish a websocket connection

WebSocket is a widely used standard, and each language has its own support library. Take Javascript as an example:


var host = 'wss://www.quidax.com:8080';
Var socket = new WebSocket(host);
Socket.onopen = function() {

Socket.onmessage = function(msg) {

Socket.onclose = function() {

You can also refer to the implementation of this Ruby client.

Use API token to verify identity

Before you can verify your identity, you must have your access/secret key ready. After you are signed up, verified and have been given API access, just visit the API Key page to get your Key.

After you establish a WebSocket connection with the server through the previous step, the server will return a challenge message with the following format:

  "challenge": "d45sSFIZZdYzRgwi-zDqA8HFP2MfVoWqXlHX-2LbB_37q9_3pkZ8og"

The challenge contains a randomly generated string. The client needs to sign the string with the access/secret key, then send the signature back to the server. The server verifies the signature. If yes, continue to the next step. Otherwise, an error message is returned.

The generation of the signature is very simple. First connect your access key to the challenge string:

payload = access_key + challenge

assumes that the access key is "abc", the challenge is "def", and the payload is "abcdef". Next, use HMAC-SHA256 and secret key to calculate the signature of the payload:

signature = HMAC-SHA256(secret_key, payload).to_hex

Assuming that secret_key is 'ghi', the result of signing the payload in the above example with HMAC-SHA256 is:

signature = HMAC-SHA256('ghi', 'abcdef').to_hex
          = '52ca0e5beab532532c62155e78d81c7dc8ad6d6f744cf3797668cf52dd2f9a41'

Now we just need to pass the resulting signature back to the server in the following format:

{auth: {access_key: 'your_access_key', answer: 'the_signature'}}

For more information, see the implementation of the official Ruby client: Streaming Client

Accept Data

After the verification is passed, the real-time data sent by the server can be accepted. Currently, two types of real-time data are provided through the WebSocket API: Trades and Orderbook. The detailed data format is as follows:


    { "id"=>2435,
        "id"=>3248, "side"=>"buy", "price"=>nil,
        "avg_price"=>"3500.0", "state"=>"done", "market"=>"btcngn",
        "created_at"=>"2014-06-16T05:02:37Z", "volume"=>"0.0331",
        "remaining_volume"=>"0.0", "executed_volume"=>"0.0331"
  • Trade message represents a new deal on your pending order.
  • Price/volume: transaction price / number of transactions
  • Funds: turnover (in quote currency)
  • Market: base currency/quote currency pair
  • Side: Your role in this deal (ask: seller, bid: buyer)
  • Ask or Bid: pending order data after the transaction


    { "action"=>"add",
  • The Orderbook message represents a change in the orderbook.
  • The Orderbook 'add' message ("action"=>"add") indicates that a new order has been added to the orderbook.
  • The Orderbook 'remove' message ("action"=>"remove") indicates that the orderbook has removed the order (the reason may be that the user cancels the pending order or the pending order is completely filled).
  • The Orderbook 'update' message ("action"=>"update") indicates that the order in the orderbook has been updated.
  • action: orderbook operation, value range: add, remove, update
  • order: the order being operated

Related libraries/tool ​​list