REST API

Public methods

Use the following public methods to obtain various exchange data:

GET[base]/frontoffice/api/info

Get the supported instruments

GET[base]/marketdata/instruments/{instrument}/depth

Get an order book snapshot

GET[base]/marketdata/instruments/{instrument}/history

Get data about instrument candles

GET[base2]/asset

Get data about assets

GET[base2]/summary

Get data about a market

GET[base2]/ticker

Get ticker data

GET[base2]/trades/{instrument}

Get data about trades

Get the supported instruments

Use this method to obtain up-to-date information about all currency pairs (instruments) supported by the exchange.

Request

No parameters.

GET[base]/frontoffice/api/info

GET /frontoffice/api/info HTTP/1.1
Host: host.name

Response

baseAsset string

The base asset.

quoteAsset string

The quote asset.

minAmount number

The minimum asset amount that can be traded.

priceDeviation number

The allowed price deviation for limit orders, upon exceeding which an order will be cancelled.

hidden number

The instrument availability: 0 — available; 1 — hidden (trading is not recommended because this instrument may be due to be disconnected).

fee number

The fee charged for trades involving the instrument.

makerFee number

The maker fee charged for orders providing market liquidity.

makerFeeLimit number

The minimum maker fee charged for a trade.

takerFee number

The taker fee charged for orders diminishing market liquidity.

takerFeeLimit number

The minimum taker fee charged for a trade.

priceScale number

The minimum increment with which an asset price can be changed at a time.

amountScale number

The minimum increment with which an asset amount can be changed at a time.

createdAt string

The date and time when an instrument has been created: YYYY-MM-DDThh:mm:ss.

updatedAt string

The date and time when an instrument has last been updated: YYYY-MM-DDThh:mm:ss.

status number

The instrument status:

  • 0 — open

  • 1 — halted (new orders are not accepted, open orders are cancelled)

  • 2 — paused (new orders are not accepted, open orders are awaiting execution)

side number

The order sides permitted for instrument trading:

  • 0 — buy and sell

  • 1 — buy

  • 2 — sell

RESPONSE BODY EXAMPLE
{
  "serverTime": 636880696809972288,
  "pairs": {
    "btc_usdt": {
      "baseAsset": "btc",
      "quoteAsset": "usdt",
      "minAmount": 0,
      "priceDeviation": 0,
      "hidden": 0,
      "fee": 0,
      "makerFee": 0,
      "makerFeeLimit": 0,
      "takerFee": 0.001,
      "takerFeeLimit": 0,
      "priceScale": 6,
      "amountScale": 6,
      "createdAt": "2019-11-14T16:18:49.253354",
      "updatedAt": "2019-11-14T16:18:49.253354",
      "status": 0,
      "side": 0
    },
    "gnt_usdt": {
      "baseAsset": "gnt",
      "quoteAsset": "usdt",
      "minAmount": 0,
      "priceDeviation": 0,
      "hidden": 0,
      "fee": 0,
      "makerFee": 0,
      "makerFeeLimit": 0,
      "takerFee": 0.001,
      "takerFeeLimit": 0,
      "priceScale": 5,
      "amountScale": 5,
      "createdAt": "2019-11-14T16:18:49.255354",
      "updatedAt": "2019-11-14T16:18:49.255354",
      "status": 0,
      "side": 0
    }
  }
}

Get an order book snapshot

Use this method to obtain order book information for a specified currency pair (instrument).

Request

Path parameters:

instrument required

The instrument identifier: {baseAsset}_{quoteAsset}.

GET[base]/marketdata/instruments/{instrument}/depth

GET /marketdata/instruments/eth_btc/depth HTTP/1.1
Host: host.name

Response

instrument string

The instrument identifier (the one specified in the request).

bids array

Each element of the array represents a particular order and contains numeric fields amount and price.

asks array

Each element of the array represents a particular order and contains numeric fields amount and price.

version number

The current order book snapshot version.

askTotalAmount number

The total amount of all ask (sell) orders.

bidTotalAmount number

The total amount of all bid (buy) orders.

snapshot boolean

A self-contained snapshot (always true for this request).

RESPONSE BODY EXAMPLE
{
  "instrument": "eth_btc",
  "bids": [
    {
      "amount": 0.3092258,
      "price": 0.01734264
    },
    {
      "amount": 51.61494099,
      "price": 0.01734363
    }
  ],
  "asks": [
    {
      "amount": 133.52370356,
      "price": 0.01739337
    },
    {
      "amount": 9.16854518,
      "price": 0.01739838
    }
  ],
  "version": 1891724,
  "askTotalAmount": 1849.11363582,
  "bidTotalAmount": 809.23878372,
  "snapshot": true
}

