WebSocket API

WebSocket protocol is a new HTML5 protocol, which provides full-duplex communication between web browsers and web servers. Connection can be established after one handshake. Web server can then push business logic data to web browsers.Advantages:

Request header is small in size (around 2 bytes) during communication Since there is no need to create and delete TCP connection repeatedly, it saves resources .

**We strongly recommend developers to use Websocket API to access market related information and trading depth.**

The connection will break automatically when a network problem occurs

url: https://websocket.indoex.io/

Command Format

Send format:

The socket support the following values

* `subscribe`
* `unsubscribe`

The `args` array,.

Successful response format:

{"status": "",”message”:””,data:””}

In the orderBook topic, the return formats for distinguishing between the first full amount and the subsequent incremental are:

{"status": "1",”message”:””,"asks":[{"",""},{"",""}...],”bids”:[{"",""},{"",""}...]}
            

Failure response format:

{"status":"0","message":"""asks":[],”bids”:[]}
Subscription

Users may subscribe to one or more topics

The format:

 { pair: '' }

the value of `op` is `subscribe`

`args` the array content is topic names

Example:

// send
{ pair: 'BTC_USDT' }
// response
 {"status":"1","message":”Subscribed to BTC_USDT"}
{"status":"1","message":"Subscribed to BTC_USDT"}
Unubscription

Users may subscribe to one or more topics

The format:

{ pair: 'BTC_USDT' }

Example:

// send
{ pair: 'BTC_USDT' }
// response
 {"status":"1","message":”Subscribed to BTC_USDT"}
{"status":"1","message":"Subscribed to BTC_USDT"}

Here is the sample document attached to get connected to our Socket API