NAV Navbar
shell

Introduction

API Introduction

Welcome to use DigiFinex ApiKey.

This is DigiFinex official API document, and will be continue updating, please follow us to get latest news.

You can switch different language by clicking language button in the top right.

Market Making Program

It is very welcome for market maker who has good market making strategy and large trading volume. Market maker who is willing to cooperate with Digifinex will get support for commission discount on trading fees(rebate), API limit rate, server resources and so on.

If you are willing to be DigiFinex market maker, you can send your email to: [email protected]

For the (spot / leverage) market maker application, provide below details:

1.UID (not linked to any rebate program in any Market Datas).

2.Screenshot of trading volume in other transaction platform (such as trading volume within 30 days, or VIP status).

3.A brief description of your market-making strategy.

Contact us

If you have any other questions on API, you can contact us by below ways:

Official Telegram: https://t.me/digifinex_api

E-mail: [email protected]

Quick Start

Digifinex API Trading Rules

In order to provide a better API trading environment, avoid malicious manipulation and disruption of the market integrity, DigiFinex hereby publish risk-control quantitative indicators and anti-manipulation rules.

Quantitative Indicators

The indicators record and calculated by all orders on certain trading pair within one time period.

Trigger Conditions

Indicator Trigger Value Trigger Condition Calculating Cycle
Filling Ratio(FR) <0.01 Number of Orders > 99 10 minutes
Filling Weight(FW) <0.01 Number of Orders > 49 10 minutes
Cancellation Ratio(CR) >0.95 Number of Orders > 99 10 minutes

Risk Control and API Ban

API Users violated any anti-manipulation rules will be banned for API trading for 30 minutes. The time will extend to 24 hours after third ban within 3 hours. During that time, banned user cannot place new order through API or creat new API key, order placement and cancellation will not be affected whatsoever.

Trading Interface List

Interface List

Permission Type Content Type Context Request Type Description Authorization
Reading Common /ping GET Server ping False
Reading Common /time GET Server timestamp False
Reading Market Data /markets GET All the market description False
Reading Market Data /ticker GET ticker price False
Reading Market Data /order_book GET Get orderbook False
Reading Market Data /trades GET Get recent trades False
Reading Market Data /kline GET Get candles data False
Reading Market Data /spot/symbols GET Spot trading pair symbol False
Reading Market Data /margin/currencies GET Currencies which support margin trading False
Reading Market Data /margin/symbols GET Margin trading pair symbol False
Reading Market interface /trades/symbols GET Whether is API trading enabled for the trading pair false
Trading Account /{market}/financelog GET Spot, margin, OTC financial logs True
Trading Account /{market}/order GET Get order status True
Trading Account ​/{market}​/order​/detail GET Get order trades details True
Trading Account /{market}/order/current GET Current active orders True
Trading Account /{market}/order/history GET Get all orders (including history orders) True
Trading Account /{market}/mytrades GET Customer's trades True
Trading Account /spot/assets GET Spot account assets True
Trading Account ​/margin​/positions GET Margin positions True
Trading Account ​/margin​/assets GET Margin assets True
Trading Account /{market}/order/new POST Create new order True
Trading Account ​/{market}​/order​/batch_new POST Create multiple order True
Trading Account /{market}/order/cancel POST Cancel order True
Trading Account /transfer POST Transfer assets among accounts True
Trading Account /margin/position/close POST Close positions True

Address

Address Applicable Sites Applicable Functions Applicable Trading Pairs
https://openapi.digifinex.com/v3 digifinex API digifinex Trading Pairs

Signature Authentication & Verification

You could create API Key in "Account - API setting".

API Key consists of the following two parts.

"Access Key", the Key used to visit API.

"Secret Key", the Key used to do Signature authentication and verification (visible during application period).

Both Access Key and Secret Key are closely related with account security, please do not disclose them to others for any reasons anytime.

API Endpoints Description:

The field contentType in request header should be: application/x-www-form-urlencoded

public Public endpoints, no signature or timestamp needed

private Private endpoints, need signature and timestamp

Signature Algorithm

Authentication

Overview

The API request may be tampered during internet, therefore all private API must be signed by your API Key (Secrete Key).

Each API Key has permission property, please check the API permission, and make sure your API key has proper permission.

Signature Method:

The signature may be different if the request text is different, therefore the request should be normalized before signing. Below signing steps take the Create New Order as an example:

  1. Create new order Parameters.

{'symbol': 'trx_usdt', 'price': 0.01, 'amount': 1, 'type': 'buy'}

  1. The parameters are URL encoded, and ordered based on ASCII

symbol=trx_usdt&price=0.01&amount=1&type=buy

  1. Use the pre-signed text and your Secret Key to generate a signature(Example: Secret:01234567890123456789abcd):

7e2d0636cab21fd41c828b8c6ce8f77e643febecdeaeab0771c01dc4d7dbef38

  1. Put ACCESS-KEY,ACCESS-TIMESTAMP,ACCESS-SIGN(Get last step) into header.

{'ACCESS-KEY': '0123456789abcd', 'ACCESS-TIMESTAMP': '1589872188', 'ACCESS-SIGN': '7e2d0636cab21fd41c828b8c6ce8f77e643febecdeaeab0771c01dc4d7dbef38'}

  1. Request Create new order url.

Method: Post