Get data about instrument candles

Use this method to obtain candlestick data for a specified currency pair (instrument).

Request

Path parameters:

instrument required

The instrument identifier: {baseAsset}_{quoteAsset}.

Query parameters:

startDate required

The date and time indicating the beginning of a required time interval: YYYY-MM-DDThh:mm:ss

endDate required

The date and time indicating the end of a required time interval: YYYY-MM-DDThh:mm:ss

type required

The detail level of the chart data; the following values are supported:

  • 1m1 minute

  • 5m5 minutes

  • 15m15 minutes

  • 30m30 minutes

  • 1h1 hour

  • 12h12 hours

  • 1d1 day

  • 1w1 week

  • 1M1 month

count number

The number of candles to return; the default value is 1000 (which is the maximum supported value).

GET[base]/marketdata/instruments/{instrument}/history

GET /marketdata/instruments/btc_usdt/history?startDate=2019-03-13T09:00:00&endDate=2019-03-13T11:00:00&type=1h&count=2 HTTP/1.1
Host: host.name

Response

instrument string

The same as in the request.

start string

The same as in the request.

end string

The same as in the request.

low number

The lowest trade price.

high number

The highest trade price.

volume number

The total volume of trades.

quoteVolume number

The total traded volume of a quote asset.

open number

The opening price.

close number

The closing price.

RESPONSE BODY EXAMPLE
{
  "success": true,
  "instrument": "btc_usdt",
  "data": [
    {
      "instrument": "btc_usdt",
      "start": "2019-03-13T09:00:00Z",
      "end": "2019-03-13T10:00:00Z",
      "low": 3842.855,
      "high": 3855.445,
      "volume": 4,
      "quoteVolume": 0,
      "open": 3855.105,
      "close": 3842.855
    },
    {
      "instrument": "btc_usdt",
      "start": "2019-03-13T10:00:00Z",
      "end": "2019-03-13T11:00:00Z",
      "low": 3834.355,
      "high": 3848.855,
      "volume": 26,
      "quoteVolume": 0,
      "open": 3842.865,
      "close": 3835.655
    }
  ],
  "startDateTime": "2019-03-13T09:00:00Z",
  "endDateTime": "2019-03-13T11:00:00Z"
}

Get data about assets

Use this method to obtain up-to-date information about supported assets.

Request

No parameters.

GET[base2]/asset

GET /asset HTTP/1.1
Host: host.name

Response

name string

The asset name.

can_withdraw string

If true, the asset can be withdrawn.

can_deposit string

If true, the asset can be deposited.

min_withdraw string

The minimum withdrawal/deposit amount.

max_withdraw string

The maximum withdrawal/deposit amount.

