Navbar
Chinese
shell

Introduction

API Introduction

Welcome to the BKEX Global API!

This document is the only official documentation for BKEX Global API, and the capabilities provided by BKEX GlobalAPI will be continuously updated here. Please pay attention to it in time.

You can switch document languages by clicking on the language button at the top right.

On the right side of the document are examples of request parameters and response results.

Update your subscription

BKEX Global will notify you of API additions, updates, downlines, and other information in advance through announcements.

You can click on here view announcement.

Contact Us

If you have any questions or suggestions during the use, you can choose any of the following ways to contact us:

Quick Start

Access preparation

If you want to use the API, please log in to the web terminal, complete the API key application and permissions configuration, and then develop and trade according to the document details.

You can click on here to create API key。

Each account can create up to five Api Keys, and each Api Key can be used to set up three types of access rights: Read, Trade and Withdraw.

The competencies are described below:

Be sure to remember the following information after successful creation:

Interface type

BKEX Global provides users with two interfaces, allowing you to choose the appropriate method for checking quotes, trading or withdrawing cash, depending on your usage scenario and preferences.

REST API

REST, which stands for Representational State Transfer, is a popular HTTP-based communication mechanism, where each URL represents a resource.

One-time operations such as transactions or asset withdrawals are recommended to developers using the REST API.

WebSocket API

WebSocket is a new protocol in HTML5. It implements full-duplex communication between client and server, with a simple handshake you can establish a client-server connection. The server can proactively push information to clients based on business rules.

It is recommended that developers use the WebSocket API to obtain information on market conditions and buying and selling depths.

interface authentication

Both types of interfaces include public and private interfaces.

The public interface can be used to obtain basic information and quotes data. The public interface can be used without authentication.

The private interface can be used for transaction management and account management. Each private request must be signed using your API Key for signature verification.

Access URLs

You can compare the latency on your own using the api.bkex.io and api.bkex.com domains. Select the low latency for use.

REST API

https://api.bkex.io (recommend)

https://api.bkex.co

https://api.bkex.com

Websocket Feed

wss://api.bkex.io (recommend)

wss://api.bkex.co

wss://api.bkex.com

Signature authentication

Signature note

API requests can be tampered with during transmission over the internet. To ensure that requests are not altered, private interfaces other than the public ones (Base Information, Quote Data) must use your API Key. Encryption is done to verify that the parameter or parameter value has not changed during transmission.
Each API Key needs to have the appropriate permissions to access the appropriate interface, and each newly created API Key Permissions need to be assigned. Before using an interface, review the permission types for each interface and make sure your API Key has the appropriate permissions.

What is required for a legitimate request:

Encryption method

Specification of requests to calculate signatures Because when using HMAC for signature calculations, calculating with different content can result in Completely different. So before you perform the signature calculation, please normalize the request. The following is an example of a request for an order detail.

Order Request URL

https://api.bkex.co/v2/u/order/create?volume=0.12&direction=ASK&price=7126.4285&symbol=BTC_USDT

Sort the parameters in ASCII order

direction=ASK&price=7126.4285&symbol=BTC_USDT&volume=0.12

The ranked request parameters are encrypted with HMAC SHA256 using secretKey.

550ac73ace8c34372e0e1dd6631e890c7bd16697af8bb4e2908e966b50aba4e0

Constructing an http request using

  1. Use the X_ACCESS_KEY header to store access key information.
  2. Use the X_SIGNATURE header to store the generated signature information.

Then send an http request

Enumeration definition

Trading pair

A trading pair consists of the base currency and the quoted currency. Take the trading pair BTC_USDT for example, BTC is the base currency and USDT is the quoted currency.

Accounts

Different accounts are required for different operations

Account types include:

Order and transaction related ID description

Order Type

Direction of buying and selling:

Order type:

Query order sorting rules:

Order Status

Access Description

Interface Overview