url: https://openapi.digifinex.com/v3/spot/order/new

headers: {'ACCESS-KEY': '0123456789abcd', 'ACCESS-TIMESTAMP': '1589872188', 'ACCESS-SIGN': '7e2d0636cab21fd41c828b8c6ce8f77e643febecdeaeab0771c01dc4d7dbef38'}

body: {'symbol': 'trx_usdt', 'price': 0.01, 'amount': 1, 'type': 'buy'}

Error codes

code Description
0 Success
10001 Wrong request method, please check it's a GET or POST request
10002 Invalid ApiKey
10003 Sign doesn't match
10004 Illegal request parameters
10005 Request frequency exceeds the limit
10006 Unauthorized to execute this request
10007 IP address Unauthorized
10008 Timestamp for this request is invalid
10009 Unexist endpoint or misses ACCESS-KEY, please check endpoint URL
10011 ApiKey expired. Please go to client side to re-create an ApiKey.
20002 Trade of this trading pair is suspended
20007 Price precision error
20008 Amount precision error
20009 Amount is less than the minimum requirement
20010 Cash Amount is less than the minimum requirement
20011 Insufficient balance
20012 Invalid trade type (valid value: buy/sell)
20013 No order info found
20014 Invalid date (Valid format: 2018-07-25)
20015 Date exceeds the limit
20018 Your have been banned for API trading by the system
20019 Wrong trading pair symbol, correct format:"base_quote", e.g. "btc_usdt"
20020 You have violated the API trading rules and temporarily banned for trading. At present, we have certain restrictions on the user's transaction rate and withdrawal rate.
20021 Invalid currency
20022 The ending timestamp must be larger than the starting timestamp
20023 Invalid transfer type
20024 Invalid amount
20025 This currency is not transferable at the moment
20026 Transfer amount exceed your balance
20027 Abnormal account status
20028 Blacklist for transfer
20029 Transfer amount exceed your daily limit
20030 You have no position on this trading pair
20032 Withdrawal limited
20033 Wrong Withdrawal ID
20034 Withdrawal service of this crypto has been closed
20035 Withdrawal limit
20036 Withdrawal cancellation failed
20037 The withdrawal address, Tag or chain type is not included in the withdrawal management list
20038 The withdrawal address is not on the white list
20039 Can't be canceled in current status
20040 Withdraw too frequently; limitation: 3 times a minute, 100 times a day
20041 Beyond the daily withdrawal limit
20042 Current trading pair does not support API trading
50000 Exception error

Common

Server ping

HTTP Request

Request Parameters

No parameter is available for this endpoint.

Response:


{
    "msg": "pong",
    "code": 0
}

Response Content

Field Mandatory Request Type Description
msg true string Response
code true int Status

Server timestamp

HTTP Request

Request Parameters

No parameter is available for this endpoint.

Response:


{
    "server_time": 1589873762,
    "code": 0
}

Response Content

Field Mandatory Request Type Description
server_time true int Server timestamp
code true int Status

Market Data

All the market description

HTTP Request

Request Parameters

No parameter is available for this endpoint.

Response:


{
    "data": [{
        "volume_precision": 4,
        "price_precision": 2,
        "market": "btc_usdt",
        "min_amount": 2,
        "min_volume": 0.0001
    }],
    "date": 1589873858,
    "code": 0
}

Response Content

Field Mandatory Request Type Description
data true object Trading Pair Information
volume_precision true int Volume Precision
price_precision true int Price Precision
market true string Symbol Name
min_amount true float Minimum Trading Amount
min_volume true float Minimum Trading Volume
date true int Timestamp
code true int Status

ticker price

HTTP Request

Request Parameters

Field Request Type Mandatory Description
symbol string false "btc_usdt"

Response:


{
    "ticker": [{
        "vol": 40717.4461,
        "change": -1.91,
        "base_vol": 392447999.65374,
        "sell": 9592.23,
        "last": 9592.22,
        "symbol": "btc_usdt",
        "low": 9476.24,
        "buy": 9592.03,
        "high": 9793.87
    }],
    "date": 1589874294,
    "code": 0
}

Response Content

Field Mandatory Request Type Description
ticker true object Trading Pair Information
vol true float 24h Volume
change true float 24h Change
base_vol true float 24h Amount
sell true float Ask1 Price
last true float Last Price
symbol true string Symbol Name
low true string 24h Low Price
buy true float Bid1 Price
high true float 24h High Price
date true int Timestamp
code true int Status

Get orderbook

HTTP Request

Request Parameters

Field Request Type Mandatory Description
symbol string true "btc_usdt"
limit int false Limit of depth, default 10, maximum 150

Response:


{
    "bids": [
        [9559.45, 1.3766],
        [9559.04, 0.0127],
        ..
    ],
    "asks": [
        [9563.45, 0.6312],
        [9563.34, 0.0087],
        ..
    ],
    "date": 1589874953,
    "code": 0
}

Response Content

Field Mandatory Request Type Description
bids true object Bids [price, size]
asks true object Asks [price, size]
date true int Timestamp
code true int Status

Get recent trades

HTTP Request

Request Parameters

Field Request Type Mandatory Description
symbol string true "btc_usdt"
limit int false Limit of trades returned, default 100, maximum 500

Response:


{
    "data": [{
        "date": 1589875415,
        "id": 2989995478,
        "amount": 0.001,
        "type": "buy",
        "price": 9661.05
    }, {
        "date": 1589875415,
        "id": 2989995473,
        "amount": 0.0005,
        "type": "buy",
        "price": 9659.99
    },
    ...
    ],
    "date": 1589875415,
    "code": 0
}

Response Content

Field Mandatory Request Type Description
data true object Customer's trades
date true int Timestamp
id true int Trading ID
amount true float Volume
type true str Trading Type
price true float Trading Price
code true int Status

Get candles data

HTTP Request

Request Parameters

Field Request Type Mandatory Description
symbol string true "btc_usdt"
period str true Candle timeframe type: 1,5,15,30,60,240,720,1D,1W
start_time int false Candle starting time in timestamp, default 200 period befor end_time
end_time int false Candle ending time in timestamp, default current timestamp

Get candles data by symbol, up to 500 at one time.

Response:


{
    "data": [
        [1589426100, 621.4565, 9342.7, 9349.99, 9305.86, 9307.96],
        [1589427000, 378.1678, 9333.71, 9344.25, 9318.26, 9342.23],
        ...,
    ],
    "code": 0
}

Response Content

Field Mandatory Request Type Description
data true object Candles Data[timestamp,vol,close,high,low,open],last one is most recent data
code true int Status

Spot trading pair symbol

HTTP Request

Request Parameters

No parameter is available for this endpoint.

Response:


{
  "code": 0,
  "symbol_list": [
    {
      "status": "TRADING",
      "symbol": "LTC_USDT",
      "quote_asset": "USDT",
      "base_asset": "LTC",
      "amount_precision": 4,
      "price_precision": 2,
      "minimum_amount": 0.001,
      "minimum_value": 2,
      "zone": "MAIN",
      "order_types": [
        "LIMIT",
        "MARKET"
      ]
    }
  ]
}

Response Content

Field Mandatory Request Type Description
symbol_list true object Trading Pair Information
order_types true list Trading Type
quote_asset true str Quote Asset
minimum_value true int Minimum Value
amount_precision true int Volume Precision
status true str Status
minimum_amount true float Minmum Amount
symbol true str Symbol Name
zone true str Zone
base_asset true str Base Asset
price_precision true int Price Precision
code true int Status

Currencies which support margin trading

HTTP Request

Request Parameters

No parameter is available for this endpoint.

Response:


{
  "code": 0,
  "funding_time": "GMT+8 10:00:00",
  "currencys": [
    "BTC",
    "USDT",
    "ETH",
    "XRP"
  ],
  "margin_fees": [
    {
      "currency_mark": "USDT",
      "level": 2,
      "range": "[8-14]",
      "loan_fees": 0.001
    }
  ]
}

Response Content

Field Mandatory Request Type Description
currencys true list Currencys List
margin_fees true object Margin Fees
currency_mark true str Currency
loan_fees true float Loan Fees
range true str Range
level true int Level
code true int Status
funding_time true str Funding Time

Margin trading pair symbol

HTTP Request

Request Parameters

No parameter is available for this endpoint.

Response:


{
  "code": 0,
  "symbol_list": [
    {
      "status": "TRADING",
      "symbol": "LTC_USDT",
      "quote_asset": "USDT",
      "base_asset": "LTC",
      "amount_precision": 4,
      "price_precision": 2,
      "minimum_amount": 0.001,
      "minimum_value": 2,
      "zone": "MAIN",
      "liquidation_rate": 0.3,
      "order_types": [
        "LIMIT",
        "MARKET"
      ]
    }
  ]
}

Response Content

Field Mandatory Request Type Description
symbol_list true object Margin trading pair symbol
order_types true list Trading Type
quote_asset true str Quote Asset
minimum_value true int Minimum Value
amount_precision true int Volume Precision
status true str Status
minimum_amount true float Minmum Amount
liquidation_rate true float Liquidation Rate
symbol true str Symbol Name
zone true str Zone
base_asset true str Base Asset
price_precision true int Price Precision
code true int Status

Whether is API trading enabled for the trading pair

HTTP request

Request parameters

This interface does not accept any parameters.

Response:


{
  "code": 0,
  "symbol_list": [
    {
      "status": "TRADING",
      "symbol": "LTC_USDT",
      "quote_asset": "USDT",
      "base_asset": "LTC",
      "amount_precision": 4,
      "price_precision": 2,
      "minimum_amount": 0.001,
      "minimum_value": 2,
      "zone": "MAIN",
      "is_allow": "1",
      "order_types": [
        "LIMIT",
        "MARKET"
      ]
    }
  ]
}

Return parameters

Parameters Required Type Description
symbol_list true object symbol list
order_types true list order types
quote_asset true str quote asset
minimum_value true int minimum value
amount_precision true int amount precision
status true str status
minimum_amount true float minimum_amount
symbol true str symbol
zone true str zone
base_asset true str base asset
price_precision true int price precision
code true int status
is_allow true int 1 true 0 false

Get currency deposit and withdrawal information

Search for crypto information, including deposit and withrawal service, withdrawal fees and minimum deposit amount etc.

HTTP Request

Request Parameters

Name of parameter If necessary Type Description Default Value range
currency false string cryptocurrency By default, the default value is null and returns to all crptos btc, ltc, bch, eth, etc ...