RESPONSE BODY EXAMPLE
{
  "BTC": {
    "name": "btc",
    "can_withdraw": true,
    "can_deposit": true,
    "min_withdraw": "0.00000001",
    "max_withdraw": "100000000"
  },
  "USDT": {
    "name": "usdt",
    "can_withdraw": true,
    "can_deposit": true,
    "min_withdraw": "0.00000001",
    "max_withdraw": "100000000"
}

Get data about a market

Use this method to obtain summary information about a specified market. The data is aggregated for the last 24 hours.

Request

No parameters.

GET[base2]/summary

GET /summary HTTP/1.1
Host: host.name

Response

id string

The market identifier

last string

The price of the most recent trade executed within the last 24 hours; 0 if more than 24 hours have passed since the most recent trade has been executed on this market.

lowestAsk string

The lowest ask (sell) price by this time.

highestBid string

The highest bid (buy) price by this time.

percentChange string

The price change within the last 24 hours, as a percentage.

baseVolume string

The total volume of assets traded within the last 24 hours (converted to a base asset).

quoteVolume string

The total volume of assets traded within the last 24 hours (converted to a quote asset).

isFrozen string

The current market status: 0 — active (orders can be placed and are being processed); 1 — temporarily suspended (orders cannot be placed and are not processed).

high24hr string

The maximum trade price within the last 24 hours.

low24hr string

The minimum trade price within the last 24 hours.

RESPONSE BODY EXAMPLE
{
  "BTC_USDT": {
    "id": "btc_usdt",
    "last": "10978.93578",
    "lowestAsk": "10979.0",
    "highestBid": "10978.71",
    "percentChange": "0.0813730364297798727996051454",
    "baseVolume": "6.47119743",
    "quoteVolume": "70829.9781692126756",
    "isFrozen": "0",
    "high24hr": "10985.0049",
    "low24hr": "10857.95376"
  },
  "BTC_USD": {
    "id": "btc_usd",
    "last": "0",
    "lowestAsk": "0",
    "highestBid": "0",
    "percentChange": "0",
    "baseVolume": "0",
    "quoteVolume": "0",
    "isFrozen": "0",
    "high24hr": "0",
    "low24hr": "0"
  }
}

Get ticker data

Use this method to obtain up-to-date ticker information.

Request

No parameters.

GET[base2]/ticker

GET /ticker HTTP/1.1
Host: host.name

Response

base_name string

The base asset name.

quote_name string

The quote asset name.

last_price string

The price of the most recent trade executed within the last 24 hours; 0 if more than 24 hours have passed since the most recent trade has been executed on this market.

base_volume string

The total base asset volume traded within the last 24 hours.

quote_volume string

The total quote asset volume traded within the last 24 hours.

isFrozen string

The current market status: 0 — active (orders can be placed and are being processed); 1 — temporarily suspended (orders cannot be placed and are not processed).

RESPONSE BODY EXAMPLE
{
  "dash_btc": {
    "base_name": "dash",
    "quote_name": "btc",
    "last_price": "0",
    "base_volume": "0",
    "quote_volume": "0",
    "isFrozen": "1"
  },
  "eth_usdt": {
    "base_name": "eth",
    "quote_name": "usdt",
    "last_price": "423.9936",
    "base_volume": "2942.97774",
    "quote_volume": "1273092.080666887",
    "isFrozen": "0"
  }
}

Get data about trades

Use this method to obtain information about all trades made with a specified currency pair (instrument) within the last 24 hours.

Request

Path parameters:

instrument required

The instrument identifier: {baseAsset}_{quoteAsset}.

GET[base2]/trades/{instrument}

GET /trades/btc_usd HTTP/1.1
Host: host.name

Response

tradeID string

The trade identifier.

price string

The trade price.

base_volume string

The base asset amount.

quote_volume string

The quote asset amount.

trade_timestamp string

The date and time when a trade has been executed, in the format of a Unix time stamp.

type string

The trade side: buy or sell.

RESPONSE BODY EXAMPLE
[
  {
    "tradeID": "1247307",
    "price": "10093.92246491",
    "base_volume": "0.0259",
    "quote_volume": "261.432591841169",
    "trade_timestamp": "1599577070",
    "type": "buy"
  },
  {
    "tradeID": "1247309",
    "price": "10091.69185435",
    "base_volume": "0.0754",
    "quote_volume": "760.913565817990",
    "trade_timestamp": "1599577128",
    "type": "sell"
  }
]

Private methods

Use the following private methods to trade on the exchange and obtain the data about user orders, trades and balances:

POST[base]/frontoffice/api/order

Place an order

GET[base]/frontoffice/api/order_history

Get order history

DELETE[base]/frontoffice/api/orders/{id}

Cancel an order

POST[base]/frontoffice/api/stoporders

Create a stop order

GET[base]/frontoffice/api/stoporders

Get stop order history

GET[base]/frontoffice/api/stoporders/{id}

Get stop order details

DELETE[base]/frontoffice/api/stoporders/{id}

Delete a stop order

GET[base]/frontoffice/api/trade_history

Get trade history

GET[base]/frontoffice/api/balances

Get user balance

GET[base]/frontoffice/api/orders

Get order details

GET[base]/frontoffice/api/orders/my

Get data about the current user’s orders

Place an order

Use this method to place a new market or limit order on the exchange.

Request

The ts and nonce values should be specified for a request.

Body:

instrument string required

The currency pair identifier: {baseAsset}_{quoteAsset}.

type string required

The order side: buy or sell.

amount number required

The order amount (must be greater than 0).

price number

The order price (required for limit orders, optional for market orders); if isLimit is true, this value must be greater than 0; otherwise, it can be equal to 0.

isLimit boolean

Set this value to true to place a limit order; set this value to false to place a market order (see Flags combinations to learn more).

isFok boolean

If true, the order is supposed to be executed immediately in a full amount or cancelled if not filled (see Flags combinations to learn more).

clientOrderId number

The order identifier provided by a client (can be any UUID strings, except for 00000000-0000-0000-0000-000000000000); must be unique among the orders placed on behalf of a particular client, meaning that an order with a clientOrderId identical to the one of an already placed order will not by placed.

POST[base]/frontoffice/api/order

POST /frontoffice/api/order HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...

{
  "ts": "2019-12-12T01:01:01",
  "nonce": 4,
  "order": {
    "instrument": "btc_usdt",
    "type": "sell",
    "amount": 1,
    "price": 1,
    "isLimit": true,
    "isFok": false,
    "clientOrderId": "6fdf688e-00b0-4c68-82dd-3aee5c727ed1"
  }
}
const crypto = require('crypto');
const https = require('https');
const Key = "7fa6ceec-d8fc..."; // Change to your PublicKey
const Secret = "7ae49b5b-99db..."; // Change to your Secret
const Host = "host.name"; // Change to your host name
const Method = '/frontoffice/api/order'
const Payload = new Date().toISOString();
const body = {
  ts: Payload,
  nonce:1,
  order: {
    instrument: 'eth_usd',
    type: 'buy',
    amount: 1,
    price: 1,
    isLimit: true
  }
};
const data = JSON.stringify(body);
const Sign = crypto
  .createHmac('sha512', Secret)
  .update(data)
  .digest('hex')
  .toUpperCase();
const options = {
  hostname: Host,
  path: Method,
  port: Port,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Key,
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
    Sign
  }
};
const req = https.request(options, res => {
  console.log(`statusCode: ${res.statusCode}`);
  res.on('data', d => {
    process.stdout.write(d);
  });
});
req.on('error', e => {
  console.error(e);
});
req.write(data);
req.end();

