The base url of broker open API can be found here
Current broker trading rules and symbol information.
0
GET /openapi/v1/brokerInfo
name | type | required | default | description |
| string |
| | Trading section information. Possible values include |
name | type | example | description |
| string |
| Timezone of timestamp |
| long |
| Retrieves the current time on server (in ms). |
In the rateLimits
field: Order api request limit will be displayed.
name | type | example | description |
| string |
| Rate Limit type |
| string |
| Rate Limit interval |
| string |
| Rate Limit value within the interval. |
In the contracts
field: All actively trading contracts will be displayed.
name | type | example | description |
| string |
| Name of the contract. |
| string |
| Status of the contract. |
| string |
| Base Asset of the trading pair. In the case with contracts, the contract itself is the base asset. |
| float |
| Precision of the contract quantity (baseAsset). |
| string |
| Quote asset for the contract. Meaning the contract is quoted in that currency. |
| float |
| Precision of the contract price (quoteAsset). |
| bool |
| Whether the contract is inverse. |
| string |
| Index symbol of the underlying asset. Index price can be accessed at the |
| string |
| The multiplier of contract. |
| string |
| Whether iceberg orders are allowed. |
For filters
in contracts
field:
name | type | example | description |
| string |
| Type of the filter. |
| float |
| Minimum price allowed |
| float |
| Maximum price allowed |
| float |
| Precision of the contract price. |
| float |
| Minimum quantity allowed |
| float |
| Maximum quantity allowed |
| float |
| Precision of the contract quantity |
| float |
| Minimum trade size (quantity * price) |
In the riskLimits
filed:
name | type | example | description |
| float |
| Positions below this amount follows the following requirement. |
| float |
| Initial margin rate requirement. |
| float |
| Minimum maintenance margin rate requirement. |
{"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-PERP-REV","symbolName":"BTC-PERP-REV","status":"TRADING","baseAsset":"BTC-PERP-REV","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"}]}]}
Get current insurance funding.
0
GET /openapi/contract/v1/insurance
name | type | required | default | description |
| string |
| | Input specific symbol to return the corresponding records. If not entered, records for all symbols will be returned. |
| long |
| | pagination, return record which id < fromId |
| long |
| | pagination, return record which id > toId. If toId is given, toId cannot be 0. |
| integer |
| 20 | Number of entries returned. |
name | type | example | description |
| long |
| The ID of the record. |
| long |
| current server timestamp. |
| float |
| Balance of the insurance fund. |
| string |
| Unit of the balance.. |
{"BTC":[{"id": 1552272184833,"timestamp": 155227218483,"value": 23.23,"unit": "BTC"},...],...}
Underlying asset index price.
0
GET /openapi/quote/v1/contract/index
name | type | required | default | description |
symbol | string |
| | Underlying index symbol. If this parameter is not sent, all symbols |
will be returned.
name | type | example | description |
| float |
| The index price of the instrument. |
| float |
| The EDP (estimated delivery price of the contract). The average price of the index in the last 1o minutes. This will be the price on which the contract is going to be settled. |
{"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",...}}
Get current funding rate (historical in process)
0
GET /openapi/contract/v1/fundingRate
name | type | required | default | description |
| string |
| | The contract to be returned. If not sent, records for all symbols will be returned as a result. |
| string |
|
| Get |
| long |
| | Timestamp to start. |
| long |
| | Timestamp to end. |
| integer |
|
| Number of entries returned. |
name | type | example | description |
| string |
| Name of the contracts |
| long |
| Timestamp when the interval started. |
| long |
| Timestamp when the interval ended. |
| float |
| The funding rate of this interval. |
| float |
| Index price at the time of settlement. |
[{'symbol': 'BTC-PERP-REV','intervalStart': '1570708800000','intervalEnd': '1570737600000','rate': '-0.000048567445464006'},...]
Retrieves the contracts order book.
Adjusted based on the limit:
Limit | Weight |
5, 10, 20, 50, 100 | 1 |
500 | 5 |
1000 | 10 |
GET /openapi/quote/v1/contract/depth
parameter | type | required | default | description |
| string |
| | The contract name for which to retrieve the order book |
| integer |
|
| The number of entries to return for bids and asks. |
name | type | example | description |
| long |
| Current timestamp (ms) |
| list | (see below) | List of all bids, best bids first. See below for entry details. |
| list | (see below) | List of all asks, best asks first. See below for entry details. |
The fields bids
and asks
are lists of orderbook price level entries, sorted from best to worst.
name | type | example | description |
| float |
| price level |
| float |
| The total quantity of orders for this price level |
{"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"]]}
Retrieve the latest trades that have occurred for a specific contract.
1
GET /openapi/quote/v1/contract/trades
Parameter | type | required | default | description |
| string |
| | The name of the contract. |
| integer |
|
| The number of trades returned |
name | type | example | description |
| float |
| The price of the trade |
| long |
| Current timestamp (ms) |
| float |
| The quantity traded |
| string |
| Maker or taker of the trade. |
[{"price": "1.21","time": 1555034474064,"qty": "0.725","isBuyerMaker": False},...]
Retrieves the kline information (open, high, trade volume, etc.) for a specific contract.
1
GET /openapi/quote/v1/contract/klines
Parameter | type | required | default | description |
| string |
| | Name of the contract. |
| string |
| | Interval of the kline. Possible values include: |
| integer |
|
| Number of entries returned. Max is capped at 1000. |
| integer |
| | timestamp of the last datapoint |
name | type | example | description |
| long |
| Open Time |
| float |
| Open |
| float |
| High |
| float |
| Low |
| float |
| Close |
| float |
| Trade volume amount |
| long |
| Close time |
| float |
| Quote asset volume |
| integer |
| Number of trades |
| float |
| Taker buy base asset volume |
| float |
| Taker buy quote asset volume |
[[1538728740000, //'opentime'"36.000000000000000000", //'open'"36.000000000000000000", //'high'"36.000000000000000000", //'low':"36.000000000000000000", //'close'"148976.11427815", // Volume1499644799999, // Close time"2434.19055334", // Quote asset volume308, // Number of trades"1756.87402397", // Taker buy base asset volume"28.46694368" // Taker buy quote asset volume],...]
base asset
means the quantity is expressed as the amount of contracts that were received by the buyer.
quote asset
means the amount of tokens paid to acquire the contracts.
Places order for a contract. This API endpoint requires your request to be signed.
1
POST /openapi/contract/v1/order
Parameter | type | required | default | description |
| string |
| | Name of the contract. |
| string |
| | Direction of the order. Possible values include |
| string |
| | The order type, possible types: |
| float |
| | The number of contracts to buy. |
| float |
| | Leverage of the order. |
| float |
| | Price of the order |
| string |
|
| The price type, possible types include: |
| float |
| | The price at which the trigger order will be executed. |
| string |
|
| Time in force for |
| string/long |
| | A unique ID of the order (user defined) |
NOTE For Market Orders, you need to set orderType
as LIMIT
AND priceType
as MARKET
.
You can get contracts' price, quantity precision configuration data in the brokerInfo
endpoint.
Note: if your balance does not meet the margin requirement (which is the minimum margin requirement + open position fee + close position fee), "insufficient balance" error message will be returned.
For detailed information regarding various price types and order types. Please refer to the explanation section in the end.
Name | type | example | description |
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contract. |
| float |
| Price of the order. |
| float |
| Leverage of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| | | Fees incurred for this order. |
{'time': '1570759718825','updateTime': '0','orderId': '469961015902208000','clientOrderId': '6423344174','symbol': 'BTC-PERP-REV','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'}
Cancels an order, specified by orderId
or clientOrderId
. This API endpoint requires your request to be signed.
1
DELETE /openapi/contract/v1/order/cancel
Parameter | type | required | default | description |
| integer |
| | The order ID of the order to be canceled |
| string |
| | Unique client customized ID of the order. |
| string |
| | The order type, possible types: |
One MUST be provided for either of these two parameters.
Name | type | example | description |
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contract. |
| float |
| Price of the order. |
| float |
| Leverage of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| | | Fees incurred for this order. |
In the fees
field:
Name | type | example | description |
| string |
| Fee token kind. |
| float |
| Actual transaction fees occurred. |
{'time': '1570759718825','updateTime': '0','orderId': '469961015902208000','clientOrderId': '6423344174','symbol': 'BTC-PERP-REV','price': '8200','leverage': '12.08','origQty': '5','executedQty': '0','avgPrice': '0','marginLocked': '0','orderType': 'LIMIT','side': 'BUY_OPEN','fees': [],'timeInForce': 'GTC','status': 'CANCELED','priceType': 'INPUT' //status will always be `CANCELED` for cancel request}
Cancel orders en masse. (PENDING: batch cancel for STOP orders)
1
DELETE /openapi/contract/v1/order/batchCancel
Parameter | type | required | default | description |
| string/list |
| | The symbol ids of the cancel orders |
Name | type | example | description |
| string |
| The message response of the cancel request. |
| long |
| The timestamp when the response is returned. |
{'message':'success','timestamp':1541161088303}
Retrieves open orders. This API endpoint requires your request to be signed.
1
GET /openapi/contract/v1/openOrders
Parameter | type | required | default | description |
| string |
| | Symbol to return open orders for. If not sent, orders of all contracts will be returned. |
| integer |
| | Order ID |
| string |
| | Direction of the order. Possible values include |
| string |
| | The order type, possible types: |
| integer |
|
| Number of entries to return. |
If orderId
is set, it will get orders < that orderId
. Otherwise most recent orders are returned.
Name | type | example | description |
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contracts. |
| float |
| Price of the order. |
| float |
| Leverage of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| | | Fees incurred for this order. |
[{'time': '1570760254539','updateTime': '0','orderId': '469965509788581888','clientOrderId': '1570760253946','symbol': 'BTC-PERP-REV','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'},...]
Retrieves history of orders that have been partially or fully filled or canceled. This API endpoint requires your request to be signed.
1
GET /openapi/contract/v1/historyOrders
Parameter | type | required | default | description |
| string |
| | Symbol to return open orders for. If not sent, orders of all contracts will be returned. |
| integer |
| | Order ID |
| string |
| | Direction of the order. Possible values include |
| string |
| | The order type, possible types: |
| integer |
|
| Number of entries to return. |
If orderId
is set, it will get orders < that orderId
. Otherwise most recent orders are returned.
Name | type | example | description |
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contracts. |
| float |
| Price of the order. |
| float |
| Leverage of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| | | Fees incurred for this order. |
[{'time': '1570759718825','updateTime': '0','orderId': '469961015902208000','clientOrderId': '6423344174','symbol': 'BTC-PERP-REV','price': '8200','leverage': '12.08','origQty': '5','executedQty': '0','avgPrice': '0','marginLocked': '0','orderType': 'LIMIT','side': 'BUY_OPEN','fees': [],'timeInForce': 'GTC','status': 'CANCELED','priceType': 'INPUT'},...]
Get details on a specific order, regardless of order state.
1
GET /openapi/contract/v1/getOrder
Parameter | type | required | default | description |
| integer |
| | Order ID. |
| string |
| | Unique client customized ID of the order. |
| string |
| | The order type, possible types: |
Either orderId
or clientOrderId
must be sent
Name | type | example | description |
| long |
| Timestamp when the order is created. |
| long |
| Last time this order was updated |
| integer |
| ID of the order. |
| string |
| A unique ID of the order. |
| string |
| Name of the contracts. |
| float |
| Price of the order. |
| float |
| Leverage of the order. |
| float |
| Quantity ordered |
| float |
| Quantity of orders that has been executed |
| float |
| Average price of filled orders. |
| float |
| Amount of margin locked for this order. This includes the actually margin needed plus fees to open and close the position. |
| string |
| The order type, possible types: |
| string |
| The price type. Possible values include |
| string |
| Direction of the order. Possible values include |
| string |
| The state of the order.Possible values include |
| string |
| Time in force. Possible values include |
| | | Fees incurred for this order. |
{'time': '1570760254539','updateTime': '0','orderId': '469965509788581888','clientOrderId': '1570760253946','symbol': 'BTC-PERP-REV','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'}
Retrieve the trade history of the account. This API endpoint requires your request to be signed.
1
GET /openapi/contract/v1/myTrades
Parameter | type | required | default | description |
| string |
| | Name of the contract. If not sent, trades for all symbols will be returned. |
| integer |
|
| The number of trades returned (clamped to max 1000) |
| string |
| | Direction of the order. |
| integer |
| | TradeId to fetch from. |
| integer |
| | TradeId to fetch to. |
Name | type | example | description |
| long |
| Timestamp when the order is created. |
| long |
| The ID for the trade |
| integer |
| ID of the order. |
| long |
| ID of the match order. |
| string |
| Name of the contract. |
| float |
| Price of the trade. |
| float |
| Quantity of the trade. |
| string |
| Fee token name. |
| | | Fee of the trade. |
| string |
| Direction of the order. Possible values include |
| string |
| The order type, possible types: LIMIT, MARKET |
[{'time': '1570760582848','tradeId': '469968263995080704','orderId': '469968263793737728',"matchOrderId": 436002617267469062,'accountId': '456552319339779840','symbolId': 'BTC-PERP-REV','price': '8531.17','quantity': '100','feeTokenId': 'TBTC','fee': '0.00000586','type': 'LIMIT','side': 'BUY_OPEN'},...]
Retrieves current positions. This API endpoint requires your request to be signed.
1
GET /openapi/contract/v1/positions
Parameter | type | required | default | description |
| string |
| | Name of the contract. If not sent, positions for all contracts will be returned. |
| string |
| |
|
Name | type | example | description |
| string |
| Name of the contract. |
| string |
| Position side. |
| float |
| Average price for opening the position. |
| float |
| Amount of contracts opened |
| float |
| Amount of contracts available to close. |
| float |
| Leverage of the position |
| float |
| Last trade price of the symbol. |
| float |
| Current position value. |
| float |
| Forced liquidation price. |
| float |
| Margin for this position. |
| float |
| Margin rate for current position. |
| float |
| Unrealized profit and loss for current position held. |
| float |
| Rate of return for the position. |
| float |
| Cumulative realized profit and loss for this |
[{'symbol': 'BTC-PERP-REV','side': 'LONG','avgPrice': '8183.11','position': '1100','available': '1100','leverage': '6','lastPrice': '8572.53','positionValue': '0.12833346','flp': '7523.65','margin': '0.01251335','marginRate': '0.14','unrealizedPnL': '0.00608975','profitRate':