Response:

{
  "code": 200,
  "data":
    [
      {
        "currency": "xrp",
        "chain":"",
        "min_deposit_amount": 0.01,
        "min_withdraw_amount": 0.02,
        "deposit_status":1,
        "withdraw_status":1,
        "withdraw_fee_currency":"eth",
        "min_withdraw_fee":0.006,
        "withdraw_fee_rate":0.02,
      },
      ...
    ]
}

Response Content

Name of parameter If necessary Data type Description Value range
currency true string currency
chain true string chain name The chain name is empty by default, and USDT has two chains: ERC20 and OMNI
min_deposit_amount true float minimum deposit
min_withdraw_amount true float minimum withdrawal
deposit_status true int deposit status: 1 is on, 0 is off
withdraw_status true int withdrawal status: 1 is on, 0 is off
withdraw_fee_currency true string The currency of withdrawal fee
min_withdraw_fee true float Minimum withdrawal fee
withdraw_fee_rate true float Percentage of withdrawal fee. Note: if the actual fee is less than the minimum fee, it will be charged according to minimum fee; Otherwise, it will be charged according to the actual fee.

Status code

Status code error message Error scenario description
200 success success

Account

Spot account assets

HTTP Request

Request Parameters

No parameter is available for this endpoint.

Response:


{
  "code": 0,
  "list": [
    {
      "currency": "BTC",
      "free": 4723846.89208129,
      "total": 0
    }
  ]
}

Response Content

Field Mandatory Request Type Description
list true object Account List
currency true string Currency Name
free true float Free
total true float Total
code true int Status

Margin assets

HTTP Request

Request Parameters

No parameter is available for this endpoint.

Response:


{
  "code": 0,
  "total": 0,
  "free": 0,
  "unrealized_pnl": 0,
  "list": [
    {
      "currency": "BTC",
      "free": 4723846.89208129,
      "total": 0
    }
  ]
}

Response Content

Field Mandatory Request Type Description
list true object Account List
currency true string Currency Name
free true float Free
total true float Total
code true int Status

Spot, margin, OTC financial logs

HTTP Request

Request Parameters

market:spot, margin

Field Request Type Mandatory Description
market str true "spot","margin"
currency_mark str false
start_time int false
end_time int false
limit int false Default 100, maximum 1000

Response:


{
  "code": 0,
  "total": 0,
  "free": 0,
  "unrealized_pnl": 0,
  "list": [
    {
      "currency": "BTC",
      "free": 4723846.89208129,
      "total": 0
    }
  ]
}

Response Content

Field Mandatory Request Type Description
list true object Account List
currency true string Currency Name
free true float Free
unrealized_pnl true float Unrealized Profit and Loss
total true float Total
code true int Status

Get order status

HTTP Request

Request Parameters

market:spot, margin

Field Request Type Mandatory Description
market str true "spot","margin"
order_id str true Order ID list, separated by commas, limit of 20

Response:


{
  "code": 0,
  "data": [
    {
      "symbol": "BTC_USDT",
      "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
      "created_date": 1562303547,
      "finished_date": 0,
      "price": 0.1,
      "amount": 1,
      "cash_amount": 1,
      "executed_amount": 0,
      "avg_price": 0,
      "status": 1,
      "type": "buy",
      "kind": "margin"
    }
  ]
}

Response Content

Field Mandatory Request Type Description
data true object Order Status List
symbol true string Symbol Name
order_id true string Order ID
created_date true int Created Time
finished_date true int Finished Time
price true float Price
amount true float Volume
cash_amount true float Cash amount of orders, 0 for none order
executed_amount true float Amount been executed
avg_price true float Average price of amount been executed
status true int Order status, 0 for none executed, 1 for partially executed, 2 for fully executed, 3 for cancelled with none executed, 4 for cancelled with partially executed
type true string buy for limit buy order, sell for limit sell order, buy_market for market buy order, sell_market for market sell order
kind true string spot, margin
code true int Status

Get order trades details

HTTP Request

Request Parameters

market:spot, margin

Field Request Type Mandatory Description
market str true "spot","margin"
order_id str true Order ID

Response:


{
  "code": 0,
  "data": {
    "symbol": "BTC_USDT",
    "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
    "created_date": 1562303547,
    "finished_date": 1574665459,
    "price": 6000,
    "amount": 0.58,
    "cash_amount": 0,
    "executed_amount": 0.58,
    "avg_price": 6000,
    "status": 2,
    "type": "buy",
    "kind": "margin",
    "detail": {
      "tid": 63194988,
      "date": 1574665459,
      "executed_amount": 0.58,
      "executed_price": 6000
    }
  }
}

Response Content

Field Mandatory Request Type Description
data true object Order Status List
symbol true string Symbol Name
order_id true string Order ID
created_date true int Created Time
finished_date true int Finished Time
price true float Price
amount true float Volume
cash_amount true float Cash amount of orders, 0 for none order
executed_amount true float Amount been executed
avg_price true float Average price of amount been executed
status true int Order status, 0 for none executed, 1 for partially executed, 2 for fully executed, 3 for cancelled with none executed, 4 for cancelled with partially executed
type true string buy for limit buy order, sell for limit sell order, buy_market for market buy order, sell_market for market sell order
kind true string spot, margin
detail true object Order Detail
tid true int Trading ID
date true int Trading Time
executed_amount true float Trading Volume
executed_price true float Trading Price格
code true int Status