Response

In case of success, an Order object is returned.


Get order history

Use this method to obtain the history of orders that meet specified criteria or the history of all orders if no parameters are defined in a request.

Request

The ts and nonce values should be specified for a request.

Query parameters:

market

The currency pair for which the orders history should be obtained (for example, btc_usdt).

side

The order side: buy or sell.

status

The current order status: Working, Rejected, Cancelled or Completed.

startDate

The date and time indicating the beginning of a required time interval: YYYY-MM-DDThh:mm:ss.s

endDate

The date and time indicating the end of a required time interval: YYYY-MM-DDThh:mm:ss.s

AscOrder

The field to be used as a criteria for sorting response data in the ascending order; any of the following fields can be specified:

  • TradeSeq

  • TradeTime

  • OrderId

  • Amount

  • Instrument

  • Side

  • ExecutionPrice

  • Commission

DescOrder

The field to be used as a criteria for sorting response data in descending order; for a list of support fields, see the AscOrder parameter description.

isHideCanceled

If true, canceled orders are not returned.

page

The number of a page listing the orders to be returned (when the perPage parameter is defined).

perPage

The number of orders to be listed on a single page

GET[base]/frontoffice/api/order_history

GET /frontoffice/api/order_history?market=btc_usdt&ts=2019-12-12T01:01:01&nonce=4 HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...
const crypto = require('crypto');
const https = require('https');
const Key = "7fa6ceec-d8fc..."; // Change to your PublicKey
const Secret = "7ae49b5b-99db..."; // Change to your Secret
const Host = "host.name"; // Change to your host name
const Payload = new Date().toISOString();
const Method = `/frontoffice/api/order_history?ts=${Payload}&market=btc_usd&nonce=4`;
async function GetOrders() {

    const Sign = crypto
        .createHmac('sha512', Secret)
        .update(`?ts=${Payload}&market=btc_usd&nonce=4`)
        .digest('hex')
        .toUpperCase();
    const options = {
        hostname: Host,
        port: Port,
        path: Method,
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
            Key,
            Sign
        }
    };
    const req = https.request(options, res => {
        console.log(`statusCode: ${res.statusCode}`);
        console.log(`statusMessage: ${res.statusMessage}`);
        res.on('data', d => {
            process.stdout.write(d);
        });
    });
    req.on('error', e => {
        console.error(e);
    });
    req.end();
}

GetOrders().catch(err => {
    console.log(err);
});

Response

In case of success, an array of Order objects meeting the specified criteria is returned.


Cancel an order

Use this method to cancel a specified market or limit order.

Request

The ts and nonce values should be specified for a request.

Path parameters:

id required

The order identifier: either orderId (the one specified in a response to a Place an order request) or clientOrderId (the one specified in the Place an order request).

DELETE[base]/frontoffice/api/orders/{id}

