Order Book Updates and Trade History

The websocket API makes it easy to keep in sync with the latest order book information using the standard Websocket specification from RFC6455.

First a websocket message is sent to subscribe for order book and trade history updates. Once the subscription succeeds a snapshot of the order book will be returned followed by book update and trade updates messages. The json payloads for the messages are described below.

Subscribe for Book & Trade Updates

After a websocket connection is established to the MainNet websocket endpoint wss://mainnet.aphelion-neo.com/ws, the following message should be sent to subscribe for order book and trade history updates for the NEO-APH market. To subscribe to other markets substitute the desired market name name for NEO-APH.

{ "op": "subscribe", "args": "orderBook:NEO-APH" }

Unsubscribe

To unsubscribe use the same format as used to subscribe, just switch the op to unsubscribe as in the example below.

{ "op": "unsubscribe", "args": "orderBook:NEO-APH" }

Book Updates

Book Snapshot

Upon Subscription to the Order Book a snapshot of the book will first be returned with type set to "bookSnapshot". Bids and asks come back as an array of arrays with three fields: [ order_price, order_quantity, order_quantity pending]

Here is an example:

{ "type": "bookSnapshot",
  "pair": "GAS-APH",
  "bids": [["0.00745678", "7.12345678", "2.15121321"]],
  "asks": [["0.00751231", "9.21249876", "7.21249876"]]
}

Book Update

Book updates come as an object with a type set to "bookUpdate". The book update object includes the trading pair, side of the book, and the changes as an array of arrays with three fields: [ order_price, order_quantity, order_quantity pending]. Pending quantity is the quantity waiting to be confirmed in the next block.

Entries in the changes list report the current quantity available at the specified price level. A subsequent change at the same level replaces the previous quantity at the given price (it is not a delta). A quantity of 0 indicates there are no more offers available at a given price level and it should be removed from the book.

Here is an example:

{ "type": "bookUpdate",
  "pair": "GAS-APH",
  "side": "ask",
  "changes": [ ["0.00745678", "7.12345678", "2.15121321"],
               ["0.00745678", "5.21249876", "7.21249876"],
               ["0.00745678", "0" ]
             ]
}

Trade History

Trade history entries are of type “trades” and have fields as shown below. The trades object includes the trading pair, side of the book, and the trades as an array of arrays with four fields: [price, quantity, date].

{ "type": "trades", 
  "pair": "GAS-APH", 
  "side": "ask", 
  "trades": [ ["0.00712345", "0.03580906", "2018-06-22T18:31:10Z"], 
            ...
          ]
}