Current active orders

HTTP Request

Request Parameters

market:spot, margin

Field Request Type Mandatory Description
market str true "spot","margin"
symbol str false Symbol Name

Response:


{
  "code": 0,
  "data": [
    {
      "symbol": "BTC_USDT",
      "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
      "created_date": 1562303547,
      "finished_date": 0,
      "price": 0.1,
      "amount": 1,
      "cash_amount": 1,
      "executed_amount": 0,
      "avg_price": 0,
      "status": 1,
      "type": "buy",
      "kind": "margin"
    }
  ]
}

Response Content

Field Mandatory Request Type Description
data true object Current Active Orders List
symbol true string Symbol Name
order_id true string Order ID
created_date true int Created Time
finished_date true int Finished Time
price true float Price
amount true float Volume
cash_amount true float Cash amount of orders, 0 for none order
executed_amount true float Amount been executed
avg_price true float Average price of amount been executed
status true int Order status, 0 for none executed, 1 for partially executed, 2 for fully executed, 3 for cancelled with none executed, 4 for cancelled with partially executed
type true string buy for limit buy order, sell for limit sell order, buy_market for market buy order, sell_market for market sell order
kind true string spot, margin
code true int Status

Get all orders (including history orders)

HTTP Request

Request Parameters

market:spot, margin

Field Request Type Mandatory Description
market str true "spot","margin"
symbol str false Symbol Name
limit int false Default 10, maximum 100
start_time int false Starting time, default 3 days before now, maximum 30 days
end_time int false Ending time, default current timestamp

Response:


{
  "code": 0,
  "data": [
    {
      "symbol": "BTC_USDT",
      "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
      "created_date": 1562303547,
      "finished_date": 0,
      "price": 0.1,
      "amount": 1,
      "cash_amount": 1,
      "executed_amount": 0,
      "avg_price": 0,
      "status": 1,
      "type": "buy",
      "kind": "margin"
    }
  ]
}

Response Content

Field Mandatory Request Type Description
data true object Order History List
symbol true string Symbol Name
order_id true string Order ID
created_date true int Created Time
finished_date true int Finished Time
price true float Price
amount true float Volume
cash_amount true float Cash amount of orders, 0 for none order
executed_amount true float Amount been executed
avg_price true float Average price of amount been executed
status true int Order status, 0 for none executed, 1 for partially executed, 2 for fully executed, 3 for cancelled with none executed, 4 for cancelled with partially executed
type true string buy for limit buy order, sell for limit sell order, buy_market for market buy order, sell_market for market sell order
kind true string spot, margin
code true int Status

Customer's trades

HTTP Request

Request Parameters

market:spot, margin

Field Request Type Mandatory Description
market str true "spot","margin"
symbol str false Symbol Name
limit int false Default 50, maximum 500
start_time int false Starting time, default 3 days before now, maximum 30 days
end_time int false Ending time, default current timestamp

Response:


{
  "code": 0,
  "list": [
    {
      "symbol": "BTC_USDT",
      "order_id": "6707cbdcda0edfaa7f4ab509e4cbf966",
      "id": 28457,
      "price": 0.1,
      "amount": 0,
      "fee": 0.096,
      "fee_currency": "USDT",
      "timestamp": 1499865549,
      "side": "buy",
      "is_maker": true
    }
  ]
}

Response Content

Field Mandatory Request Type Description
list true object Customer's trades List
symbol true string Symbol Name
order_id true string Order ID
id true int Trading ID
price true float Trading Price
amount true float Volume
fee true float Fee
fee_currency true string Fee Currency
timestamp true int Timestamp
side true string Trading Type,buy,sell,buy_market,sell_market
is_maker true bool maker or taker
code true int Status

Margin positions

HTTP Request

Request Parameters

Field Request Type Mandatory Description
symbol str false Symbol Name

Response:


{
  "code": 0,
  "margin": "20",
  "margin_rate": 1,
  "unrealized_pnl": "55",
  "positions": [
    {
      "symbol": "BTC_USDT",
      "leverage_ratio": "3.0",
      "side": "long",
      "amount": "3.0",
      "entry_price": "40",
      "unrealized_pnl": "55",
      "liquidation_price": "25.999999999999996",
      "liquidation_rate": "0.3"
    }
  ]
}

Response Content

Field Mandatory Request Type Description
margin true str Margin
margin_rate true int Margin Rate
unrealized_pnl true str Unrealized Profit and Loss
positions true object Positions
symbol true string Symbol Name
leverage_ratio true float Leverage Ratio
side true string long, short, empty for none position
amount true float Amount in position
entry_price true float Entrance price of position
unrealized_pnl true float Unrealized Profit and Loss
liquidation_price true float Estimated liquidation price
liquidation_rate true float liquidation leverage ratio
code true int Status

Create new order

HTTP Request

Request Parameters

market:spot, margin

Field Request Type Mandatory Description
market str true "spot","margin"
symbol str true Symbol Name
type str true buy for limit buy order, sell for limit sell order, buy_market for market buy order, sell_market for market sell order
amount float true Order amount, value in quote currency for market orders and base currency in other order types
price float false Order price required for limit order
post_only int false Default 0, enabled by 1, if enabled the order will be cancelled if it can be executed immediately, making sure there will be no market taking