DELETE /frontoffice/api/orders/-72057594037927933&ts=2019-12-12T01:01:01&nonce=4 HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...
const crypto = require('crypto');
const https = require('https');
const Key = "7fa6ceec-d8fc..."; // Change to your PublicKey
const Secret = "7ae49b5b-99db..."; // Change to your Secret
const Host = "host.name"; // Change to your host name
const Payload = new Date().toISOString();
const OrderId = '-72057594037927933';
const Method = `/frontoffice/api/orders?OrderId=${OrderId}&ts=${Payload}&nonce=2`
async function deleteOrder() {
  const Sign = crypto
    .createHmac('sha512', Secret)
    .update(`?OrderId=${OrderId}&ts=${Payload}&nonce=2`)
    .digest('hex')
    .toUpperCase();
  const options = {
    hostname: Host,
    path: Method,
    port: Port,
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
      'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
      Key,
      Sign
    }
  };
  const req = https.request(options, res => {
    console.log(`statusCode: ${res.statusCode}`);
    console.log(`statusMessage: ${res.statusMessage}`);
    res.on('data', d => {
      process.stdout.write(d);
    });
  });
  req.on('error', e => {
    console.error(e);
  });
  req.end();
}
deleteOrder().catch(err => {
  console.log(err);
});

Response

In case of success, an HTTP status code is returned, indicating the request result:

  • 200 — the order has been cancelled

  • 400 — the request has not been processed due to an unexpected error

  • 404 — the order with a specified ID has not been found


Create a stop order

Use this method to place a new stop market or stop limit order on the exchange.

Note

The maximum number of active stop orders that can be placed at a time is 1000.

Request

The ts and nonce values should be specified for a request.

Body:

marketId string required

The currency pair identifier: {baseAsset}_{quoteAsset}.

orderType string required

The order type. Possible values:

  • market

  • limit

side string required

The order side: buy or sell.

requestedPrice number required

For limit orders, the sell or buy price at which the order is placed after a specified stop price (activationPrice) is reached on the market.

This value must be greater than or equal to zero.

The number of decimal places allowed for this value cannot exceed the scale value specified for the currency pair being traded.

activationPrice number required

The stop (trigger) price which the market price must hit for the order to be placed.

This value must be greater than or equal to zero.

The number of decimal places allowed for this value cannot exceed the scale value defined for the instrument being traded.

requestedAmount number required

The order amount.

This value must be greater than zero.

This amount must correspond to the amountScale and minAmount values defined for the instrument being traded.

timeInForce string required

The time-in-force rule applied to an order. Possible values:

For limit orders:

  • gtc (good-‘til-cancelled) — the order must await execution until it is cancelled explicitly or filled

For market orders:

  • ioc (immediate-or-cancel) — the order must be executed immediately, while any portion of an order that cannot be filled at once must be cancelled

  • fok (fill-or-kill) — the order must be filled immediately in its full amount or not executed at all

POST[base]/frontoffice/api/stoporders

POST /frontoffice/api/order HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...

{
  "ts": "2019-12-12T01:01:01",
  "nonce": 4,
  "order": {
    "marketId": "btc_usd",
    "orderType": "limit",
    "side": "buy",
    "requestedPrice": 100,
    "activationPrice": 100,
    "requestedAmount": 1,
    "timeInForce": "gtc"
  }
}

Response

In case of success, a Stop Order object is returned.


Get stop order history

Use this method to obtain the history of stop orders that meet specified criteria, or the history of all stop orders if no parameters are defined in a request.

Request

The ts and nonce values should be specified for a request.

Query parameters:

market

The currency pair for which the orders history should be obtained (for example, btc_usdt).

status

The current order status: WaitingForActivation, Activated or Rejected.

sort

The sorting criteria:

OrderId

The order identifier in the system.

RequestedAmount

The order amount.

RequestedPrice

For limit orders, the sell or buy price at which the order is placed after a specified stop price (activationPrice) is reached on the market.

MarketId

The currency pair identifier: {baseAsset}_{quoteAsset}.

Side

The order side: buy or sell.

GET[base]/frontoffice/api/stoporders

GET /frontoffice/api/stoporders?market=usdt_usd&status=working&sort=-orderid,%2BrequestedPrice&page=1&perPage=10 HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...

Response

In case of success, an array of Stop Order objects meeting the specified criteria is returned.


Get stop order details

Use this method to obtain detailed information about a specified stop order.

Request

The ts and nonce values should be specified for a request.

Query parameters:

id

The stop order identifier in the system.

GET[base]/frontoffice/api/stoporders/{id}

GET /frontoffice/api/stoporders/1 HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...

Response

In case of success, a specified Stop Order object is returned.


Delete a stop order

Use this method to delete a stop order.

Note

Only stop orders with the WaitingForActivation status can be deleted.

Request

