Digitex Rest Trading API (0.0.1)

Download OpenAPI specification:Download

Sergiy Pavlyuk: spavlyuk@digitex.io License: MIT License

Digitex's REST trading api specification

In order to start, one has to register either at https://testnet.digitexfutures.com for testnet (virtual funds trading) or at https://digitex.io - our mainnet (real money trading).

After registration you need to obtain your trading token in your account.

Direct links to the account page:

If you have already created your token, you can simply copy it, else click on "Create" in the API section of your account.

IMPORTANT NOTES!

  • All of the data which is expected to be float or decimal are passed as strings. Data is converted into Decimal/float format on the client level
  • All timestamps are in microseconds UTC
  • Enums, such as order types, status etc can be found in Exchange-Meta-Data group of endpoints

Authentication

TradersToken

Trader's token should be place in the header of the request, e.g.:
{"Authorization": "Token 4321532asfasdf31453245234adsadsf"}

Security Scheme Type API Key
Header parameter name: Authorization

Public

Currencies

Returns list of currencies that are available to use in the wallet

Authorizations:
query Parameters
currency_id
integer

Optional query parameter to return single currency info, if empty returns list of available currencies

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/currency/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    }
]

Ping

Utility endpoint to ping the server, If "pong" is in the response, then the service is working properly. Additionally there is a timestamp value of servers's internal time. Note all times are in UTC

Authorizations:

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/ping',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "timestamp": 1234598990003,
  • "datetime": "2021-09-19 17:18:44.820400",
  • "message": "pong"
}

Order book

Returns exchange's order book for selected market

Authorizations:
query Parameters
market_id
required
integer
Examples:
  • market_id=2 -

market_id

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/order_book/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "ticker_id": 24,
  • "timestamp": 1632230927428280,
  • "bids": [
    ],
  • "asks": [
    ]
}

List of recent trades done at the market

Authorizations:
query Parameters
max_trades
integer

Limit maximum number of recent trades. Default limit is 1000

market_id
required
integer
Examples:
  • market_id=1 -

market id

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/recent_trades/',
  qs: {max_trades: 'SOME_INTEGER_VALUE', market_id: 'SOME_INTEGER_VALUE'},
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "market_id": 1,
  • "timestamp": 1625037107016692,
  • "recent_trades": [
    ]
}

OHLCV

Returns open high low close volume aggregated data for selected market and timeframe.

In any case returns max 1k datapoints. Optionally datapoints can be filtered with date_from and date_to parameters

Available timeframes (resolutions):

  • daily (D or 1D, 2D ... )
  • weekly (1W, 2W ...)
  • monthly (1M, 2M...)
  • minutes (1, 2 ...).
Authorizations:
query Parameters
date_from
integer

Unix timestamp (UTC) of the leftmost required bar, including from.

date_to
integer

Unix timestamp (UTC) of the rightmost required bar, including to. It can be in the future. In this case, the rightmost required bar is the latest available bar.

market_id
required
integer

int market_id

top_n
integer

number of records ohlcv, default 10000

resolution
required
string

Symbol resolution. Possible resolutions are daily (D or 1D, 2D ... ), weekly (1W, 2W ...), monthly (1M, 2M...) and an intra-day resolution – minutes(1, 2 ...).

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/history/ohlcv/',
  qs: {
    date_from: 'SOME_INTEGER_VALUE',
    date_to: 'SOME_INTEGER_VALUE',
    market_id: 'SOME_INTEGER_VALUE',
    top_n: 'SOME_INTEGER_VALUE',
    resolution: 'SOME_STRING_VALUE'
  },
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "market_id": 24,
  • "resolution": "1D",
  • "timestamp": 1632476201371805,
  • "ohlcv": [
    ]
}

Exchange information

