API Documentations

WebSocket API RESTful API

Interface URI: wss://ajubit.com:8080
Returns the 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://ajubit.com:8080';
var socket = new WebSocket(host);
socket.onopen = function() {

socket.onmessage = function(msg) {

socket.onclose = function() {

Use api token to verify identity

Before you can verify your identity, you must have your access/secret key ready. After registering and passing the authentication, 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:


The challenge contains a randomly generated string. The client needs to sign the string with the access/secret key, and 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.

Signature generation is very simple, first connect your access key with the challenge string:

payload = access_key + challenge

Suppose 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'}}

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: Trade and Orderbook. The detailed data format is as follows:

Type of dataData structure / exampleRemarks
{ "trade"=>
    { "id"=>2435,
        "id"=>3248, "side"=>"buy", "price"=>nil,
        "avg_price"=>"3500.0", "state"=>"done", "market"=>"btcusd",
        "created_at"=>"2014-06-16T05:02:37Z", "volume"=>"0.0331",
        "remaining_volume"=>"0.0", "executed_volume"=>"0.0331"

Trade News has a new deal on behalf of 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 the deal (ask: seller, bid: buyer)

Ask or bid pending order data after the transaction

{ "orderbook"=>
  { "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, range of values: add, remove, update

Order the order being operated