The ts and nonce values should be specified for a request.

Query parameters:

id

The stop order identifier in the system.

DELETE[base]/frontoffice/api/stoporders/{id}

DELETE /frontoffice/api/stoporders/1 HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...

Response

In case of success, HTTP code 200 is returned.


Get trade history

Use this method to obtain the history of trades that meet specified criteria or the history of all trades if no parameters are defined in a request.

Request

The ts and nonce values should be specified for a request.

Query parameters:

orderId

The order identifier by which you can get information about all related trades.

market

The currency pair for which the trades history should be obtained (for example, btc_usdt)

side

The trade side: 0 — buy; 1 — sell

startDate

The date and time indicating the beginning of a required time interval: YYYY-MM-DDThh:mm:ss.s

endDate

The date and time indicating the end of a required time interval: YYYY-MM-DDThh:mm:ss.s

AscOrder

The field to be used as a criteria for sorting response data in ascending order; any of the following fields can be specified:

  • TradeSeq

  • TradeTime

  • OrderId

  • Amount

  • Instrument

  • Side

  • ExecutionPrice

  • Commission

DescOrder

The field to be used as a criteria for sorting response data in descending order; for a list of support fields, see the AscOrder parameter description.

page

The number of a page listing the trades to be returned (when the perPage parameter is defined).

perPage

The number of trades to be listed on a single page.

GET[base]/frontoffice/api/trade_history

GET /frontoffice/api/trade_history?market=btc_usdt&ts=2019-12-12T01:01:01&nonce=4 HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...
const crypto = require('crypto');
const https = require('https');
const Key = "7fa6ceec-d8fc..."; // Change to your PublicKey
const Secret = "7ae49b5b-99db..."; // Change to your Secret
const Host = "host.name"; // Change to your host name
const Payload = new Date().toISOString();
const Method = `/frontoffice/api/trade_history?ts=${Payload}&market=btc_usd&startDate=2020-01-12T01:01:01&nonce=5&ascOrder=Side`;
async function GetTrades() {

    const Sign = crypto
        .createHmac('sha512', Secret)
        .update(`?ts=${Payload}&market=btc_usd&startDate=2020-01-12T01:01:01&nonce=5&ascOrder=Side`)
        .digest('hex')
        .toUpperCase();
    const options = {
        hostname: Host,
        port: Port,
        path: Method,
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
            Key,
            Sign
        }
    };
    const req = https.request(options, res => {
        console.log(`statusCode: ${res.statusCode}`);
        console.log(`statusMessage: ${res.statusMessage}`);
        res.on('data', d => {
            process.stdout.write(d);
        });
    });
    req.on('error', e => {
        console.error(e);
    });
    req.end();
}
GetTrades().catch(err => {
    console.log(err);
});

Response

tradeSeq number

The trade sequence number.

tradeTime string

The date and time when a trade has been executed.

amount number

The trade amount.

executionPrice number

The trade execution price.

instrument string

The traded currency pair (instrument).

side number

The trade side: 0 — buy; 1 — sell.

commission number

The commission charged for a trade.

orderId number

The identifier of a related order.

RESPONSE BODY EXAMPLE
{
  "filters": {
    "market": "btc_usdt",
    "ascOrder": [
      "Side"
    ]
  },
  "paging": {
    "page": 1,
    "per_page": 15,
    "total": 1
  },
  "data": [
    {
      "tradeSeq": 0,
      "tradeTime": "2019-12-20T06:17:03.093597",
      "amount": 0.00000001,
      "executionPrice": 0.00000001,
      "instrument": "btc_usdt",
      "side": 0,
      "commission": 0.00000000,
      "orderId": -72057593704402280
    },
    {
      "tradeSeq": 3927,
      "tradeTime": "2019-12-20T06:17:03.093597",
      "amount": 0.00000001,
      "executionPrice": 0.00000001,
      "instrument": "btc_usdt",
      "side": 1,
      "commission": 0.00000000,
      "orderId": -72057593704402281
    }
  ]
}

Get user balance

Use this method to obtain up-to-date information about the total and locked amount of each asset on user balances.

Request

The ts and nonce values should be specified for a request.

No parameters.

GET[base]/frontoffice/api/balances