This endpoint returns all metadata for the exchange, such as:

  • traders ratelimits. сurrently this is not strictly enforced, however rate limits can be applied individually if the trader abuses the API
  • notifications. This field will contain all notifications/announcements from the exchnage. Please note, these are not system notifications.
  • servertime - server's Unix timestamp in microseconds.
  • currencies
  • markets
  • order types enum values (LIMIT/MARKET)
  • time in force / order duruation enum values (e.g Good till funding, Good till cancelled)
  • order_sides enum values (But/Sell)
  • order_positions enum values(Long/Short)
  • order_status (Pending, Accepted, Filled, etc)
Authorizations:

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/exchange_info/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "rate_limits": [
    ],
  • "notifications": [ ],
  • "server_time": 1632229225740173,
  • "currencies": [
    ],
  • "markets": [
    ],
  • "order_meta": {
    }
}

Markets

Get list of markets

Authorizations:
query Parameters
market_id
integer

Optional query to return just one market_id

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/markets/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • {
    }
]

Returns available list of currency pairs

Authorizations:

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/currency_pair/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • {
    }
]

Exchange-Meta-Data

Currencies

Returns list of currencies that are available to use in the wallet

Authorizations:
query Parameters
currency_id
integer

Optional query parameter to return single currency info, if empty returns list of available currencies

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/currency/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    }
]

Exchange information

This endpoint returns all metadata for the exchange, such as:

  • traders ratelimits. сurrently this is not strictly enforced, however rate limits can be applied individually if the trader abuses the API
  • notifications. This field will contain all notifications/announcements from the exchnage. Please note, these are not system notifications.
  • servertime - server's Unix timestamp in microseconds.
  • currencies
  • markets
  • order types enum values (LIMIT/MARKET)
  • time in force / order duruation enum values (e.g Good till funding, Good till cancelled)
  • order_sides enum values (But/Sell)
  • order_positions enum values(Long/Short)
  • order_status (Pending, Accepted, Filled, etc)
Authorizations:

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/exchange_info/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "rate_limits": [
    ],
  • "notifications": [ ],
  • "server_time": 1632229225740173,
  • "currencies": [
    ],
  • "markets": [
    ],
  • "order_meta": {
    }
}

Markets

Get list of markets

Authorizations:
query Parameters
market_id
integer

Optional query to return just one market_id

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/markets/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • {
    }
]

Returns available list of currency pairs

Authorizations:

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/currency_pair/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • {
    }
]

Private

Place an order

Authorizations:
Request Body schema: application/json
market_id
integer <int32>

market id, can be found in markets instance

side
integer (OrderSide)
Enum: "0" "1" "2"

Order sides

UNDEFINEd - 0  
BUY - 1
SELL - 2
type
integer (OrderType)
Enum: "1" "2"

Order types

1 - LIMIT
2 - MARKET
duration
integer (OrderDuration)
Enum: "0" "1" "2" "3" "4" "5"

Duration of the order

UNDEFINED - 0
GFD - 1
GTC - 2
GTF - 3
IOC - 4
FOK - 5
leverage
integer <int32>

Leverage of the trades, only valid for futures market and will be ignored for spot

quantity
string

quantity of the order. If you are trading futures, this is - amount of contracts.

for spot - it depends on your side.

price
string

price of the orders

client_id
string

user generated uidid. it is optional, the backend will generate one if nothing is provided

Responses

Request samples

Content type
application/json
{
  • "id": "986ca2aa-9f21-4a90-87f0-692b88c92bdf",
  • "market_id": 24,
  • "side": 1,
  • "type": 2,
  • "duration": 2,
  • "leverage": 1,
  • "quantity": 1234,
  • "price": 0.0038
}

Response samples

Content type
application/json
{
  • "id": "986ca2aa-9f21-4a90-87f0-692b88c92bdf",
  • "market_id": 24,
  • "trader_id": 12354,
  • "side": 1,
  • "type": 2,
  • "duration": 2,
  • "leverage": 1,
  • "quantity": 1234,
  • "price": 0.0038
}

Order history

