Home Features Markets Blog
Guide Contact
 
Telegram icon Twitter icon Facebook icon

WebSocket API Documentation - Version 1.0

Basics


Subscriptions


Other Commands



Connection

Our WebSocket server conforms to the W3C standard for WebSockets. You can reach the server at:


Requests

Once the connection is established, you can send requests to the server. These requests must be sent as JSON and typically follow this pattern:
{
    "operation": "operation_name",
    "parameter_1": "some_value"
}

Responses

The server also responds with JSON. All integer and float values are returned as quoted strings. This ensures that no precision is lost across platforms.
{
    "id": "UPPERCASE_RESPONSE_IDENTIFIER",
    "data": {
        "string_example": "abc",
        "integer_example": "4330",
        "float_example": "14.5344"
    }
}

Keepalive

A client has to send a "keepalive" every 30 seconds or the server will close the connection. For more details regarding this command, please refer to the keepalive command.


Subscriptions

Subscribing to one of our channels is a convenient way to receive real-time data specific to your interests. Instead of polling our HTTPS API, you should use WebSocket subscriptions whenever possible. Keep in mind that, depending on the channel, it might take a while until you receive the first update (e. g. when subscribing to a market with low activity). If you build a custom user interface, you should use the HTTPS API for initializing it and use the WebSocket API for updates.

Subscribing and Unsubscribing

Subscribing to a channel is straightforward. Here is an example:
{
    "operation": "subscribe",
    "channel": "TRADES_BTCUSD"
}

You will receive an instant response indicating whether or not the subscription was successful:
{
    "id": "SUBSCRIBE_SUCCESS_TRADES_BTCUSD",
    "data": null
}
{
    "id": "SUBSCRIBE_ERROR_TRADES_BTCUSD",
    "data": "Channel TRADES_BTCUSD does not exist."
}

Once subscribed, you will receive real-time updates for the channel:
{
    "id": "TRADES_BTCUSD",
    "data": {
        "trade_id": "37",
        "symbol": "BTCUSD",
        "type": "BUY",
        "price": "12702",
        "contracts": "25",
        "date": "2017-12-07T13:47:39.123456Z"
    }
}

There are two ways to unsubscribe from channels:
{
    "operation": "unsubscribe",
    "channel": "TRADES_BTCUSD"
}
{
    "operation": "unsubscribeall"
}

Available Channels


USER_USERID

Every time the cash balance, orders or positions of the specified user ID change you will receive an update on this channel with the affected currency in the data field. Replace USERID with your own user ID that you can find out with the user/get HTTPS API call. This channel is meant to be used together with the user/overview HTTPS API call. Calling the HTTPS API each time you receive an update on this channel ensures real-time information in your application.
{
    "id": "USER_USERID",
    "data": {
        "currency": "BTC"
    }
}

TICKER_SYMBOL

A message is received on this channel every time the bid price, ask price or last price of the specified market changes. Replace SYMBOL with the desired market symbol.
{
    "id": "TICKER_SYMBOL",
    "data": {
        "ask": "10400",
        "bid": "10385",
        "last": "10400",
        "symbol": "SYMBOL"
    }
}

TRADES_SYMBOL

A message is received every time a trade happens. Replace SYMBOL with the desired market symbol.
{
    "id": "TRADES_SYMBOL",
    "data": {
        "trade_id": "6",
        "symbol": "SYMBOL",
        "type": "BUY",
        "price": "10200",
        "contracts": "8159",
        "volume": "0.79990836",
        "date": "2018-01-31T13:25:52.748000Z"
    }
}

ORDERBOOK_CHANGES_SYMBOL

Every time the order book is changed a message is received on this channel. Replace SYMBOL with the desired market symbol. Together with the market/orderbook HTTPS API request this is useful for maintaining a real-time order book.
{
    "id": "ORDERBOOK_CHANGES_SYMBOL",
    "data": {
        "type": "BID",
        "price": "9810",
        "contracts_delta": "-40",
        "server_time": "2017-12-07T13:48:51.643Z"
    }
}



Other Commands

keepalive

Description

The keepalive command has to be sent every 30 seconds or the server will close your connection. Returns a success message if the keepalive was successful.

Request

{
    "operation": "keepalive"
}

Example Response

{
    "id": "KEEPALIVE_SUCCESS",
    "data": null
}


heartbeat_on

Description

Activates heartbeat messages. The server will send a heartbeat every second with the current server UNIX time in milliseconds since 1970-01-01. You can use this to synchronize clocks or to check connectivity.

Request

{
    "operation": "heartbeat_on"
}

Example Response

{
    "id": "HEARTBEAT",
    "data": "1516800623899"
}


heartbeat_off

Description

Disables heartbeat messages.

Request

{
    "operation": "heartbeat_off"
}

Latest Blog Entries

Portfolio system is live!
3 months
Minor update
3 months
Portfolio System
3 months
New Funding System
5 months

What are you waiting for?

Trading Panel

Take us with you

Get it on
Google Play