GET /frontoffice/api/balances HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...
const crypto = require('crypto');
const https = require('https');
const Key = "7fa6ceec-d8fc..."; // Change to your PublicKey
const Secret = "7ae49b5b-99db..."; // Change to your Secret
const Host = "host.name"; // Change to your host name
const Payload = new Date().toISOString();
const Method = `/frontoffice/api/balances?ts=${Payload}&nonce=6`;
async function GetBalances() {
  const Sign = crypto
    .createHmac('sha512', Secret)
    .update(`?ts=${Payload}&nonce=6`)
    .digest('hex')
    .toUpperCase();
  const options = {
    hostname: Host,
    port: Port,
    path: Method,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
      Key,
      Sign
    }
  };
  const req = https.request(options, res => {
    console.log(`statusCode: ${res.statusCode}`);
    console.log(`statusMessage: ${res.statusMessage}`);
    res.on('data', d => {
      process.stdout.write(d);
    });
  });
  req.on('error', e => {
    console.error(e);
  });
  req.end();
}
GetBalances().catch(err => {
  console.log(err);
});

Response

asset string

The asset name.

balance number

The total asset amount on a user’s balance.

locked number

The locked asset amount on a user’s balance.

RESPONSE BODY EXAMPLE
[
  {
    "asset": "btc",
    "balance": 10.0,
    "locked": 0.0
  },
  {
    "asset": "usdt",
    "balance": 80000.0,
    "locked": 7.0
  }
]

Get order details

Use this method to obtain detailed information about an order that is identified by a specific order ID or client order ID.

Request

The ts and nonce values should be specified for a request.

Query parameters:

orderId required

The order identifier: either orderId (the one specified in a response to a Place an order request) or clientOrderId (the one specified in the Place an order request).

GET[base]/frontoffice/api/orders

GET /frontoffice/api/orders?orderId=-72057594037927933
    &ts=2019-12-12T01:01:01
    &nonce=4 HTTP/1.1
Host: host.name

Response

In case of success, an Order object is returned.


Get data about the current user’s orders

Use this method to obtain up-to-date information about orders placed by a currently authorized user.

Request

The ts and nonce values should be specified for a request.

No parameters.

GET[base]/frontoffice/api/orders/my

GET /frontoffice/api/orders/my?ts=2019-12-12T01:01:01&nonce=4 HTTP/1.1
Host: host.name
Key: 7fa6ceec-d8fc...
Sign: 7ae49b5b-99db...

Response

In case of success, an array of Order objects meeting the specified criteria is returned.


Reference

In this section, you can find additional information about the exchange REST API:

The Order object

The following data is provided about an order:

clientOrderId number

The client order identifier.

orderId string

The order identifier in the system.

total number

The quote amount, meaning the total traded amount of a quote asset.

orderType number

The order type:

  • 0 — a limit order

  • 1 — a market IOC (immediate-or-cancel) order

  • 2 — a stop limit order (currently not supported)

  • 3 — a stop market order (currently not supported)

  • 4 — a market FOK (fill-or-kill) order

commission number

The commission charged for an order, in a quote asset.

createdAt string

The date and time when an order has been created.

unitsFilled number

The filled order amount.

isPending boolean

If true, the order is awaiting execution (it has not been rejected, cancelled or completed).

status string

The order status: Working, Rejected, Cancelled or Completed.

type string

The order side: buy or sell.

amount number

The order amount, must be greater than 0.

remaining number

The remaining order amount awaiting to be filled.

price number

Obsolete. This parameter is assigned the executionPrice value for market and stop orders, and the requestedPrice value for stop orders.

executionPrice number

The order execution price.

requestedPrice number

The requested (ask/bid) price for the order.

stopPrice number

The order stop price.

isLimit boolean

If true, indicates a limit order; if false, indicates a market order.

isFok boolean

Obsolete. If true, indicates a “fill-or-kill” order that is supposed to be executed immediately in a full amount or cancelled if not filled (see Flags combinations to learn more).

instrument string

The order instrument identifier: {baseAsset}_{quoteAsset}.

side number

The order side: 0 — buy; 1 — sell.

rejectDetails string

Detailed information about why an order has been rejected.

When calling [base]/frontoffice/api/orders methods, the following additional fields are included into order details:

updatedAt string

The date and time when an order has last been updated.

averageFillPrice number

The average order fill price.

timeInForce string

The Time in Force setting applied to an order.

THE ORDER OBJECT
{
  "order": {
    "updatedAt": "2020-06-19T11:21:30.532789",
    "averageFillPrice": "1000",
    "timeInForce": "GTC",
    "clientOrderId": "",
    "orderId": "-72057594037927934",
    "total": 100.0,
    "orderType": 0,
    "commission": 0.0001,
    "createdAt": "2020-06-19T11:21:30.532784Z",
    "unitsFilled": 0.1,
    "isPending": false,
    "status": "completed",
    "type": "buy",
    "amount": 0.1,
    "remaining": 0.0,
    "price": 1000.0,
    "executionPrice": 1000.0,
    "requestedPrice": 1000.0,
    "isLimit": true,
    "instrument": "btc_usdt",
    "side": 0,
    "rejectDetails": ""
  }
}