Includes orders that are no longer active. These are orders that have the following status:

  • FILLED - numerical status 5. Order has been fully filled
  • CANCELLED - numerical status 4. Order has been cancelled by user. Note partially filled order can be cancelled as well
  • REJECTED - numerical status 3. Order has been rejected by matching engine.

All query parameters are optional.

Authorizations:
query Parameters
created_at_from
integer <int64>
Examples:
  • created_at_from=2020-04-01T13:37:39.867Z -

Timestamp in microseconds. Filters for order created at or after this timestamp

created_at_to
string
Examples:
  • created_at_to=2020-04-02T13:37:39.867Z -

Timestamp in microseconds. Filters for orders created before this timestamp

cursor
string
Examples:
  • cursor=qweJKFA31rnkjASFALKhl1324 -

cursor for fetching pages

market_id
integer
Examples:
  • market_id=2 -

Id of a market

page_size
integer
Examples:
  • page_size=30 -

Amount of order displayed per page

status
integer
Examples:
  • status=2 -

orders status

trader_id
number
Examples:
  • trader_id=2 -

Id of a users trader

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/order_history/',
  qs: {
    created_at_from: 'SOME_INTEGER_VALUE',
    created_at_to: 'SOME_STRING_VALUE',
    cursor: 'SOME_STRING_VALUE',
    market_id: 'SOME_INTEGER_VALUE',
    page_size: 'SOME_INTEGER_VALUE',
    status: 'SOME_INTEGER_VALUE',
    trader_id: 'SOME_NUMBER_VALUE'
  },
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "next": "cD0yMDIxLTA4LTIwKzEyJTNBNDYlM0ExOC40Mjg3ODclMkIwMCUzQTAw",
  • "results": [
    ]
}

Order status

Get status of orders by query params

Authorizations:
query Parameters
client_id
required
string
Examples:
  • client_id=d3c32cc8-89b7-4a4a-8847-7a255e7739ad -

uuid of the order

trader_id
integer
Examples:
  • trader_id=3 -

optional trader's id. Works in case user has several trading accounts

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/order_status/',
  qs: {client_id: 'SOME_STRING_VALUE', trader_id: 'SOME_INTEGER_VALUE'},
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • {
    }
]

All orders

Open orders are orders that have not been fully filled yet.

These are order with order_status:

  • PENDING - numerical status 1 - the order has been recieved, however not yet accepted by the exchange matching engine
  • ACCEPTED - numerical status 2 - the order has been recieved, validated and accepted by the exchange matching engine
  • PARTIAL - numerical status 6 - ACCEPTED + partially filled. Partial filled information and remaining volume are part of the open order information

Orders can be filtered with any of the query parameters. No query parameters means all open orders.

Authorizations:
query Parameters
status
integer
  • ACCEPTED (2) - order has been accepted for execution by matching engine
  • PENDING (1) - order has been recieved, however not yet accepted
  • PARTIAL (6) - order has been only partially filled
cursor
string
Examples:
  • cursor=cD0yMDIxLTA4LTE4KzE1JTNBMjQlM0EwOS43OTczMTUlMkIwMCUzQTAw -

Cursor for fetching. Pagination

market_id
integer
Examples:
  • market_id=2 -

id of a market

page_size
integer
Examples:
  • page_size=50 -

Size of a paginator page

side
integer
Examples:
  • side=1 -

Filter by order side

trader_id
integer
Examples:
  • trader_id=2 -

Id of a trader

type
integer
Examples:
  • type=3 -

MARKET = 1 LIMIT = 2

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/orders/',
  qs: {
    status: 'SOME_INTEGER_VALUE',
    cursor: 'SOME_STRING_VALUE',
    market_id: 'SOME_INTEGER_VALUE',
    page_size: 'SOME_INTEGER_VALUE',
    side: 'SOME_INTEGER_VALUE',
    trader_id: 'SOME_INTEGER_VALUE',
    type: 'SOME_INTEGER_VALUE'
  },
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "next": "cD0yMDIxLTA4LTIwKzEyJTNBNDYlM0ExOC40Mjg3ODclMkIwMCUzQTAw",
  • "results": [
    ]
}