Response:


{
  "code": 0,
  "order_id": "198361cecdc65f9c8c9bb2fa68faec40"
}

Response Content

Field Mandatory Request Type Description
order_id true str Order ID
code true int Status

Create multiple order

HTTP Request

Request Parameters

market:spot, margin up to 10 orders at a time, either all succeed or all fail

Field Request Type Mandatory Description
market str true "spot","margin"
symbol str true Symbol Name
list str true order list, must be json-format, eg:[{"type":"buy","amount":0.1,"price":6000,"post_only":1},{"type":"sell","amount":0.1,"price":6100,"post_only":0}]

Response:


{
  "code": 0,
  "order_ids": [
    "198361cecdc65f9c8c9bb2fa68faec40",
    "3fb0d98e51c18954f10d439a9cf57de0"
  ]
}

Response Content

Field Mandatory Request Type Description
order_ids true object Order ID列表
code true int Status

Cancel order

HTTP Request

Request Parameters

market:spot, margin

Field Request Type Mandatory Description
market str true "spot","margin"
order_id str true Order ID list, separated by commas

Response:


{
  "code": 0,
  "success": [
    "198361cecdc65f9c8c9bb2fa68faec40",
    "3fb0d98e51c18954f10d439a9cf57de0"
  ],
  "error": [
    "78a7104e3c65cc0c5a212a53e76d0205"
  ]
}

Response Content

Field Mandatory Request Type Description
success true object Cancel Success Orders
error true object Cancel Failed Orders
code true int Status

Transfer assets among accounts

HTTP Request

Request Parameters

Transfer assets among, 1 for spot account, 2 for margin account, 3 for OTC account Please be noted transfers between margin account and OTC account is currently not available

Field Request Type Mandatory Description
currency_mark str true Currency
num str true Transfer amount
from int true Transfer from, 1 for spot account, 2 for margin account, 3 for OTC account
to int true Transfer to, 1 for spot account, 2 for margin account, 3 for OTC account

Response:


{
  "code": 0
}

Response Content

Field Mandatory Request Type Description
code true int Status

Close positions

HTTP Request

Request Parameters

说明:以市场价格平掉仓位

Field Request Type Mandatory Description
symbol str true Symbol Name

Response:


{
  "code": 0
}

Response Content

Field Mandatory Request Type Description
code true int Status

Deposit address inquiry

This node is used to query the address of a specific currency

HTTP request

curl "https://openapi.digifinex.com/v3/deposit/address?currency=btc"

Request parameters

fieldname if necessary types fieldname value range
currency true string crypto btc, ltc, bch, eth, etc ...

Response:

{
    "code": 200,
    "data": [
        {
            "currency": "btc",
            "address": "1PSRjPg53cX7hMRYAXGJnL8mqHtzmQgPUs",
            "addressTag": "",
            "chain": ""
        }
    ]
}

Response data

fieldname if necessary data type field description value range
currency true string currency
address true string deposit address
addressTag true string deposit address lable
chain true string the chain name is empty by default, and USDT has two chains: ERC20 and OMNI

Status code

status code error message Error scenario description
200 success success

Deposit history

Query the deposit history

HTTP request

Request parameters

name of parameter if necessary type description default value value range
currency false string currency By default, the default value is null and returns to all crptos btc, ltc, bch, eth, etc ...
from false int query initial ID By default, the default value is direct correlation. When direct is' prev ', from is 1, returning from old to new ascending order; When direct is' next ', from is the ID of the most recent record, returning from the old descending order
size false int Query record size 100 1-500
direct false string Returns to the sorting direction of the record By default, it is "prev" (ascending) "Prev" (ascending) or "next" (descending)

Response:

{
  "code": 200,
  "data":
    [
      {
        "id": 1171,
        "currency": "xrp",
        "hash": "ed03094b84eafbe4bc16e7ef766ee959885ee5bcb265872baaa9c64e1cf86c2b",
        "chain":"",
        "amount": 7.457467,
        "address": "rae93V8d2mdoUQHwBDBdM4NHCMehRJAsbm",
        "state": 3,
        "created_date": "2020-04-20 11:23:00",
        "finished_date": "2020-04-20 13:23:00"
      },
      ...
    ]
}

response data

response Data if neccesary data type description value range
id true long
currency true string currency
hash true string transaction hash
chain true string chain name The chain name is empty by default, and USDT has two chains: ERC20 and OMNI
amount true float amount
address true string address
state true int state deposit state includes: 1 (in deposit), 2 (to be confirmed), 3 (successfully deposited), 4 (stopped)
created_date true string created date
finished_date true string finished date

Status code

status code error message error scenario description
200 success success

Withdrawal history

Query the withdrawal history

HTTP request

Request parameters

name of parameter if neccesary type description default value value range
currency false string currency By default, the default value is null and returns all currencies btc, ltc, bch, eth, etc ...
from false string query initial ID By default, the default value is direct correlation. When direct is' prev ', from is 1, returning from old to new ascending; When direct is' next ', from is the ID of the most recent record, returned from the old descending order
size false string query record size 100 1-500
direct false string Return to the sorting direction of the record By default, it is "prev" (ascending) "Prev" (ascending) or "next" (descending)

Response:

{
  "code": 200,
  "data":
    [
      {
        "id": 1171,
        "currency": "xrp",
        "hash": "ed03094b84eafbe4bc16e7ef766ee959885ee5bcb265872baaa9c64e1cf86c2b",
        "chain": "",
        "amount": 7.457467,
        "address": "rae93V8d2mdoUQHwBDBdM4NHCMehRJAsbm",
        "memo": "100040",
        "fee": 0,
        "state": "safe",
        "created_date": "2020-04-20 11:23:00",
        "finished_date": "2020-04-20 13:23:00"
      },
      ...
    ]
}

Response data

name of parameter if neccesary data type description value range
id true long
currency true string currency
hash true string transaction hash
chain true string chain name
amount true float amount
address true string address
memo true string address lable
fee true float fee Withdrawal status includes: 1 (application in progress), 2 (to be confirmed), 3 (completed),4 (rejected)
created_date true string created date
finished_date true string date of latest update

Status code

status code error message error scenario description
200 success success

Request withdrawal

API must be tied to IP in order to have access to withdrawal, and the withdrawal address must be in the white list of the withdrawal address set by the user

HTTP request

{
 "currency": "eth",
  "chain": "",
  "address": "0xde709f2102306220921060314715629080e2fb77",
  "amount": "0.05",
  "memo": "",
}

Request parameters

name of parameter if neccesary type description value range
type true false withdraw type normal or internal, default normal
currency true string asset crypto btc, ltc, bch, eth, etc ...
chain false string chain type USDT required (ERC20 or OMNI), other cryptos empty
address true string withdrawal address or uid (if internal) Must be in the white list of withdrawal addresses set by the user
amount true float withdrawal amount
memo false string withdrawal tag,applicable to xrp,xem,bts,steem,eos,xmr string

Response:

{
  "code": 200,
  "withdraw_id": 700
}

Response data

name of parameter if neccesary data type description value range
withdraw_id true long withdrawal ID

Status code

status code error message error scenario description
200 success success

Cancel withdrawal

HTTP request

Request parameters

name of parameter if neccesary type description default value Value range
withdraw_id true long Fill withdrawal ID in path

Response:

{
  "code": 200,
  "withdraw_id": 700
}

Response data

name of parameter if neccesary data type description value range
withdraw_id true long withdrawal ID

Status code

status code error message error scenario description
200 success success

Sample Code

PHP


<?php

class digifinex
{
  protected $baseUrl = "https://openapi.digifinex.com/v3";    
  protected $appKey;
  protected $appSecret;

  public function __construct($data) {
      $this->appKey = $data['appKey'];
      $this->appSecret = $data['appSecret'];
  }

  private function calc_sign($data = []) {
      $query = http_build_query($data, '', '&');
      $sign = hash_hmac("sha256", $query, $this->appSecret);
      echo 'query: ' . $query . "\r\n";
      echo 'sign: ' . $sign . "\r\n";
      return $sign;
  }

  public function do_request($method, $path, $data = [], $needSign=false) {
      $curl = curl_init();
      $query = http_build_query($data, '', '&');
      if ($method == "POST") {
          curl_setopt($curl, CURLOPT_URL, $this->baseUrl . $path);
          curl_setopt($curl, CURLOPT_POST, true);
          curl_setopt($curl, CURLOPT_POSTFIELDS, $query);
      } else {
          if(!empty($data)){
              curl_setopt($curl, CURLOPT_URL, $this->baseUrl . $path . '?' . $query);
          } else {
              curl_setopt($curl, CURLOPT_URL, $this->baseUrl . $path);
          }
      }
      if($needSign){
          curl_setopt($curl, CURLOPT_HTTPHEADER, array(
              'ACCESS-KEY: ' . $this->appKey,
              'ACCESS-TIMESTAMP: ' . time(),
              'ACCESS-SIGN: ' . $this->calc_sign($data),
          ));
      }
      curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17");
      curl_setopt($curl, CURLOPT_HEADER, false);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_TIMEOUT, 10);
      $content = curl_exec($curl) ;
      curl_close($curl);
      return $content;
  }
}

$coin = new digifinex([
  'appKey' => 'your-api-key',
  'appSecret' => 'your-api-secret',
]);

echo 'assets => ' . $coin->do_request('GET', '/margin/assets', [], true) . "\r\n";
echo 'place_order => ' . $coin->do_request('POST', '/margin/order/new', [
  'symbol' => 'btc_usdt',
  'price' => 5000,
  'amount' => 0.01,
  'type' => 'buy',
], true) . "\r\n";

JS


var https = require('https');
var crypto = require('crypto')
var querystring = require('querystring');

const baseUrl = "openapi.digifinex.com"
const appKey = "your-api-key"
const appSecret = "your-api-secret"

calc_sign = function(data) {
  var content = querystring.stringify(data);
  return crypto.createHmac('sha256', appSecret).update(content).digest('hex')
}

