Skip to content

Terminal API

Eugene V. Palchukovsky edited this page Apr 17, 2019 · 13 revisions
Table of Contents

General
Messages
Messages / Authorization
Messages / Error
Messages / Securities

General

API uses a WebSocket connection to communicate by messages in JSON-format. Each server message is an array with one or more messages. A client can send only one message in one frame. A message has the next format:

{
  string with the message topic: message data, the format depends on message topic
}

Workflow

The first message from a newly connected client to the service must be a message with the authorization request. Any other messages may be sent only after successful authorization. If the service receives any message before - the client connection will be terminated.

Messages

Authorization

The message has the topic auth. Client message provides accounts credentials to requests the authorization process for the connection. The service message reports about authorization status. If the authorization process fails for any reason - service will close the client connection.

Request

{
  "auth": {
    "login": string with user login,
    "password": string with user password
  }
}

Response

{
  "auth": true, if the connection is authenticated, or false if not
}

Error

Service sends a message with error to notify clients about an abstract error. The message has the topic error.

{
  "error": string with error description
}

Securities

To access a security list to receive market data, or to trade, the client has to send a request for a security list. Service responds with the actual security list in topic securities and sends an update in the same topic each time when the list is changed. Before each new exchange in the security list, the service sends an exchange list with new exchanges in the topic exchanges with exchanges description.

Request

{
  "securities": {}
}

Response

Exchanges:

{
  "exchanges": {
    unique exchange ID, string: {
      "name": string with an official non-localized name of the exchange
    }
  }
}

Securities:

{
  "securities": {
    unique exchange ID, string: {
      string with unique security ID for a given exchange: {
        "isActive": true, if the security is active or false otherwise,
        "type": "currencyPair",
        "name": string with a verbose security name,
        "base": string with base currency (existent only if type is "currencyPair"),
        "quote": string with quote currency (existent only if type is "currencyPair")
      },
      string with unique security ID for a given exchange: null if security is removed from the exchange
    }
  }
}

Example

[
  {
    "exchanges": {
      "binance": {
        "name": "Binance"
      }
    }
  },
  {
    "securities": {
      "binance": {
        "btc_eur": {
          "isActive": true,
          "type": "currencyPair",
          "name": "BTC/EUR",
          "base": "BTC",
          "quote": "EUR"
        },
        "btc_usd": null
      }
    }
  }
]
Clone this wiki locally