Trade history

Get trade history of a trader

Authorizations:
query Parameters
traded_at_from
integer <int64>
Examples:
  • traded_at_from=1632234345216613 -

Timestamp in microseconds

traded_at_to
integer <int64>
Examples:
  • traded_at_to=1632234345216613 -

Timestamp in microseconds. Only return contracts traded before this time.

cursor
string
Examples:
  • cursor=cD0yMDIxLTA4LTE4KzE1JTNBMjQlM0EwOS43OTczMTUlMkIwMCUzQTAw -

Cursor for fetching pages in pagination

market_id
integer
Examples:
  • market_id=2 -

Id of a market

page_size
integer

size of a paginator page

trader_id
integer
Examples:
  • trader_id=2 -

optional trader id

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/trade_history/',
  qs: {
    traded_at_from: 'SOME_INTEGER_VALUE',
    traded_at_to: 'SOME_INTEGER_VALUE',
    cursor: 'SOME_STRING_VALUE',
    market_id: 'SOME_INTEGER_VALUE',
    page_size: 'SOME_INTEGER_VALUE',
    trader_id: 'SOME_INTEGER_VALUE'
  },
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "next": "cD0yMDIxLTA3LTIwKzEwJTNBMjglM0EzNS4yNTI3OTMlMkIwMCUzQTAw",
  • "results": [
    ]
}

Order update

Authorizations:
Request Body schema: application/json
client_id
required
string

order's client_id

duration
required
integer (OrderDuration)
Enum: "0" "1" "2" "3" "4" "5"

Duration of the order

UNDEFINED - 0
GFD - 1
GTC - 2
GTF - 3
IOC - 4
FOK - 5
leverage
required
integer

desired leverage for margin trades

market_id
required
integer

market id

price
required
string

Desired price of an order

quantity
required
string

quantity of an order

side
required
integer (OrderSide)
Enum: "0" "1" "2"

Order sides

UNDEFINEd - 0  
BUY - 1
SELL - 2
type
required
integer (OrderType)
Enum: "1" "2"

Order types

1 - LIMIT
2 - MARKET

Responses

Request samples

Content type
application/json
{
  • "client_id": "3877a30e-6acb-49f5-a101-5c46656cd8a5",
  • "duration": 1,
  • "leverage": 1,
  • "market_id": 1,
  • "price": "51000.000000000000000000",
  • "quantity": "1.000000000000000000",
  • "side": 2,
  • "type": 2
}

Response samples

Content type
application/json
{
  • "timestamp": 1566818724722,
  • "client_order_id": "90d26126-3b65-4274-9ecb-3365a54b0975",
  • "order_id": "e76163a9-142d-43fa-b0d6-27c690b73676",
  • "qty": 1,
  • "exec_qty": 1,
  • "avg_price": 0,
  • "quantity": 1,
  • "market_id": 1,
  • "price": 48000,
  • "reduce_only": false,
  • "side": 1,
  • "status": 2,
  • "stop_price": 50000,
  • "time_in_force": 1,
  • "type": 2
}

Cancel order

Authorizations:
Request Body schema: application/json

to cancel an order(s) - send list of cliet_id(s) and the market for which you want to close orders, you can close orders only for one market at a time

to cancel all order(s) by market - send only market_id

to cancel all orders - send empty body

market_id
integer <int32>

market_id

orders_client_ids
Array of strings

list of cliend_ids to cancel

Responses

Request samples

Content type
application/json
{
  • "market_id": 1,
  • "orders_client_ids": [
    ]
}

Response samples

Content type
application/json
{
  • "market_id": 1,
  • "orders_client_ids": [
    ]
}

Trader position

Authorizations:

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/position/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    }
]

Balances

Getting balances

Authorizations:

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://testnet.digitexfutures.com/dapi/v1/exchange/bot/balances/',
  headers: {Authorization: 'REPLACE_KEY_VALUE'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
[
  • [
    ]
]