. . .
Interface Classification Category Links Overview
Basics /v2/common/* Basic class interface, including currency, pair and other interfaces
Quotes /v2/q/* Public quote class interface, including transaction, depth, quotes, etc.
Account Classes /v2/u/account/* Account class interface, including account information, etc.
Wallet class /v2/u/wallet/* Wallet withdrawals, deposit and withdrawal records
Order Class /v2/u/order/* Order class interface, including placing orders, withdrawals, order inquiries, deal inquiries, etc.

Frequency limit rules

For example:

Request Format

There are currently only two methods: GET and POST

Return Format

All interfaces are in JSON format. There are three fields at the top of JSON: msg, code and data. The first two fields represent the request status and information, the actual business data is in the data field .

Here is an example of a return format:

{
  "msg": "success",
  "code": "0",
  "data": // per API response data in nested JSON object
}
. .
Parameter Name Data Types Description
msg string API information returned
code int Interface status returned, 0 represents success
data object Interface returns data subject

Error Code

Error Code Description
75 Incorrect trade priceSpread
76 Incorrect trade order priceSpread precision
77 Incorrect request param
1005 Not Enough balance
1801 Amount too small
1931 Quantity of ordering exceeds the limit
2002 Trading pair error
2025 Trading direction error
2027 The trading pair is not currently open for orders
2031 The number of precision not correct
2033 The trading pair is not currently open for BID orders
2034 This trading pair is not open for BID orders
2035 The trading pair is not currently open for ASK orders
2036 This trading pair is not open for ASK orders
2037 Please make trade after some time
2041 Price should be empty for market order
2042 The stop-limit orders of the trading pair exceeds the limit
2043 The total of stop-limit orders exceeds the limit
6006 Visit too frequently. Please try again later
7019 Cannot find order, cannot cancel
7020 You can not cancel the order now

Sample code

github sample code

Basic Information

Get all pairs

.

This interface returns all symbols supported by BKEX Global.

curl "https://api.bkex.co/v2/common/symbols"
            

HTTP requests

Request Parameters

This interface does not accept any parameters.

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "symbol": "BTC_USDT",
      "supportTrade": true,
      "volumePrecision": 4,
      "pricePrecision": 4,
      "minimumTradeVolume": 0.001
    },
    {
      "symbol": "ETH_USDT",
      "supportTrade": false,
      "volumePrecision": 4,
      "pricePrecision": 4,
      "minimumTradeVolume": 0.01
    }
  ]
}

Return field

.
Field names Data Types Description
symbol string Trading pair
supportTrade boolean Whether or not the transaction is supported
volumePrecision integer Precision (number of decimal places) of the number of orders placed for a transaction
pricePrecision integer Accuracy of trade to order price (decimal places)
minimumTradeVolume decimal Minimum number of orders placed in previous currency pairs

Get all currencies

This interface returns all currencies supported by BKEX Global.

curl "https://api.bkex.co/v2/common/currencys"
            

HTTP request

Request Parameters

This interface does not accept any parameters.

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "currency": "ETH",
      "maxWithdrawOneDay": 2000,
      "maxWithdrawSingle": 2000,
      "minWithdrawSingle": 0.1,
      "supportDeposit": true,
      "supportTrade": true,
      "supportWithdraw": true,
      "withdrawFee": 0.008
    },
    {
      "currency": "BTC",
      "maxWithdrawOneDay": 100,
      "maxWithdrawSingle": 100,
      "minWithdrawSingle": 0.01,
      "supportDeposit": true,
      "supportTrade": true,
      "supportWithdraw": true,
      "withdrawFee": 0.008
    }
  ]
}

Return field

.
Field names Data Types Description
currency string Currency
maxWithdrawOneDay decimal Same day maximum withdrawal limit
maxWithdrawSingle decimal Maximum limit for single withdrawal
minWithdrawSingle decimal Minimum number of withdrawals in a single transaction
supportDeposit boolean Whether or not to support deposit
supportTrade boolean Whether or not to support trade
supportWithdraw boolean Whether or not to support withdrawal
withdrawFee decimal Withdrawal fees

Get the server timestamp

.

This interface returns the server's current timestamp. That is, the total number of milliseconds from 00:00:00:0 milliseconds on January 1, 1970 UTC to the present.

curl "https://api.bkex.co/v2/common/timestamp"
            

HTTP request

Request Parameters

This interface does not accept any parameters.

Response:

{
    "code": 0,
    "data": 1588652674630,
    "msg": "success"
}

Return field

Field names Data Types Description
data long Timestamp

quotes data

K-line data (candlestick)

This interface returns historical K-line data.

HTTP requests

curl "https://api.bkex.co/v2/q/kline?period=1m&size=200&symbol=BTC_USDT&from=1529739295000&to=1532331295000"

Request Parameters

. . .
Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA Trading pair BTC_USDT
period string false 1m Returns the data time granularity, which is the time interval for each candle1m, 5m, 15m, 30m, 1h, 4h, 6h, 12h, 1d, 1w
from long true NA The start timestamp in milliseconds1529739295000
to long true NA The end timestamp in milliseconds 1532331295000
size integer false 500 The number of K-line data bars[1, 1000]

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "symbol": "BTC_USDT",
      "volume": 12321.1234,
      "open": 4124.3,
      "close": 3873.213,
      "low": 3521.1,
      "high": 4521.5,
      "quoteVolume": 71031537.978665,
      "ts": 1529739295000
    }
  ]
}

Response data

.
Field names Data Types Description
symbol string Trading pair
volume decimal Transaction volume in base currency
open decimal Opening price for this phase
close decimal Closing price for the period
low decimal Lowest price at this stage
high decimal Highest price at this stage
quoteVolume decimal Volumes in quoted currencies
ts long Time stamp of Singapore time in milliseconds

24-hour trade statistics

This interface provides the last 24 hours of pair market information.

HTTP requests

curl "https://api.bkex.co/v2/q/tickers?symbol=BTC_USDT"

request parameter

Parameters Data Types Is it necessary Default values Description Range of values
symbol string false NA Trading pair BTC_USDT,ETH_USDT...

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "symbol": "BTC_USDT",
      "close": 7145.0407,
      "open": 7145.0407,
      "high": 7145.0407,
      "low": 7145.0407,
      "volume": 3124.1231,
      "quoteVolume": 23131.847291,
      "change": 0.12,
      "ts": 1529739295000
    }
  ]
}

Response data

Field names Data Types Description
symbol string Trading pair
volume decimal Transaction volume in base currency
open decimal Opening price for this phase
close decimal Last price at this stage
quoteVolume decimal Lowest price at this stage
high decimal Highest price at this stage
vol decimal Volumes in quoted currencies
change decimal 24-hour ups and downs
ts long Time stamp of Singapore time in milliseconds

Last sale price

This interface provides trading pairs with the latest current transaction prices

HTTP requests

curl "https://api.bkex.co/v2/q/ticker/price?symbol=BTC_USDT"

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string false NA Trading pair BTC_USDT,ETH_USDT...

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "symbol": "BTC_USDT",
      "price": 7145.0407
    }
  ]
}

Response data

Field names Data Types Description
symbol string Trading pair
price decimal Current Transaction Prices

Trade pair order book

This interface returns the current depth data for the specified trading pair.

HTTP requests

curl "https://api.bkex.co/v2/q/depth?symbol=BTC_USDT&depth=20&precision=4"
            

Request Parameters

Parameters Data Types Must Default values Description Range of values
symbol string true NA Trading pair BTC_USDT
depth integer false 50 Number of depths returned [1-50]
precision integer false Trading Pair Default Accuracy Price Accuracy [1-10]

Response:

{
  "msg": "success",
  "code": "0",
  "data": {
    "bid": [
      [7964, 0.0678], // [Price, quantity]
      [7963, 0.9162],
      ...
    ],
    "ask": [
      [7979, 0.0736],
      [7980, 1.0292],
      ...
    ]
  }
}

Response data

Field names Data Types Description
bid object All current buy orders [price, volume]
ask object All current sell orders [price, volume]

Recent Transaction History

This interface returns the latest transaction record of the specified pair.

HTTP requests

curl "https://api.bkex.co/v2/q/deals?symbol=BTC_USDT&size=20"
            

Request Parameters

Parameters Data Types Is it necessary Default values Description
symbol string true NA BTC_USDT
size integer false NA [1-50]

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "symbol": "BTC_USDT",
      "price": 7145.0407,
      "volume": 0.5344,
      "direction": "B",
      "ts": 1529739295000
    }
  ]
}

Response data

Field names Data Types Description
symbol string Trading pair
volume decimal Volume in Base Currencies
price decimal Traded price in quoted currency
direction string Trade Direction: "B" or "S", "B" is Buy, "S" is Sell
ts long Time stamp of Singapore time in milliseconds
>

Account Related

API Key Permission Information

Query the permission information for the current API Key

HTTP request

Request Parameters

This interface does not accept any parameters.

Response:

{
  "msg": "success",
  "code": "0",
  "data": {
    "asset": true,
    "contract": true,
    "contractType": 1,
    "deal": true,
    "endTime": 1591537150000
  }
}

response data

.
Parameter Name Data Types Examples Description
asset boolean true Whether or not assets (wallet accounts, fiat currency accounts) are searchable
deal boolean true Whether you can make a trade using this API key
contract boolean true Whether to enable contract-related permissions
contractType integer 1 Contract Permissions (0: Query, 1: Query and Trade)

Account Balance

API Key Permissions: Read

Check the balance of a given currency or all of them, wallet and OTC account support

HTTP requests

Request Parameters

Parameter Name Is it necessary Type Description Default values Range of values
currencys false string Currency NA BTC,ETH...

Response:

{
  "msg": "success",
  "code": "0",
  "data": {
    "WALLET": [
      {
        "currency": "BTC",
        "available": "0.1",
        "frozen": "0.1",
        "total": "0.2"
      },
      {
        "currency": "USDT",
        "available": "1.2",
        "frozen": "0",
        "total": "1.2"
      }
    ]
  }
}

Response data

Field names Data Types Description
WALLET string Wallet account type, WALLET/OTC/GENERAL

Fields in the account

Field names Data Types Description
currency string Currency
available decimal Available balance
frozen decimal Frozen balance
total decimal Full balance

Top-ups and withdrawals

Deposit Address Lookup

API Key Permissions: Read

HTTP requests

curl "https://api.bkex.co/v2/u/wallet/address?currency=ETH"
            

Request Parameters

Field names Is it necessary Type Field Description Range of values
currency true string Currency ETH,BTC...

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "currency": "BTC",
      "address": "1m4k2yUKTSrX6SM9FGgvwMybAbYtRVi2N",
      "memo": ""
    }
  ]
}

Response Data

Field names Data Types Field Description
currency string Currency
address string Deposit Address
memo string Deposit Address Labels

Recharge Record

API Key Permissions: Read

Checking Recharge Record

HTTP requests

Request Parameters

.
Parameter Name Is it necessary Type Description Default values Range of values
currency true string Currency BTC
from false long Beginning timestamp, in milliseconds 1532331295000
to false long End timestamp, in milliseconds 1532331295000
Size false integer Query record size 10 10-100
page false integer Number of pages 1

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "id": "117121312313",
      "currency": "BTC",
      "hash": "6ea95a124371c685e000b968ace1c024f2d67bf73a97b43cf94ab6572fa529",
      "volume": 0.1234,
      "fromAddress": "1LMhQnpvwiiRSn2NPPxaQLVyBzdGcXvi",
      "toAddress": "1LMhQnpvwiiRSn2NPPxaQLVyBzdGcXvi",
      "confirmed": 3,
      "state": 0,
      "createTime": 1532331295000
    }
  ]
}

Response data

.
Parameter Name Data Types Description
id string Business ID
currency string Currency
hash string Exchange Hash
volume decimal Number of pieces
fromAddress string Beginning address
toAddress string Top-up Address
confirmed integer Certainties
state integer Status
createTimelong Initiation time
Status Description
-1 Failure
0 Acknowledged
3 Confirmation in progress

Withdraw records

.

API Key Permissions: Read

Check your cash withdrawal history

HTTP requests

Request Parameters

.
Parameter Name Is it necessary Type Description Default values Range of values
currency false string Currency BTC
from false long Beginning timestamp, in milliseconds 1532331295000
to false long Timestamp 1532331295000
Size false integer Query record size 10 10-100
page false integer Number of pages 1

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "id": "117121312313",
      "currency": "BTC",
      "hash": "6ea95a124371c685e000b968ace1c024f2d67bf73a97b43cf94ab6572fa529",
      "volume": 0.1234,
      "fromAddress": "1LMhQnpvwiiRSn2NPPxaQLVyBzdGcXvi",
      "toAddress": "1LMhQnpvwiiRSn2NPPxaQLVyBzdGcXvi",
      "fee": 0.0001,
      "state": 0,
      "createTime": 1532331295000
    }
  ]
}

Response Data

.
Parameter Name Data Types Description
id string Business ID
currency string Currency
hash string Exchange Hash
volume decimal Number of pieces
fromAddress string Beginning address
toAddress string Top-up Address
fee decimal Number of fees
state integer Status
createTimelong Initiation time
Status Description
-1 Failure
0 Acknowledged
1 Submitted
2 Cancelled
5 Awaiting confirmation
>

Spot trading

Order

.

API Key Permissions: Transactions

Send a new order

HTTP request

{
  "volume": 0.1,
  "price": 7000.12,
  "direction": "ASK",
  "symbol": "BTC_USDT",
  "source": "WALLET",
  "type": "STOP_LIMIT",
  "stopPrice": 6900,
  "operator": "gte",
}

Request Parameters

Parameter Name Data Types Is it necessary Default values Description
symbol string true NA BTC_USDT
volume decimal true NA Number of orders placed
price decimal false NA Order price
direction string true NA Direction of order, ASK, BID
source string false WALLET Order source account, default is wallet account (bar account will be supported later)
type string false LIMIT Order type, which can be (LIMIT, MARKET, STOP_LIMIT)
stopPrice decimal false NA Stop-limit Order Trigger Price
operator string false NA Stop-limit order trigger price operator gte - greater than and equal (>=), lte - less than and equal (<=)

Response:

{
  "code": 0,
  "msg": "Create Order Successfully",
  "data": "20180623123334234234"
}

Response data

code is 0, which means the order is successful, and the returned data object is the order number after the order is successful.

Cancel Order

API Key Permissions: Transactions

This interface sends a request to cancel the order.

HTTP requests

Request Parameters

Parameter Name Is it necessary Type Description
orderId true string Order ID

Response:

{
  "code": 0,
  "msg": "success",
  "data": "201908231244212312123"
}

Response Data

code is 0, which means the cancellation was successful, and data returns the order Id

Query the current unfinished order

.

API Key Permissions: Read

{
   "symbol": "BTC_USDT",
   "direction": "ASK",
   "source": "WALLET",
   "type": "LIMIT",
   "sortingWay": "TIME_ASC",
   "page": 1,
   "size": 10
}

HTTP requests

Request Parameters

Parameter Name Data Types Is it necessary Default values Description
symbol string true NA Trade pair, BTC_USDT
direction string false NA Specify orders that return only one direction, sell as ASK, buy as BID
source string false WALEET Order Source Account Type
type string false NA Order Type
sortingWay string false NA Sorting rules, with values (TIME_ASC, TIME_DESC, PRICE_ASC, PRICE_DESC)
page integer false 1 Query page number
Size integer false 10 Returns the number of orders, maximum 100.

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "id": "201806232342422123123",
      "symbol": "BTC_USDT",
      "type": "STOP_LIMIT",
      "totalVolume": 1.123,
      "price": "7000.3241",
      "direction": "ASK",
      "dealVolume": 0.1,
      "frozenVolumeByOrder": 1.123,
      "source": WALLET,
      "stopPrice": 6900,
      "operator": ">=",
      "status": 0,
      "createdTime": 1530604762277

    }
  ]
}

Response data

. .
Field names Data Types Description
id string Order id
symbol string Trading pair, e.g. BTC_USDT
price string Order price
createdTimelong Time stamp of order creation time in milliseconds
type string Order Type
totalVolume decimal Total number of orders placed
direction string Order Direction
dealVolume decimal Number traded
frozenVolumeByOrder decimal Frozen quantity of orders placed
source string Order Source Account Type
stopPrice decimal Stop-limit Order Trigger Price
operator string Stop-limit Order Operator
status string 0: Pending orders, 1: Completed, 2: Cancelled, 3: Partially filled

Query Unfinished Order Details

API Key Permissions: Read

HTTP request

Request Parameters

Parameter Name Data Types Is it necessary Default values Description
orderId string true NA Order ID

Response:

{
  "msg": "success",
  "code": "0",
  "data":{
      "id": "201806232342422123123",
      "symbol": "BTC_USDT",
      "type": "STOP_LIMIT",
      "totalVolume": 1.123,
      "price": "7000.3241",
      "direction": "ASK",
      "dealVolume": 0.1,
      "frozenVolumeByOrder": 1.123,
      "source": "WALLET",
      "stopPrice": 6900,
      "operator": ">=",
      "status": 0,
      "createdTime": 1530604762277,
      "updateTime": 1530604762277
    }
}

Response data

. . . . .
Field names Data Types Description
id string Order id
symbol string Trading pair, e.g. BTC_USDT
price string Order price
createdTimelong Time stamp of order creation time in milliseconds
type string Order Type
totalVolume decimal Total number of orders placed
direction string Order Direction
dealVolume decimal Number traded
frozenVolumeByOrder decimal Frozen quantity of orders placed
source string Order Source Account Type
stopPrice decimal Stop-limit Order Trigger Price
operator string Stop-limit Order Operator
status string 0: Pending, 3: Partially Sold
createdTimelong Pending order time
updateTimelong Last updated

Query history orders

API Key Permissions: Read

{
   "symbol": "BTC_USDT",
   "direction": "ASK",
   "type": "LIMIT",
   "sortingWay": "TIME_ASC",
   "filterCancelAll": true,
   "page": 1,
   "size": 10,
   "startTime": 1532331295000,
   "endTime": 1532331295000
            }

HTTP requests

Request Parameters

?
Parameter Name Data Types Is it necessary Default values Description
symbol string true NA Trade pair, BTC_USDT
direction string false NA Specify orders that return only one direction, sell as ASK, buy as BID
type string false NA Order Type
sortingWay string false NA Sorting rules, with values (TIME_ASC, TIME_DESC, PRICE_ASC, PRICE_DESC)
filterCancelAll boolean false NA Does it filter orders that are not filled at all
page integer false 1 Query page number
Size integer false 10 Returns the number of orders, maximum 100.
startTime long false NA Beginning time stamp in milliseconds
endTime long false NA Cut-off time stamp in milliseconds

Response:

{
  "msg": "success",
  "code": "0",
  "data": [
    {
      "id": "201806232342422123123",
      "symbol": "BTC_USDT",
      "type": "STOP_LIMIT",
      "totalVolume": 1.123,
      "price": "7000.3241",
      "direction": "ASK",
      "dealVolume": 0.1,
      "frozenVolumeByOrder": 1.123,
      "dealAvgPrice": 2341,
      "source": "WALEET",
      "stopPrice": 6900,
      "operator": ">=",
      "createdTime": 1530604762277,
      "updateTime": 1530604762277,
      "status": 0
    }
  ]
}

Response data

. . . .
Field names Data Types Description
id string Order id
symbol string Trading pair, e.g. BTC_USDT
price string Order price
type string Order Type
totalVolume decimal Total number of orders placed
direction string Order Direction
dealVolume decimal Number traded
frozenVolumeByOrder decimal Frozen quantity of orders placed
dealAvgPrice decimal Average transaction price
source decimal Order Source Account Type
stopPrice decimal Stop-limit Order Trigger Price
operator string Stop-limit Order Operator
createdTimelong Time stamp of order creation time in milliseconds
updateTimelong Time stamp of the last modification time of the order in milliseconds
status string 1: completed, 2: withdrawn

Batch order

API Key Permissions: Transactions

Up to 20 orders in a batch


[
  {
   "volume": 0.1,
   "price": 7000.12,
   "direction": "ASK",
   "symbol": "BTC_USDT",
   "source": "WALLET",
   "type": "STOP_LIMIT",
   "stopPrice": "6900",
   "operator": "lte"
   },
   "volume": 0.1,
   "price": 7000.12,
   "direction": "ASK",
   "symbol": "BTC_USDT",
   "source": "WALEET",
   "type": "STOP_LIMIT",
   "stopPrice": "6900",
   "operator": "lte"
  }
]

HTTP requests

Request Parameters

Parameter Name Is it necessary Type Description Default values Range of values
orders true string JSON format string

Response:

{
  "code":0,
  "msg": "success",
  "data":
   {
    "success": 2,
    "fail": 0,
    "results": ["2019062312313131231","2019063123131312313"]
   }
}

Response Data

.
Parameter Name Data Types Description
success integer Number of successes
fail integer Number of failures
results string Sets of successful order numbers

Batch order cancellation

API Key Permissions: Transactions

.

This interface sends cancellation requests for multiple orders (based on id) at the same time.

HTTP requests


[
    "2018062321121231231","2018062321121231232"
]
        

Request Parameters

Parameter Name Is it necessary Type Description Default values Range of values
orders true string JOSN format string, order ID set:["2018062321121231231"] , "2018062321121231231"]

Response:

{
  "code": 0,
  "msg": "success",
  "data":
   {
    "success": 2,
    "fail": 0,
    "results": ["2019062312313131231"]," 2019063123131312313"]
   }
}

Response Data

.
Parameter Name Data Types Description
success integer Number of successes
fail integer Number of failures
results string A collection of order numbers for successful order cancellation

Contract transaction

Explanation of key parameters

side

Direction of the transaction

BUY_OPEN: open long position

SELL_CLOSE: close long positions

SELL_OPEN: open empty position

BUY_CLOSE: open short position

priceType

Price type

INPUT: The system will use the price you enter to set up the order.

OPPONENT: Orders will be placed at the best price on the opponent market. If you open 10 more contracts and the best bid is 10 and the best ask is 11, you will place 10 orders at the following price For 11 contract orders. If the number of orders is less than 10 contracts traded, the rest will remain in the market.

QUEUE: Orders will be matched at the best price in the same direction. If you open 10 contracts long, and the best bid is 10 and the best ask is 11, you will place 10 contracts at 10. Orders. Let's say the market originally had 5 buy orders of 10, and with the order you placed there is now a total of 15 buy orders of 10

Over: Orders will be matched at the best price + over-price (floating) of the opposing order. Suppose you open 10 contracts long and the best bid is 10 and the best ask is 11 (the overshoot is now 3), you will place 10 contracts. (11 + 3 =) 14 of the buy orders. If the number of orders is less than 10 traded, the rest will remain in the market.

MARKET: Orders will be matched at the last traded price * (1 ± 5%). Let's say you open 10 contracts long and the latest traded price is 10, you would place 10 (10*1.05=)10.5 of a buy order.

timeInForce

Types of aging sheets

GTC: Stays in effect until cancelled. The order will remain in effect until cancelled.

IOC: Fill or Kill immediately. Orders will be filled for as much volume as possible at the best available price, the order may be partially filled and the remainder will be automatically filled. Withdrawn.

FOK: Filled in full or cancelled. Orders will either be filled in full at a best available price or simply cancelled.

LIMIT_MAKER: If the order will be filled immediately, the order will be cancelled.

orderType

Order Types

LIMIT: The order will be filled at a given (or better) price

.

STOP: The order will be triggered once the price reaches the triggerPrice

.

Public Information Interface

Broker transaction information (contract)

API Key permissions: no signature required

Get information about the current broker's trading rules and contract symbols (precision units and other information), including the contract's risk limits and multipliers

HTTP request


curl "https://api.bkex.co/v2/contract/common/brokerInfo"
        

Request Parameters

No parameters

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
    "timezone": "UTC",
    "serverTime": "1570701444309",
    "brokerFilters": [],
    "rateLimits": [
      {
        "rateLimitType": "ORDERS",
        "interval": "SECOND",
        "limit": 20
      },
      {
        "rateLimitType": "ORDERS",
        "interval": "DAY",
        "limit": 350000
      },
      {
        "rateLimitType": "REQUEST_WEIGHT",
        "interval": "MINUTE",
        "limit": 1500
      }
    ],
    "contracts": [
      {
        "filters": [
          {
            "minPrice": "0.01",
            "maxPrice": "100000.00000000",
            "tickSize": "0.01",
            "filterType": "PRICE_FILTER"
          },
          {
            "minQty": "1",
            "maxQty": "100000.00000000",
            "stepSize": "1",
            "filterType": "LOT_SIZE"
          },
          {
            "minNotional": "0.000001",
            "filterType": "MIN_NOTIONAL"
          }
        ],
        "exchangeId": "301",
        "symbol": "BTC-SWAP",
        "symbolName": "BTC-SWAP",
        "status": "TRADING",
        "baseAsset": "BTC-SWAP",
        "baseAssetPrecision": "1",
        "quoteAsset": "USDT",
        "quoteAssetPrecision": "0.01",
        "icebergAllowed": false,
        "inverse": true,
        "index": "BTCUSDT",
        "marginToken": "TBTC",
        "marginPrecision": "0.00000001",
        "contractMultiplier": "1.0",
        "riskLimits": [
          {
            "riskLimitId": "200000001",
            "quantity": "1000000.0",
            "initialMargin": "0.01",
            "maintMargin": "0.005"
          },
          {
            "riskLimitId": "200000002",
            "quantity": "2000000.0",
            "initialMargin": "0.02",
            "maintMargin": "0.01"
          },
          {
            "riskLimitId": "200000003",
            "quantity": "3000000.0",
            "initialMargin": "0.03",
            "maintMargin": "0.015"
          },
          {
            "riskLimitId": "200000004",
            "quantity": "4000000.0",
            "initialMargin": "0.04",
            "maintMargin": "0.02"
          }
        ]
      }
    ]
  }
}

Response Data

. .
Parameter Name Data Types Examples Description
timezone string UTC Timestamped time zone
serverTimelong 1554887652929 Returns the current server timestamp in milliseconds

In the rateLimits group: the request limit for the order api will be displayed

.
Parameter Name Data Types Examples Description
rateLimitType string ORDERS Type of speed limit
interval string SECOND Speed limit range
limit string 1500 Speed limit interval values

In the contracts information group: information on all contracts currently being traded by the broker will be returned:

?
Parameter Name Data Types Examples Description
symbol string BTC-SWAP Contract name
status string TRADING Contract status
baseAsset string BTC-SWAP Underlying Assets. For contracts, the contract itself is the underlying asset.
baseAssetPrecision float 0.001 Accuracy of underlying assets (number of contracts)
quoteAsset string USDT Pricing the asset. For contracts, this is what the contract is settled for.
quoteAssetPrecision float 0.001 Accuracy in pricing assets (contract prices).
inverse bool true Whether the contract is a reverse contract (true=is a reverse contract, false=is a forward contract).
index string BTCUSDT Name of the underlying index. The real time price of the underlying index can be accessed at the index endpoint. For example, if BTC-SWAP uses BTCUSDT as the underlying index, then the following can be found at the index endpoint Real-time prices for BTCUSDT
contractMultiplier string true Multiplier for contracts
icebergAllowed string false Is the iceberg order supported

In the contracts filers information group:

.
Parameter Name Data Types Examples Description
filterType string PRICE_FILTER Filter types
minPrice float 0.001 Minimum price allowed
maxPrice float 100000.0 Maximum price allowed
tickSize float 0.001 Accuracy of contract prices
minQty float 0.01 Minimum number allowed
maxQty float 100000 Maximum number allowed
stepSizefloat 0.001 Accuracy of contract numbers
minNotional float 1 Minimum transaction size limit (quantity * price)

In the riskLimits information group:

Parameter Name Data Types Examples Description
quantity float 100 Positions less than this number and greater than the quantity of the previous stall need to refer to the following requirements.
initialMargin float 0.1 Initial margin rate
maintMargin float 0.03 Minimum maintenance margin rate

Quotes interface

Index price

API Key permissions: no signature required

The underlying index price

HTTP Request


curl "https://api.bkex.co/v2/contract/q/index?symbol=BTC-SWAP"
        

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string false NA Underlying index name, if this is not sent, all prices of the underlying index are returned. e.g. BTC-SWAP

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
  "index":{
    "BTCUSDT":"8243.21666667",
    "OKBUSDT":"1.482",
    "BNBUSDT":"31.2658",
    "HTUSDT":"3.1209",...
    },
  "edp":{
    "BTCUSDT":"8258.98505556",
    "OKBUSDT":"1.48578333",
    "BNBUSDT":"31.48741917",
    "HTUSDT":"3.14308",...
  }
}
}

Response data

Parameter Name Data Types Examples Description
index float 8342.73 Price of the underlying index
EDP float 8432.32 EDP of the underlying index (estimated delivery price, average of index prices over the last 10 minutes)

Order Book

API Key Permissions: no signature required

Get the data from the current order book. This endpoint is updated once every 3 seconds.

HTTP request


curl "https://api.bkex.co/v2/contract/q/depth?symbol=BTC-SWAP&limit=30"
            

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA The contract name used to get the order book. e.g. BTC-SWAP
limit integer false 40 Returns the number of bids and tasks. Default 40; max 40.

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
  "time": 1555049455783,
  "bids": [
   ["78.82", "0.526"],//[Price, Quantity]
   ["77.24", "1.22"],
   ["76.65", "1.043"],
   ["76.58", "1.34"],
   ["75.67", "1.52"],
   ["75.12", "0.635"],
   ["75.02", "0.72"],
   ["75.01", "0.672"],
   ["73.73", "1.282"],
   ["73.58", "1.116"],
   ["73.45", "0.471"],
   ["73.44", "0.483"],
   ["72.32", "0.383"],
   ["72.26", "1.283"],
   ["72.11", "0.703"],
   ["70.61", "0.454"]],
   "asks": [
     ["122.96", "0.381"],//[Price, Quantity]
     ["144.46", "1"],
     ["155.55", "0.065"],
     ["160.16", "0.052"],
     ["200", "0.775"],
     ["249", "0.17"],
     ["250", "1"],
     ["300", "1"],
     ["400", "1"],
     ["499", "1"]]
   }
}

Response Data

Parameter Name Data Types Examples Description
time long 1550829103981 Current time (Unix Timestamp in milliseconds ms)
bids list (as follows) Price and quantity information for all bids, best bid price from top to bottom.
asks list (as follows) Price and quantity information for all ASKs, best ASK price from top to bottom.

The group of information corresponding to bids and asks represents all prices in the order book and the quantity corresponding to the price by Best price from top to bottom:

Parameter Name Data Types Examples Description
'' float 123.10 Price
'' float 300 Qualities corresponding to the current price

Latest deals

API Key permissions: no signature required

Get information on the most recently executed orders for a particular contract.

HTTP requests


curl "https://api.bkex.co/v2/contract/q/trades?symbol=BTC-SWAP&limit=10"
            

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA The contract name used to get the order book. e.g. BTC-SWAP
limit integer false 500 The number of transactions returned. Default 500; Max 1000

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
  "time": 1555049455783,
  "bids": [
  {
    "price": "4.00000100",
    "qty": "12.00000000",
    "time": 1499865549590,
    "isBuyerMaker": true
  },...
]
}

Response Data

Parameter Name Data Types Examples Description
price float 0.055 Trade price
time long 1537797044116 Current Unix timestamp in milliseconds (ms)
qty float 5 Number (number of sheets)
isBuyerMaker string true Seller or buyer. true=buy when order is created, false=sell when order is created

K-line/candlestick data

API Key Permissions: no signature required

Get the K line of a contract (high, low, open, close, volume...).

HTTP request


curl "https://api.bkex.co/v2/contract/q/kline?symbol=BTC-SWAP&interval=1m"
            

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA Symbol Name E.g. BTC-SWAP
interval string true NA K-line chart interval 1m, 5m, 15m, 30m, 1h, 1d, 1W, 1M (m=minutes, h=hours, d=days, w=weeks, M=months)
to number false NA Time stamp (milliseconds) of the last returned entry
limit integer false 500 The number of bars returned. Default 500; Max 1000

Response:

{
  "code": 0,
  "msg": "success",
  "data": {[
  [
    1499040000000,      // Open time
    "0.01634790",       // Open
    "0.80000000",       // High
    "0.01575800",       // Low
    "0.01577100",       // Close
    "148976.11427815",  // Volume
    1499644799999,      // Close time
    "2434.19055334",    // Quote asset volume
    308,                // Number of trades
    "1756.87402397",    // Taker buy base asset volume
    "28.46694368"       // Taker buy quote asset volume
  ]
]
}

Response Data

Parameter Name Data Types Examples Description
'' long 1538728740000 Beginning timestamp in milliseconds
'' float 36.00000 Opening price
'' float 36 Highest Price
'' float 36 Lowest Price
'' float 36 Closing price
'' float 148976.11427815 Contract Transaction Amount
'' long 1538728740000 Stop timestamp, milliseconds (ms)
'' float 2434.19055334 Number of transactions (number of sheets)
'' integer 308 Number of transactions completed (number of pieces)
'' float 1756.87402397 Buyer purchase amount
'' float 28.46694368 Number of purchases by the buyer (number of pieces)

24-hour ticker price changes Data

API Key Permissions: no signature required

24-hour price change data. Note A lot of data is returned if symbols are not sent

HTTP Requests

。
curl "https://api.bkex.co/v2/contract/q/ticker24hr?symbol=BTC-SWAP"
            

Request parameters

Parameters Data Types Is it necessary Default values Description Range of values
符号 字符串 false NA 符号名称 如BTC-SWAP

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
## Single ticker
{
  "time":1579424880100,
  "symbol":"BTC-SWAP",
  "bestBidPrice":"9079.1",
  "bestAskPrice":"9079.5",
  "volume":"61684269",
  "quoteVolume":"553667621070",
  "openInterest":"2277632.99999999998",
  "lastPrice":"9077.5",
  "highPrice":"9179.8",
  "lowPrice":"8840.8",
  "openPrice":"8861.7"
  }
## Multiple ticker info when symbol is omiited
[
  {
    "time":1579422004248,
    "symbol":"BTC-SWAP-USDT",
    "volume":"102696523",
    "quoteVolume":"918742352316.6",
    "openInterest":"2277632.99999999998",
    "lastPrice":"9092.9",
    "highPrice":"9180.2",
    "lowPrice":"8817.7",
    "openPrice":"8817.7"
    },...
    ]
}

response data

.
Parameter Name Data Types Examples Description
time long 1538728740000 Beginning timestamp, in milliseconds
symbol string BTC-SWAP Symbol name
bestBidPrice float 4.00 Best buy price
bestAskPrice float 4.000002000 Best selling price
lastPrice float 4.000002000 Last sale price
openPrice float 99 Opening price
highPrice float 100 Highest Price
lowPrice float 0.10000000 Lowest Price
volume float 8913.30 Trade volume
openInterest float 213933113 Number of positions

Transaction interface

Creating a new order

API Key Permissions: Contract Operations

Contract orders

HTTP request

{
  "symbol": "BTC-SWAP",
  "side": "BUY_OPEN",
  "orderType": "LIMIT",
  "quantity": 10,
  "leverage": 10,
  "clientOrderId": "100011111100001",
  "price": 7928.6,
  "priceType": "INPUT"
}

Request Parameters

. . .
Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA Symbol Name E.g. BTC-SWAP
side string true NA Order direction, direction type BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE
orderType string true NA Order type, supports order types LIMIT and STOP
quantity number true NA Number of contracts on order
leverage string true NA Leverage on orders. (Not required for *_CLOSE" close orders)
clientOrderId string true NA ID of the order, defined by the user himself. e.g. 12094ahsihsiad
price number false NA Order Price. (LIMIT&INPUT) orders are mandatory
priceType string false NA Price types supported are INPUT (default), OPPONENT, QUEUEUE. OVER, MARKET.
triggerPrice number false NA Trigger price for a plan commission.
timeInForce string false NA Time in Force command for LIMIT orders, currently supported types are GTC (default), FOK, IOC, LIMIT_MAKER

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
    "time": "1570759718825",
    "updateTime": "0",
    "orderId": "469961015902208000",
    "clientOrderId": "6423344174",
    "symbol": "BTC-SWAP",
    "price": "8200",
    "leverage": "12.08",
    "origQty": "5",
    "executedQty": "0",
    "avgPrice": "0",
    "marginLocked": "0.00005047",
    "orderType": "LIMIT",
    "side": "BUY_OPEN",
    "fees": [],
    "timeInForce": "GTC",
    "status": "NEW",
    "priceType": "INPUT"
  }
}

Response data

. . .
Parameter Name Data Types Examples Description
time long 1570759718825 Time stamp at order generation
updateTimelong 1570759718825 Time stamp of the last update of the order
orderId integer 469961015902208000 Order ID
clientOrderId string 100011111100001 User-defined order ID
symbol string BTC-SWAP Contract name
price float 8200 Order Price
leverage float 99 Order Leverage
origQty float 1.01 Number of orders
executedQty float 0.10000000 Number of orders executed
avgPrice float 8913.30 Average trading price
marginLocked float 200 Margin locked in for this order. This includes the actual margin required plus the fees required to open and close the position.
orderType string LIMIT Order Type (and STOP)
priceType string INPUT Price type (INPUT, OPPONENT, QUEUEUE, OVER, MARKET)
side string BUY Order Direction (BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE)
status string NEW Order Status (NEW, PARTIALLY_FILLED, FILLED, CANCELLED, REJECTED)
timeInForce string GTC Time in Force type (GTC, FOK, IOC, LIMIT_MAKER)
fees Commission on orders

Order Information

API Key Permissions: Contract Queries

Get the details of a particular order

HTTP request


curl "https://api.bkex.co/v2/contract/trade/getOrder?orderId=507904211109878016&orderType=LIMIT"
        

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
orderType string true NA Order Types (LIMIT and STOP)
orderId string false NA Order Id E.g. 507904211109878016
clientOrderId string false NA ID of the order, defined by the user himself. e.g. 100011111100001

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
    "time": "1570759718825",
    "updateTime": "0",
    "orderId": "469961015902208000",
    "clientOrderId": "6423344174",
    "symbol": "BTC-SWAP",
    "price": "8200",
    "leverage": "12.08",
    "origQty": "5",
    "executedQty": "0",
    "avgPrice": "0",
    "marginLocked": "0.00005047",
    "orderType": "LIMIT",
    "side": "BUY_OPEN",
    "fees": [],
    "timeInForce": "GTC",
    "status": "NEW",
    "priceType": "INPUT"
  }
}

Response data

. . .
Parameter Name Data Types Examples Description
time long 1570759718825 Time stamp at order generation
updateTimelong 1570759718825 Time stamp of the last update of the order
orderId integer 469961015902208000 Order ID
clientOrderId string 100011111100001 User-defined order ID
symbol string BTC-SWAP Contract name
price float 8200 Order Price
leverage float 99 Order Leverage
origQty float 1.01 Number of orders
executedQty float 0.10000000 Number of orders executed
avgPrice float 8913.30 Average trading price
marginLocked float 200 Margin locked in for this order. This includes the actual margin required plus the fees required to open and close the position.
orderType string LIMIT Order Type (and STOP)
priceType string INPUT Price type (INPUT, OPPONENT, QUEUEUE, OVER, MARKET)
side string BUY Order Direction (BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE)
status string NEW Order Status (NEW, PARTIALLY_FILLED, FILLED, CANCELLED, REJECTED)
timeInForce string GTC Time in Force type (GTC, FOK, IOC, LIMIT_MAKER)
fees Commission on orders

In the fees information group:

Parameter Name Data Types Examples Description
feeToken string USDT Commission pricing types.
fee float 0.1 Actual fees

Cancel the order

API Key Permissions: Contract Operations

To cancel an order, you need to send one of orderId or clientOrderId. This API endpoint requires a signature for your request.

HTTP request

{
  "orderType": "LIMIT",
  "orderId": "507904211109878016",
  "clientOrderId": "100011111100001"
}

Request Parameters

Parameters Data Types Is it necessary Default values Description
orderType string true NA Order Types (LIMIT and STOP)
orderId string false NA Order Id E.g. 507904211109878016
clientOrderId string false NA ID of the order, defined by the user himself. e.g. 100011111100001

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
    "symbol": "BTC-SWAP",
    "leverage": "10",
    "orderType": "LIMIT",
    "side": "BUY_OPEN",
    "fees": [],
    "executedQty": "0",
    "orderId": "580438692152238336",
    "origQty": "10",
    "avgPrice": "0",
    "clientOrderId": "20200311202803",
    "priceType": "INPUT",
    "updateTime": "0",
    "marginLocked": "0",
    "price": "5000",
    "time": "1583929684121",
    "timeInForce": "GTC",
    "status": "CANCELED"
  }
}

Response data

. . .
Parameter Name Data Types Examples Description
time long 1570759718825 Time stamp at order generation
updateTimelong 1570759718825 Time stamp of the last update of the order
orderId integer 469961015902208000 Order ID
clientOrderId string 100011111100001 User-defined order ID
symbol string BTC-SWAP Contract name
price float 8200 Order Price
leverage float 99 Order Leverage
origQty float 1.01 Number of orders
executedQty float 0.10000000 Number of orders executed
avgPrice float 8913.30 Average trading price
marginLocked float 200 Margin locked in for this order. This includes the actual margin required plus the fees required to open and close the position.
orderType string LIMIT Order Type (and STOP)
priceType string INPUT Price type (INPUT, OPPONENT, QUEUEUE, OVER, MARKET)
side string BUY Order Direction (BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE)
status string NEW Order Status (NEW, PARTIALLY_FILLED, FILLED, CANCELLED, REJECTED)
timeInForce string GTC Time in Force type (GTC, FOK, IOC, LIMIT_MAKER)
fees Commission on orders

In the fees information group:

Parameter Name Data Types Examples Description
feeToken string USDT Commission pricing types.
fee float 0.1 Actual fees

Current Orders

API Key Permissions: Contract Queries

Gets the current order of single or multiple symbols. Note If no symbols are sent, a lot of data is returned.

HTTP requests


curl "https://api.bkex.co/v2/contract/trade/openOrders?symbol=BTC-SWAP&orderType=LIMIT"

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA Symbol Name E.g. BTC-SWAP
orderType string false NA Order Types (LIMIT and STOP)
side string false NA Order Direction (BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE)
orderId string false NA Order Id E.g. 507904211109878016
limit integer false 20 Default 20; max 1000

Response:

{
  "code": 0,
  "msg": "success",
  "data": [
    {
      "time": "1570760254539",
      "updateTime": "0",
      "orderId": "469965509788581888",
      "clientOrderId": "1570760253946",
      "symbol": "BTC-SWAP",
      "price": "8502.34",
      "leverage": "20",
      "origQty": "222",
      "executedQty": "0",
      "avgPrice": "0",
      "marginLocked": "0.00130552",
      "orderType": "LIMIT",
      "side": "BUY_OPEN",
      "fees": [],
      "timeInForce": "GTC",
      "status": "NEW",
      "priceType": "INPUT"
    },...
  ]
}

Response data < /h3> . . .
Parameter Name Data Types Examples Description
time long 1570759718825 Time stamp at order generation
updateTimelong 1570759718825 Time stamp of the last update of the order
orderId integer 469961015902208000 Order ID
clientOrderId string 100011111100001 User-defined order ID
symbol string BTC-SWAP Contract name
price float 8200 Order Price
leverage float 99 Order Leverage
origQty float 1.01 Number of orders
executedQty float 0.10000000 Number of orders executed
avgPrice float 8913.30 Average trading price
marginLocked float 200 Margin locked in for this order. This includes the actual margin required plus the fees required to open and close the position.
orderType string LIMIT Order Type (and STOP)
priceType string INPUT Price type (INPUT, OPPONENT, QUEUEUE, OVER, MARKET)
side string BUY Order Direction (BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE)
status string NEW Order Status (NEW, PARTIALLY_FILLED, FILLED, CANCELLED, REJECTED)
timeInForce string GTC Time in Force type (GTC, FOK, IOC, LIMIT_MAKER)
fees Commission on orders

In the fees information group:

Parameter Name Data Types Examples Description
feeToken string USDT Commission pricing types.
fee float 0.1 Actual fees
  • Weight:1
  • If an orderId is sent, all orders with < orderId are returned. If not, it returns the most recent unfinished order

History Orders

API Key Permissions: Contract Queries

Get the history order for the current account. Note that if no symbol is sent, a lot of data is returned.

HTTP Requests


curl "https://api.bkex.co/v2/contract/trade/historyOrders?symbol=BTC-SWAP&orderType=LIMIT"

request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA Symbol Name E.g. BTC-SWAP
orderType string false NA Order Types (LIMIT and STOP)
side string false NA Order Direction (BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE)
orderId string false NA Order Id E.g. 507904211109878016
limit integer false 500 Default 500; max 1000

Response:

{
  "code": 0,
  "msg": "success",
  "data": [
    {
      "time": "1570760254539",
      "updateTime": "0",
      "orderId": "469965509788581888",
      "clientOrderId": "1570760253946",
      "symbol": "BTC-SWAP",
      "price": "8502.34",
      "leverage": "20",
      "origQty": "222",
      "executedQty": "0",
      "avgPrice": "0",
      "marginLocked": "0.00130552",
      "orderType": "LIMIT",
      "side": "BUY_OPEN",
      "fees": [],
      "timeInForce": "GTC",
      "status": "NEW",
      "priceType": "INPUT"
    },...
  ]
}

Response Data

. . .
Parameter Name Data Types Examples Description
time long 1570759718825 Time stamp at order generation
updateTimelong 1570759718825 Time stamp of the last update of the order
orderId integer 469961015902208000 Order ID
clientOrderId string 100011111100001 User-defined order ID
symbol string BTC-SWAP Contract name
price float 8200 Order Price
leverage float 99 Order Leverage
origQty float 1.01 Number of orders
executedQty float 0.10000000 Number of orders executed
avgPrice float 8913.30 Average trading price
marginLocked float 200 Margin locked in for this order. This includes the actual margin required plus the fees required to open and close the position.
orderType string LIMIT Order Type (and STOP)
priceType string INPUT Price type (INPUT, OPPONENT, QUEUEUE, OVER, MARKET)
side string BUY Order Direction (BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE)
status string NEW Order Status (NEW, PARTIALLY_FILLED, FILLED, CANCELLED, REJECTED)
timeInForce string GTC Time in Force type (GTC, FOK, IOC, LIMIT_MAKER)
fees Commission on orders

In the fees information group:

Parameter Name Data Types Examples Description
feeToken string USDT Commission pricing types.
fee float 0.1 Actual fees

transaction history

API Key Permissions: Contract Queries

Get the transaction history of the current account

HTTP requests


curl "https://api.bkex.co/v2/contract/trade/myTrades?symbol=BTC-SWAP&side=LIMIT"

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA Symbol Name E.g. BTC-SWAP
side string false NA Order type (LIMIT, STOP)
fromId integer false NA From here Trade Id begins to query
toId integer false NA Conclude with this Trade Id
limit integer false 20 Default 20; max 1000

Response:

{
  "code": 0,
  "msg": "success",
  "data": [
    {
      "time": "1570760582848",
      "tradeId": "469968263995080704",
      "orderId": "469968263793737728",
      "accountId": "456552319339779840",
      "symbolId": "BTC-SWAP",
      "price": "8531.17",
      "quantity": "100",
      "feeTokenId": "TBTC",
      "fee": "0.00000586",
      "type": "LIMIT",
      "side": "BUY_OPEN"
    },...
  ]
}

Response data

.
Parameter Name Data Types Examples Description
time long 1570759718825 Time stamp at order generation
tradeId long 49366 Transaction ID
orderId integer BTC-SWAP Order id
symbolId string BTC-SWAP Contract name
price float 4765.29 Trading price
quantity float 1.01 Number of transactions
feeTokenId string USDT Commission type (Token name)
fee Actual fees
side string BUY_OPEN Order Direction (BUY_OPEN, SELL_OPEN, BUY_CLOSE, SELL_CLOSE)
orderType string LIMIT Order types (LIMIT, MARKET)

Current Positions

API Key Permissions: Contract Queries

Get current position information

HTTP requests


curl "https://api.bkex.co/v2/contract/trade/positions?symbol=BTC-SWAP&side=LONG"

Request Parameters

Parameters Data Types Is it necessary Default values Description Range of values
symbol string false NA Contract Name. If not sent, all contract position information will be returned. e.g. BTC_PERP-REV
side string false NA Position direction, LONG (long position) or SHORT (short position). If it is not sent, position information is returned for both directions.

Response:

{
  "code": 0,
  "msg": "success",
  "data": [
    {
      "symbol": "BTC-SWAP",
      "leverage": "8.81",
      "side": "SHORT",
      "margin": "0.00056284",
      "avgPrice": "7849.1",
      "available": "40",
      "flp": "8779.5",
      "profitRate": "0.0302",
      "positionValue": "0.00511312",
      "marginRate": "0.1134",
      "unrealizedPnL": "0.00001701",
      "realizedPnL": "-0.00000216",
      "position": "40",
      "lastPrice": "7822.8"
    }
  ]
}

Response data

Parameter Name Data Types Examples Description
symbol string BTC-SWAP Contract name
side string LONG Position Direction (LONG, SHORT)
avgPrice float 100 Average opening price
position float 20 Number of open positions (sheets)
available float 15 Number of positions that can be closed (sheets)
leverage float 6 Position now leveraged
lastPrice float 100 Last Market Price of Contract
positionValue float 2000 Value of position
flp float 80 Forced liquidation price
margin float 20 Position Margin
marginRate float 0.2 Margin rate for current position
unrealizedPnL float 10 Unrealized gain/loss on current position
profitRate float 0.0000333 Profit margin on current position
realizedPnL float 6.8 Realized gains/losses on current contracts

Change Position Margin

API Key Permissions: Contract Operations

Change the margin for a particular contract position.

HTTP requests

{
  "symbol": "BTC-SWAP",
  "amount": 0.2564,
  "side": "LONG"
}

Request Parameters

.
Parameters Data Types Is it necessary Default values Description Range of values
symbol string true NA Contract name E.g. BTC-SWAP
side string true NA Position direction, LONG (long) or SHORT (short).
amount number true NA The amount by which the margin is increased (positive) or decreased (negative). Note that this quantity refers to the underlying contract pricing asset (i.e., the subject of the contract settlement)

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
    "symbol": "BTC-SWAP",
    "margin": "0.00056304",
    "timestamp": "1583931567359"
  }
}

Response data

Parameter Name Data Types Examples Description
symbol string BTC-SWAP Contract name
margin float 12.3 Updated Position Margin
Timestamp long 1541161088303 Updated timestamp

Account information

Account information

API Key Permissions: Contract Queries

Return the contract account balance.

HTTP request


curl "https://api.bkex.co/v2/contract/u/account"
        

Request Parameters

No parameters

Response:

{
  "code": 0,
  "msg": "success",
  "data": {
    "TBTC": {
        "total":"131.06671401",
        "availableMargin":"131.0545541",
        "positionMargin":"0.01215991",
        "orderMargin":"0"
    },...
  }
}

Response data

Parameter Name Data Types Examples Description
total float 131.06671401 Total balance
availableMargin float 131.0545541 Available deposit
positionMargin float 0.01215991 Position Margin
orderMargin float 0 Commission deposit (order lock)

Websocket coin market data

Introduction

Access URL

Quote Request Address

wss://api.bkex.io (recommend). strong>

wss://api.bkex.co. strong>

wss://api.bkex.com

Example

Socket.io Demo

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.4/socket.io.js"></script>

const socket = io('https://api.bkex.co/quotation');

socket.on('connect', function (data) {

 socket.emit("subKlineByRange", {

  "symbol": "BTC_USDT,ETH_USDT,LTC_USDT",

  "period": "240",

  "from": 1567136369,

  "to": 1588735346,

  "no": "157430756955441803"

 });

});

Native WebScoket Demo

var pingPong = null;

ws = new WebSocket("wss://api.bkex.co/socket.io/?EIO=3&transport=websocket");

ws.onopen = function() {pingPong = setInterval(function () { ws.send('2');}, 20 * 1000)};

ws.onmessage = function(e) {

if(e.data === '40') {

    ws.send('40/quotation')}

  else if(e.data === '40/quotation'){

    ws.send('42/quotation,["subOrderDepth",{"symbol": "BTC_USDT","number": 50}]')}

  else {}

};

K-line data

Topic subscription

subKlineByRange

Subscription Requests


[
  "subKlineByRange",
  {
    "symbol": "BTC_USDT,ETH_USDT",
    "period": "240",
    "from": 1567136369,
    "to": 1574307629,
    "no": "157430756955441833"
  }
]

Subscription Parameters

Parameters Data Types Is it necessary Description Range of values
symbol string true Trading pairs (multiple pairs separated by ',') BTC_USDT,ETH_USDT...
period string true K Cycle '1', '5', '15', '30', '60', '240', '360', '720', '1D', '1W', numbers for minutes, 1D for: 1 day, 1W for: 1 week
from long true Beginning time stamp in seconds
to long true Cut-off time stamp in seconds
no string true Marker

Full Amount Response


[
  "symbolKlineByRange",
  {
   "no": "157430756955441833",
   "noMore": false,
   "list":[
     {
       "volume": 194.2213,
       "close": 8765.4543,
       "quoteVolume": 31295.7543,
       "high": 8942.4962,
       "low": 8312.3154,
       "open": 8532.8129,
       "ts": 1574307629
     }]
  }
]

Incremental Response


[
  "qSymbolKLine",
  {
    "volume": 194.2213,
    "close": 8765.4543,
    "vol": 31295.7543,
    "high": 8942.4962,
    "quoteVolume": 8312.3154,
    "open": 8532.8129,
    "ts": 1574307629
  }
]

Response data

Field Data Types Description
no string Tag number, return and parameter match
noMore boolean Is there more data, false is yes
list object Full data set

List of data fields

Field Data Types Description
volume decimal Turnover
open decimal Opening price
close decimal Closing price
low decimal Lowest Price
high decimal Highest Price
quoteVolume decimal Turnover

Order Depth Market Data

Subscription by topic

subOrderDepth

Subscription parameters


[
  "subOrderDepth",
  {
   "symbol": "BTC_USDT,ETH_USDT",
   "number": 50
  }
]

Parameters

Parameters Data Types Is it necessary Default value Description Range of values
symbol string true NA Trading pairs (multiple pairs separated by ',') BTC_USDT,ETH_USDT...
number integer true 50 Number of depth [1-50]

Response


[
  "quotationOrderDepth",
  {
    "symbol": BTC_USDT,
    "ts": 1577254059571,
    "asks": [
        ["7148.0994","0.0021"],// [价格, 数量]
        ["7148.0994","0.0021"],
        ... 
            ],
    "bids":[
        ["7148.0994","0.0021"],
        ["7148.0994","0.0021"],
        ... 
    ]
  }
]

List of data fields

Field Data Types Description
symbol string Trading pair
ts long Time stamp in milliseconds
asks object All current sell orders [price, quantity]
bids object Current So Buy Order [price, quantity]

Transaction details

Topic Subscriptions

quotationDealConnect

.

This thread provides a line-by-line breakdown of the latest transactions.

Subscription parameters


[
  "quotationDealConnect",
  {
   "symbol": "BTC_USDT,ETH_USDT",
   "number": 50
  }
]

Parameters

Parameters Data Types Is it necessary Default value Description Range of values
symbol string true NA Trading pairs (multiple pairs separated by ',') BTC_USDT,ETH_USDT...
number integer true 50 Quantity [1-50]

Full Response


[
  "quotationAllDeal",
  [{
    "symbol": BTC_USDT,
    "price": 7145.0806,
    "volume": 0.1662,
    "direction": "B",
    "ts": 1577254059571
  }]
]

List of data fields

Field Data Types Description
symbol string Trading pair
price decimal Trading price
volume decimal Number of transactions
direction string Direction of transaction, B for buy, S for sell
ts long Closing Time Stamp

Incremental Response

.

[
  "quotationListDeal",
  [{
    "symbol": BTC_USDT,
    "price": 7145.0806,
    "volume": 0.1662,
    "direction": "B",
    "ts": 1577254059571
  }]
]

24-hour market

Topic Subscription

subQuotationSymbol

Subscription parameters


[
  "subQuotationSymbol",
  {
   "symbol": "BTC_USDT,ETH_USDT"
  }
]

Parameters

Parameters Data Types Is it necessary Default value Description Range of values
symbol string false NA Trading pairs (multiple pairs separated by ',') BTC_USDT,ETH_USDT...

Response


[
  "qPairsUpdateStats",
  [{
    "symbol": BTC_USDT,
    "close": 7145.0806,
    "open": 7123.0407,
    "high": 7167.1034,
    "low": 7105.5237,
    "volume": 4214.5321,
    "quoteVolume": 94285313.4451,
    "change": 0.12
  }]
]

List of data update fields

. .
Field Data Types Description
symbol string Trading pair
close decimal 24-hour closing price
volume decimal 24-hour trading volume
open decimal 24-hour opening price
low decimal Lowest price for 24 hours
high decimal 24-hour top price
quoteVolume decimal 24-hour turnover
change decimal 24-hour ups and downs






Websocket Coin User Data

Introduction

Access URL

Request address

wss://api.bkex.io (recommend). strong>

wss://api.bkex.co. strong>

wss://api.bkex.com

Example

Socket.io Demo

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.4/socket.io.js"></script>

const socketUser = io('https://api.bkex.co/account');

socketUser.on('connect', function (data) {

 socketUser.emit('userLogin', {

  "signature": "XXXXX",

  "accessKey": "XXXXX",

  "timestamp": 1589199182739

  });

 });

socketUser.on('userLogin', function (data) {

 if(data.code==0){

  socketUser.emit("subUserAccountInfo");

  socketUser.emit("subUserOrderDeal");

 }

});

Native WebScoket Demo

var pingPong = null;

ws = new WebSocket("wss://api.bkex.co/socket.io/?EIO=3&transport=websocket");

ws.onopen = function() {pingPong = setInterval(function () { ws.send('2');}, 20 * 1000)};

ws.onmessage = function(e) {

  if(e.data === '40') {

    ws.send('40/account')}

  else if(e.data === '40/account'){

    ws.send('42/account,["userLogin",{"signature":"93c4f85c396eeff4c0472a31439b98bec7168338f8fad44ef54b4f5b3f6b3e2f","accessKey":"64ff07234e19363cf15ca8dae1fa35e734a7842e1fef820ba7fbc94d5cffa45d","timestamp":1588663088781}]')}

  else {}

};

websocket user login

event name

userLogin

parameters

[
  "userLogin",
  {
    "signature": "93c4f85c396eeff4c0472a31439b98bec7168338f8fad44ef54b4f5b3f",
    "accessKey": "xxxxxxxxxx19363cf15ca8dae1fa35e734a7842e1fef820ba7fbc94d5c",
    "timestamp": 1588663088781
  }
]

Request Parameters

Field Data Types Description
accessKey string api key
timestamp long Timestamp
signature string Signature String

The signature parameter is timestamp

Example:
Signature parameter string: timestamp=1588663088781
Using secretKey for HMAC SHA256 encryption, the result is:93c4f85c396eeff4c0472a31439b98bec7168338f8fad44ef54b4f5b3f

Response


[
  "userLogin",
  {
    "code": 0,
    "msg": "success"
  }
]

Response message

A success message is returned if the login information is verified (code=0, msg='success');
The corresponding error message is returned if the validation fails.

User Balance Change Subscription

Topic Subscription

subUserAccountInfo

Subscription parameters


[
  "subUserAccountInfo"
]

Response

[
  "subUserAccountInfo",
  [
    {
      "avAfterChange": "201.100000",
      "availableChange": "0.100000",
      "currency": "BTC",
      "frAfterChange": "0.000000",
      "frozenChange": "0.000000",
      "time": 1588667153068,
      "type": "TRADE_DEAL_BUYER"
    },
    {
      "avAfterChange": "1991120.234380",
      "availableChange": "0.000000",
      "currency": "USDT",
      "frAfterChange": "0.000000",
      "frozenChange": "-807.251420",
      "time": 1588667153068,
      "type": "TRADE_DEAL_BUYER"
    }
  ]
]

List of data update fields

Field Data Types Description
avAfterChange string Changed available balance
availableChange string Change in available balance
currency string Currency
frAfterChange string Frozen balance after changes
frozenChange string Changes to frozen balances
time long Timestamp
type string Type of balance change

Type of balance change:

TRADE_DEAL_BUYER: Buyer's balance changed during the transaction

TRADE_DEAL_SELLER: Change in seller balance during transaction

TRADE_DEAL_BUYER_FEE: Change in Buyer's Fee on Transactions

TRADE_DEAL_SELLER_FEE: Change in seller's fee on transactions

User Order Change Subscription

Topic Subscription

subUserOrderDeal

.

Subscription parameters


[
  "subUserOrderDeal"
]

Response


[
  "subUserOrderDeal",
  {
    "dealVolume": "0.1000",
    "fee": "0.00000000",
    "feeCurrency": "BKK",
    "id": "2020050516255306842000020",
    "orderId": "2020050516255281242000020",
    "orderSide": "BID",
    "price": "8072.5142",
    "symbol": "BTC_USDT",
    "tradeTime": 1588667153068
  }
]

List of data update fields

Field Data Types Description
dealVolume string Turnover
fee string Fee charges
feeCurrency string Currency of fees
id string Transaction ID
orderId string Order id
orderSide string Order Direction (BID: Buy, ASK: Sell)
price string Unit price
symbol string Trading pair
tradeTime long Times of transaction

Websocket Contract Quote Data

Access URL

Contract Quote Request Address

wss://api.bkex.io/contract/q/ws (recommend)

wss://api.bkex.co/contract/q/ws

wss://api.bkex.com/contract/q/ws

Error Handling

INVALID_REQUEST("-10000", "Invalid request!")

JSON_FORMAT_ERROR("-10001", "Invalid JSON!")

INVALID_EVENT("-10002", "Invalid event")

REQUIRED_EVENT("-10003", "Event required!")

INVALID_TOPIC("-10004", "Invalid topic!")

REQUIRED_TOPIC("-10005", "Topic required!")

PARAM_EMPTY("-10007", "Params required!")

PERIOD_EMPTY("-10008", "Period required!")

PERIOD_ERROR("-10009", "Invalid period!")

SYMBOLS_ERROR("-100010", "Invalid Symbols!")

heartbeat

Every once in a while, the client needs to send a ping frame and the server will reply to the pong frame, otherwise the server will reply at 5 Minute to actively disconnect the link.

Request

{ "ping": 1535975085052 }

Return

{ "pong": 1535975085052 }

Full Depth

Subscribe to messages

{ "topic": "depth", "event": "sub", "params": { "binary": false, "symbol": "$symbol" } }

Subscription Requests

{
  "topic": "depth",
  "event": "sub",
  "params": {
    "binary": false,
    "symbol": "BTC-SWAP-USDT"
    }
}

Subscription Parameters

.
Parameters Data Types Is it necessary Description Range of values
symbol string true Trading pair BTC-SWAP-USDT
binary boolean false Whether the returned data is compressed, default is false

Response

{
  "topic": "depth",
  "params": {
    "symbol": "BTC-SWAP-USDT",
    "binary": "false"
  },
  "data": {
    "s": "BTC-SWAP-USDT",
    "t": 1582001376853,
    "v": "13850022_2",
    "b": [
      [
        "9780.79",
        "0.01"
      ],//[price, quantity]
      [
        "9780.5",
        "0.1"
      ],
      [
        "9780.4",
        "0.517813"
      ]...
    ],
    "a": [
      [
        "9781.21",
        "0.042842"
      ],//[price, quantity]
      [
        "9782",
        "0.3"
      ],
      [
        "9782.1",
        "0.226"
      ],
      [
        "9782.3",
        "0.2"
      ]...
    ]
  }
}

Response data data

Field Data Types Description
s string Symbol
t long Timestamp
b[0][0] string Bids Price
b[0][1] string Number of Bids
a[0][0] string Asks Price
a[0][1] string Number of Asks

Ticker information for Symbol

Topic Subscriptions

{ "topic": "realtimes", "event": "sub", "params": { "binary": false, "symbol": "$symbol" } }

Subscription parameters

{
  "topic": "realtimes",
  "event": "sub",
  "params": {
    "binary": false,
    "symbol": "$symbol"
  }
}
            

Parameters

.
Parameters Data Types Is it necessary Description Range of values
symbol string true Trading pair BTC-SWAP-USDT
binary boolean false Whether the returned data is compressed, default is false

Response

{
  "topic": "realtimes",
  "params": {
    "symbol": "BTC-SWAP-USDT",
    "binary": "false"
  },
  "data": {
    "t": 1582001616500,
    "s": "BTC-SWAP-USDT",
    "o": "9736.5",
    "h": "9830.19",
    "l": "9455.71",
    "c": "9796.75",
    "v": "77211.561764",
    "qv": "740412516.91255711",
    "m": "0.0062"
  }
}

Response data data

Field Data Types Description
t long Timestamp
s string Symbol
o string Opening price
h string Highest Price
l string Lowest Price
c string Closing price
v string Trade volume
qv string Transactions
m string Up or down

transaction-by-transaction

Trade-by-trade pushes information about each transaction. A transaction, or trade, is defined as only one order eater and one order pendant trading with each other. After a successful connection to the server, the server first pushes one of the last 60 transactions. After this push, each push is followed by a real-time transaction. The variable "v" can be interpreted as a transaction ID, which is globally incremental and unique. For example, let's say 3 transactions have taken place in the last 5 seconds: EOS-SWAP-USDT, BTC-SWAP-USDT and BTC-SWAP-USDT. USDT, BTC-SWAP. their "v" will be consecutive values (112, 113, 114).

Topic Subscription

{ "topic": "trade", "event": "sub", "params": { "symbol": "$symbol", "binary": false } }

Subscription parameters

{
  "topic": "trade",
  "event": "sub",
  "params": {
    "symbol": "$symbol",
    "binary": false
  }
}
        

Parameters

.
Parameters Data Types Is it necessary Description Range of values
symbol string true Trading pair BTC-SWAP-USDT
binary boolean false Whether the returned data is compressed, default is false

Response

{
  "topic": "trade",
  "params": {
    "symbol": "BTC-SWAP-USDT",
    "binary": "false"
  },
  "data": {
    "v": "564265886622695424",
    "t": 1582001735462,
    "p": "9787.5",
    "q": "0.195009",
    "m": true
  }
}

Response data data

.
Field Data Types Description
t long Timestamp
v string can be understood as a transaction ID
p string Price
q string Quantity
m string true = buy, false = sell

K-line/candlestick

K line stream pushes updates of the requested K line type (the latest K line) on a second-by-second basis

K line/candle interval:

Subscribing to Kline requires an interval parameter, with the shortest being a minute line and the longest being a month line. The following intervals are supported:

m -> minutes; h -> hours; d -> days; w -> weeks; M -> months

1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1w, 1M

Subscription by topic

{ "topic": "kline", "event": "sub", "params": { "binary": false, "symbol": "$symbol", "klineType": "1m" } }

Subscription parameters

{
  "topic": "kline",
  "event": "sub",
  "params": {
    "binary": false,
    "symbol": "BTC-SWAP-USDT",
    "klineType": "1m"
  }
}
        

Parameters

.
Parameters Data Types Is it necessary Description Range of values
symbol string true Contract id BTC-SWAP-USDT
binary boolean false Whether the returned data is compressed, default is false
klineType string true Interval

Response

{
  "topic": "kline",
  "params": {
    "symbol": "BTC-SWAP-USDT",
    "binary": "false",
    "klineType": "1m"
  },
  "data": {
    "t": 1585729380000,
    "s": "BTC-SWAP-USDT",
    "c": "6308",
    "h": "6308",
    "l": "6308",
    "o": "6308",
    "v": "10"
  }
}

Response data data

Field Data Types Description
t long K line start time
s string symbol
c string Closing price
h string Highest Price
l string Lowest Price
o string Opening price
v string Trade volume

Order Book Ticker Information

Subscription by topic

{ "topic": "BookTicker", "event": "sub", "params": { "binary": false, "symbol": "$symbol" } }

Subscription parameters

{
  "topic": "trade",
  "event": "sub",
  "params": {
    "symbol": "BTC-SWAP-USDT",
    "binary": false
  }
}
        

Parameters

.
Parameters Data Types Is it necessary Description Range of values
symbol string true Contract id BTC-SWAP-USDT
binary boolean false Whether the returned data is compressed, default is false

Response

{
  "topic": "bookTicker",
  "params": {
    "symbol": "BTC-SWAP-USDT",
    "binary": "false"
  },
  "data": {
    "symbol": "BTC-SWAP-USDT",
    "bidPrice": "9797.79",
    "bidQty": "0.177976",
    "askPrice": "9799",
    "askQty": "0.65",
    "time": 1582001830346
  }
}

Response data data

Field Data Types Description
time long Timestamp
symbol string symbol
bidPrice string bid price
bidQty string bid volume
askPrice string ask price
askQty string ask volume
>>

Websocket Contract User Data

Basic Information

Access URL

wss://api.bkex.io/contract/u/ws/{listenKey} (recommend)

wss://api.bkex.co/contract/u/ws/{listenKey}

wss://api.bkex.com/contract/u/ws/{listenKey}

Create listenKey

API Key Permissions: Contract Queries

Create a new stream of user information. If no keepalive is sent, the push will be disconnected after 60 minutes

HTTP Request

{
  "recvWindow": 500
}

Request parameters

Parameters Data Types Is it necessary Default values Description
recvWindow long false 500 recvWindow

Response:

{
  "code": 0,
  "data": {
    "listenKey": "1A9LWJjuMwKWYP4QQPw34GRm8gz3x5AephXSuqcDef1RnzoBVhEeGE963CoS1Sgj"
  }
}

Response data

Parameter Name Data Types Examples Description
listenKey String listen Key

Extend ListenKey validity

API Key Permissions: Contract Queries

Extend to 60 minutes after this call, it is recommended to do an extension every 30 minutes

HTTP Request

{
  "listenKey":" 1A9LWJjuMwKWYP4QQPw34GRm8gz3x5AephXSuqcDef1RnzoBVhEeGE963CoS1Sgj ",
  "recvWindow": 500
}

Request parameters

Parameters Data Types Is it necessary Default values Description
listenKey string true 500 listen Key
recvWindow long false 500 recvWindow

Response:

{
  "code": 0,
  "data": {}
}

Response data

{}

Close listenKey

.

API Key Permissions: Contract Queries

Closing user data streams

HTTP Request

{
  "listenKey":"1A9LWJjuMwKWYP4QQPw34GRm8gz3x5AephXSuqcDef1RnzoBVhEeGE963CoS1Sgj",
  "recvWindow": 500
}

Request parameters

Parameters Data Types Is it necessary Default values Description
listenKey string true 500 listen Key
recvWindow long false 500 recvWindow

Response:

{
  "code": 0,
  "data": {}
}

Response data

{}

WebSocket Payload

Account update

Use outbound AccountInfo event for account updates

Payload

{ "e": "outboundAccountInfo", // event type "E": 1499405658849, // Time of event "T": true, // Allow trading? "W": true, // Allow reflections? "D": true, // Allow top-ups? "B": [ // Balance change { "a": "LTC", // Asset name "f": "17366.18538083", // Quantity available "l": "0.00000000" // Quantity frozen } ] }

Account update response

{
  "e": "outboundAccountInfo", // event type
  "E": 1499405658849, // Time of event
  "T": true, // Allow trading?
  "W": true, // Allow reflections?
  "D": true, // Allow top-ups?
  "B": [ // Balance change
    {
      "a": "LTC", // Asset name
      "f": "17366.18538083", // Quantity available
      "l": "0.00000000" // Quantity frozen
    }
  ]
}

Order Update

The order is updated via the contractExecutionReport event. Detailed description information can be found here. Average price can be found by dividing Z by z

Payload

{ "e": "contractExecutionReport", // event type "E": 1499405658658, // Time of event "s": "BTC-SWAP-USDT", // trading pairs "c": 1000087761, // Client order ID "S": "BUY", // order direction "o": "LIMIT", // Order Type "f": "GTC", // Time in force "q": "1.00000000", // Number of Orders "p": "0.10264410", // Order Price "X": "NEW", // Current Order Status "i": 4293153, // Order ID "l": "0.00000000", // last traded quantity "z": "0.00000000", // Cumulative number of transactions "L": "0.00000000", // last traded price "n": "0", // Handling fees "N": null, // Fee currency "u": true, // Please ignore. "w": true, // Please ignore. "m": false, // Please ignore. "O": 1499405658657, // Order Creation Time "Z": "0.00000000" // Cumulative transaction amount

Order Status:

Order update response

{
  "e": "executionReport", // event type
  "E": 1499405658658, // Time of event
  "s": "BTC-SWAP-USDT", // trading pairs
  "c": 1000087761, // Client order ID
  "S": "BUY", // order direction
  "o": "LIMIT", // Order Type
  "f": "GTC", // Time in force
  "q": "1.00000000", // Number of Orders
  "p": "0.10264410", // Order Price
  "X": "NEW", // Current Order Status
  "i": 4293153, // Order ID
  "l": "0.00000000", // last traded quantity
  "z": "0.00000000", // Cumulative number of transactions
  "L": "0.00000000", // last traded price
  "n": "0", // Handling fees
  "N": null, // Fee currency
  "u": true, // Please ignore.
  "w": true, // Please ignore.
  "m": false, // Please ignore.
  "O": 1499405658657, // Order Creation Time
  "Z": "0.00000000" // Cumulative transaction amount
}

Position update

Using outboundContractPositionInfo event for position updates

Payload

{ "e": "outboundContractPositionInfo", // event genre "A": "", // Account ID "s": "BTC-SWAP-USDT", // symbol "S": "LONG", // Position Direction "p": "9851.5", // average price "P": "269", // Number of Positions "a": "269", // available "f": "7705.9", // STRONG CLOSING PRICE "m": "59.7884", // Margin "r": "-0.0139" // P&L realized }

Holdings update response

{
  "e": "outboundContractPositionInfo", // event genre
  "A": "", // Account ID
  "s": "BTC-SWAP-USDT", // symbol
  "S": "LONG", // Position Direction
  "p": "9851.5", // average price
  "P": "269", // Number of Positions
  "a": "269", // available
  "f": "7705.9", // STRONG CLOSING PRICE
  "m": "59.7884", // Margin
  "r": "-0.0139" // P&L realized Translated with www.DeepL.com/Translator (free version)
}