The Stop Order object

The following data is provided about a stop order:

orderId number

The order identifier in the system.

accountId number

The account identifier of a user who created an order.

orderType string

The order type. Possible values:

  • market

  • limit

timeInForce string

For limit orders:

  • gtc (good-‘til-cancelled) — the order must await execution until it is cancelled explicitly or filled

For market orders:

  • ioc (immediate-or-cancel) — the order must be executed immediately, while any portion of an order that cannot be filled at once must be cancelled

  • fok (fill-or-kill) — the order must be filled immediately in its full amount or not executed at all

side string

The order side: buy or sell.

requestedAmount string

The order amount.

requestedPrice string

For limit orders, the sell or buy price at which the order is placed after a specified stop price (activationPrice) is reached on the market.

activationPrice string

The stop (trigger) price which the market price must hit for the order to be placed.

marketId string

The currency pair identifier: {baseAsset}_{quoteAsset}.

createdAt string

The date and time when an order was created.

updatedAt string

The date and time when an order was last updated.

status string

The current order status. Possible values:

  • WaitingForActivation — the order is created and awaits activation

  • Activated — the order was activated and awaits execution

  • Rejected — the order was rejected

In addition, the stop order data returned for a Get stop order history or Get stop order details request may include the following information:

activatedOrderId string

For stop orders with the Activated status, the identifier of a market or limit order that has been placed upon stop order activation.

activationError string

For stop orders with the Rejected status, the reason why an order was rejected.

THE STOP ORDER OBJECT
{
  "order": {
    "orderId": 2,
    "accountId": 14090,
    "orderType": "Limit",
    "timeInForce": "Gtc",
    "side": "Buy",
    "requestedAmount": "1",
    "requestedPrice": "100",
    "activationPrice": "100",
    "marketId": "btc_usd",
    "createdAt": "2022-10-17T11:20:57.1204992Z",
    "updatedAt": "2022-10-17T11:20:57.1204996Z",
    "status": "WaitingForActivation",
  }
}

Flags combinations

In the following table, you can find information about various combinations of flags corresponding to specific order types:

Order

Description

Flags

Limit

Limit order

isLimit is true

isFok is false

Market (Market IOС)

Market order (Immediate-or-Cancel) — the order must be executed immediately, with any unfilled portion being cancelled

isLimit is false

isFok is false

Market FOK

Market order (Fill-or-Kill) — the order must be executed immediately in the full amount or cancelled

isLimit is false

isFok is true


HTTP status codes

The B2BX API uses standard HTTP response codes to indicate the success or failure of a request:

Successful responses

200 OK

The request succeeded.

201 Created

The request succeeded, and a new resource was created as a result. Typically, this response is sent after POST requests.

202 Accepted

The request was accepted for processing, but the processing will start later.

204 No Content

The request succeeded, but no response body was returned.

Error responses

400 Bad Request

The request was invalid (for example, malformed or syntactically incorrect). This status code may indicate one of the following issues:

  • The API cannot convert the payload data to the underlying data type.

  • The data is not in the expected data format.

  • Required fields are not available.

  • A data validation error occurred.

401 Unauthorized

The request didn’t include an authentication token or the token has expired.

403 Forbidden

The client didn’t have the permissions to access the requested resource.

404 Not Found

The requested resource wasn’t found because the specified URI was invalid or the requested resource was unavailable (for example, a URI pointed to an empty database).

405 Method Not Allowed

The HTTP method in the request wasn’t supported by the resource.

406 Not Acceptable

The request wasn’t completed because the server doesn’t support the requested response format.

For example, the request contained the Accept: application/xml header, but the API can only generate a response in the application/json format.

413 Payload Too Large

The request payload was too large to be processed by the server.

415 Unsupported Media Type

The request was rejected by the server because it doesn’t support the requested data format.

For example, the request contained the Content-Type: application/xml header, but the API only accepts requests in the application/json format.

429 Too Many Requests

The rate limit set for the user, application or token exceeded a predefined value.

To learn more, see API rate limits.

500 Internal Server Error

The request wasn’t completed due to an internal error on the server side.

503 Service Unavailable

The server is down for maintenance.

For a full list of valid response codes, refer to the IANA HTTP Status Code Registry.