do_request = function(method, path, data = {}, needSign = false) {
  var content = querystring.stringify(data);
  var options = {
      hostname: baseUrl,
      port: 443,
      path: '/v3' + path,
      method: method,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17',
      }
  };
  if (method == "GET" && content != "") {
      options.path += '?' + content;
  }
  if (needSign) {
      options.headers['ACCESS-KEY'] = appKey;
      options.headers['ACCESS-TIMESTAMP'] = parseInt(Date.now() / 1000);
      options.headers['ACCESS-SIGN'] = calc_sign(data);
  }
  console.log('request: ' + JSON.stringify(options));
  var req = https.request(options, function (res) {
      console.log('STATUS: ' + res.statusCode);
      console.log('HEADERS: ' + JSON.stringify(res.headers));
      res.setEncoding('utf8');
      res.on('data', function (chunk) {
          console.log('BODY: ' + chunk);
      });
  });
  req.on('error', function (e) {
      console.log('problem with request: ' + e.message);
  });
  if (method != 'GET') {
      req.write(content);
  }
  req.end();
}

do_request('GET', '/margin/symbols', {}, false)
do_request('POST', '/margin/order/new', {
  symbol: 'btc_usdt',
  price: 5000,
  amount: 0.01,
  type: 'buy',
}, true)

Python


#!/bin/python
# -*-coding=utf-8-*-

import requests
import time
import hmac
import hashlib
import urllib

baseUrl = "https://openapi.digifinex.com/v3"

class digifinex():
    def __init__(self, data):
        self.appKey = data["appKey"]
        self.appSecret = data["appSecret"]

    def _generate_accesssign(self, data):
        query_string = urllib.urlencode(data)
        m = hmac.new(self.appSecret.encode('utf-8'), query_string.encode('utf-8'), hashlib.sha256)
        s = m.hexdigest()
        print("data-origin:", data)
        print("query_string:", query_string)
        print("sign:", s)
        return s

    def do_request(self, method, path, data, needSign=False):
        if needSign:
            headers = {
                "ACCESS-KEY": self.appKey,
                "ACCESS-TIMESTAMP": str(int(time.time())),
                "ACCESS-SIGN": self._generate_accesssign(data),
            }
        else:
            headers = {}
        if method == "POST":
            response = requests.request(method, baseUrl+path, data=data, headers=headers)
        else:
            response = requests.request(method, baseUrl+path, params=data, headers=headers)
        print('response.text:',response.text)
        print('----------------------------------')

coin = digifinex({"appKey":"your-api-key", "appSecret":"your-api-secret"})
coin.do_request("POST", "/margin/order/new", {
    "symbol": "btc_usdt",
    "price": 5000,
    "amount": 0.01,
    "type": "buy"
}, True)

GO


package main

import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)

const (
dfxRestURI = "https://openapi.digifinex.com/v3"
)

type digifinex struct {
appKey         string
appSecret      string
deafultTimeout time.Duration
}

func parseToString(val interface{}) string {
switch t := val.(type) {
case int, int8, int16, int32, int64:
  return fmt.Sprintf("%d", t)
case uint, uint8, uint16, uint32, uint64:
  return fmt.Sprintf("%d", t)
case float32, float64:
  return fmt.Sprintf("%.8f", t)
case string:
  return t
default:
  panic(fmt.Errorf("invalid value type", t))
}
}

func hmacSha256(key []byte, msg []byte) string {
mac := hmac.New(sha256.New, key)
mac.Write(msg)
return hex.EncodeToString(mac.Sum(nil))
}

func (coin *digifinex) doRequest(method string, path string, params map[string]interface{}, sign bool) (*http.Response, error) {
inputParam := url.Values{}
for key, val := range params {
  inputParam.Add(key, parseToString(val))
}
encodedParams := inputParam.Encode()
var (
  req *http.Request
  err error
)
if method == "GET" {
  if encodedParams != "" {
    req, err = http.NewRequest(method, dfxRestURI+path+"?"+encodedParams, nil)
  } else {
    req, err = http.NewRequest(method, dfxRestURI+path, nil)
  }
} else {
  req, err = http.NewRequest(method, dfxRestURI+path, strings.NewReader(encodedParams))
}
if err != nil {
  return nil, fmt.Errorf("unable to create request " + err.Error())
}
// header
req.Header.Add("ACCESS-TIMESTAMP", strconv.Itoa(int(time.Now().Unix())))
if sign {
  req.Header.Add("ACCESS-KEY", coin.appKey)
  req.Header.Add("ACCESS-SIGN", hmacSha256([]byte(coin.appSecret), []byte(encodedParams)))
  fmt.Println(req.Header.Get("ACCESS-SIGN"))
}
client := &http.Client{
  Transport: &http.Transport{},
  Timeout:   coin.deafultTimeout,
}
resp, err := client.Do(req)
if err != nil {
  return nil, err
}
return resp, nil
}

const (
appKey    = "your-api-key"
appSecret = "your-api-secret"
)

func main() {
app := digifinex{
  appKey:    appKey,
  appSecret: appSecret,
}
response, err := app.doRequest("POST", "/spot/order/new", map[string]interface{}{
  "symbol": "btc_usdt"
  "type": "buy",
  "amount": 1,
  "price": "8100",
  "post_only": 0,
}, true)
if err != nil {
  panic(err)
}
textRes, err := ioutil.ReadAll(response.Body)
if err != nil {
  panic(err)
}
defer response.Body.Close()
if response.StatusCode != 200 {
  panic(fmt.Errorf(string(textRes)))
}
fmt.Println(string(textRes))
}

Websocket

Websoket API

For Websoket API see https://github.com/DigiFinex/api/blob/master/Websocket_API_en.md