Navbar

Change Log

2021-10-19

2021-10-18


Introduction

Account

Spot Account
Newly registered accounts will have a Spot (SPOT) account.


Basic Information

API Basic Information

Basic Information of Interfaces

API Key Setup

API Key Permission Setup


Access Restrictions

Basic Access Restrictions

IP Access Restrictions

Order Frequency Restrictions

WebSocket Basic Information


API Authentication Types

Authentication Type Description
NONE No authentication required for the interface
TRADE Requires a valid API Key and signature
MARGIN Requires a valid API Key and signature
USER_DATA Requires a valid API Key and signature
USER_STREAM Requires a valid API Key
MARKET_DATA Requires a valid API Key

SIGNED (TRADE, USER_DATA, and MARGIN) Endpoint Security

Time Synchronization Security


Enumeration Definitions

Order Types (orderTypes, type):

Order Sides (side):

K-Line Intervals:

Here is the translation of the content related to Spot Trading APIs:


Spot API

Spot WebSocket Market Data Push

Real-time Subscription/Unsubscription of Data Streams

Subscribe to a Data Stream

{ 
  "sub": ["BTCUSDT@Kline_1m"]
}

Unsubscribe from a Data Stream

{
  "cancel": ["BTCUSDT@Kline_1m"]
}

K-Line Data Push

Latest K-Line data push

StreamName: <symbol>@Kline_<interval>

K-Line interval options:

Response

{
  'closePrice': 27776.08,      # Closing price
  'count': 330,                # Number of transactions
  'highestPrice': 27783.06,    # Highest price
  'lowestPrice': 27774.98,     # Lowest price
  'openPrice': 27774.98,       # Opening price
  'period': '1min',            # K-Line interval
  'time': 1685432160000,       # Time
  'turnover': 397563.8825656,  # Transaction volume
  'volume': 14.31145           # Trade volume
}

Ticker Data Push

StreamName: <symbol>@ticker

Response

{
  'high': 28447.14,             # Highest price in 24 hours
  'lastDayClose': 0,             
  'low': 27546.0,               # Lowest price in 24 hours
  'open': 27272.17,             # Opening price in 24 hours
  'price': 27875.6,             # Latest transaction price
  'symbol': 'BTC/USDT',         # Trading pair
  'timestamp': 1685439793093,   # Timestamp
  'turnover': 945039033.2096055,# Transaction volume
  'volume': 63.8112             # Trade volume
}

Order Book Push

StreamName: <symbol>@plate

Response

{
  "bid": [{"price": 27875.6, "quantity": 63}, {"price": 27875.6, "quantity": 63}],
  "ask": [{"price": 27875.6, "quantity": 63}, {"price": 27875.6, "quantity": 63}]
}

Recent Trades

StreamName: <symbol>@trade

Response

[
  {
    "amount": 0.0690,                  # Quantity
    "buyOrderId": "E163471835947920",  # Buyer's order ID
    "buyTurnover": 266.8678500000,     # Buyer's transaction volume
    "direction": "SELL",               # Direction
    "price": 3867.650000,              # Price
    "sellOrderId": "E163471836299129", # Seller's order ID
    "sellTurnover": 266.8678500000,    # Seller's transaction volume
    "symbol": "ETH/USDT",        
    "time": 1634718363156              # Time
  }
]

Spot WebSocket Account Data Push

Generate ListenKey (USER_DATA)

GET /open/order_update_key

Response

{
  'code': 0, 
  'message': '',  
  'data': 'vYmf6uHNUKv1+DW77hJQ8g=='  # ListenKey
}

Order Data Update

Data will be pushed whenever the status of the current valid order changes.

Order Status:

StreamName: <symbol>@orders@<ListenKey>

Response

{
  'amount': 123.0,                        # Transaction amount
  'direction': 'BUY',                     # Direction
  'newClientOrderId': '311321114341131',  # Custom user-defined order ID
  'memberId': 35084,                
  'orderId': 'E168552607888820',          # Order ID
  'price': 1.0,                           # Price
  'status': 'COMPLETED',                  # Status
  'symbol': 'BTC/USDT',                   # Trading pair
  'tradedAmount': 0.004541,               # Transaction volume
  'turnover': 123.0,                      # Transaction turnover
  'type': 'MARKET_PRICE'                  # Order type
}

Spot Market APIs

Get K-Line Data

GET /open/history/kline

Parameters:

Name Type Required Description
symbol String YES Trading pair
period String YES K-Line interval
size int NO Number of results to retrieve

Response

[{
  'closePrice': 27776.08,      # Closing price
  'count': 330,                # Number of transactions
  'highestPrice': 27783.06,    # Highest price
  'lowestPrice': 27774.98,     # Lowest price
  'openPrice': 27774.98,       # Opening price
  'period': '1min',            # K-Line interval
  'time': 1685432160000,       # Time
  'turnover': 397563.8825656,  # Transaction turnover
  'volume': 14.31145           # Trade volume
}]

Get Supported Trading Pairs

GET /open/symbol_thumb

Response

[
  {
    "symbol": "BTC/USDT",
    "open": 41341.97,
    "high": 41518.81,
    "low": 40728.1,
    "close": 40930.26,
    "chg": -0.0102,
    "change": -411.71,
    "volume": 5.5142,
    "turnover": 5623362.5318740000000000,
    "lastDayClose": 41341.13,
    "usdRate": 40930.26,
    "baseUsdRate": 1,
    "zone": 0,
    "scale": 5,
    "baseScale": 2,
    "timestamp": 1702450378733,
    "coinSymbolLogo": "https://gsx-uexchange.s3.ap-south-1.amazonaws.com/chat_photo/coinLogo_1700043069568.svg",
    "baseSymbolLogo": "https://gsx-uexchange.s3.ap-south-1.amazonaws.com/chat_photo/coinLogo_1700043170734.svg",
    "coinSymbolName": "Bitcoin",
    "baseSymbolName": "USDT",
    "priceSize": "0.01"
  },
  {
    "symbol": "ETH/USDT",
    "open": 2192.43,
    "high": 2204.98,
    "low": 2150.58,
    "close": 2161.59,
    "chg": -0.0144,
    "change": -30.84,
    "volume": 907.7642,
    "turnover": 14705757.3477890000000000,
    "lastDayClose": 2192.43,
    "usdRate": 2161.59,
    "baseUsdRate": 1,
    "zone": 0,
    "scale": 4,
    "baseScale": 2,
    "timestamp": 1702450373615,
    "coinSymbolLogo": "https://gsx-uexchange.s3.ap-south-1.amazonaws.com/chat_photo/coinLogo_1700043087963.svg",
    "baseSymbolLogo": "https://gsx-uexchange.s3.ap-south-1.amazonaws.com/chat_photo/coinLogo_1700043170734.svg",
    "coinSymbolName": "Ethereum",
    "baseSymbolName": "USDT",
    "priceSize": "0.01"
  }
]

Get Recent Trade History

GET /open/trade_history

Parameters:

Name Type Required Description
symbol String YES Trading pair
size int YES Number of results to retrieve

Response

[
  {
    "amount": 0.0690,                  # Quantity
    "buyOrderId": "E163471835947920",  # Buyer's order ID
    "buyTurnover": 266.8678500000, # Buyer's transaction volume
    "direction": "SELL", # Direction
    "price": 3867.650000, # Price
    "sellOrderId": "E163471836299129", # Seller's order ID
    "sellTurnover": 266.8678500000, # Seller's transaction volume
    "symbol": "ETH/USDT",  
    "time": 1634718363156 # Time
    }
]

Spot Account and Trading API


Get Server Time (NONE)

Response

1499827319559  # Timestamp

GET /api/getServerTimestamp


Place an Order (TRADE)

Response

{
    "code": 0,
    "message": "success",
    "totalPage": null,
    "totalElement": null,
    "data": {
        "orderId": "E173397853621515",
        "memberId": 1836567906821896,
        "type": "LIMIT_PRICE",
        "amount": 1,
        "symbol": "INJ/USDT",
        "tradedAmount": 0,
        "turnover": 0,
        "coinSymbol": "INJ",
        "baseSymbol": "USDT",
        "status": "TRADING",
        "direction": "BUY",
        "price": 29,
        "time": 1733978536215,
        "completedTime": null,
        "canceledTime": null,
        "useDiscount": "0",
        "orderResource": "CUSTOMER",
        "strategyId": null,
        "fee": null,
        "newClientOrderId": "shg123123",
        "exchangeAccount": null,
        "orderType": null,
        "detail": null,
        "completed": true,
        "averagePrice": null,
        "hedgingAveragePrice": null
    }
}

POST /api/Order (HMAC SHA256)

Place an order.

Weight (UID): 1

Parameters:

Parameter Type Required Description
symbol STRING YES Trading pair
side ENUM YES Order direction (BUY or SELL)
type ENUM YES Order type (e.g., LIMIT_PRICE, MARKET_PRICE)
quantity DECIMAL NO Quantity of asset (for certain order types)
price DECIMAL NO Price for limit orders
newClientOrderId STRING NO Custom unique client order ID (auto-generated if not provided)
recvWindow LONG NO Maximum allowed window, not exceeding 60000
timestamp LONG YES Request timestamp

Required Parameters Based on type:

Order Type Required Parameters
LIMIT_PRICE quantity, price
MARKET_PRICE quantity

Additional Information:

Market vs Limit Order Price Rules:

Data Source: Database


Batch Order (TRADE)

Response

{
    "code": 0,
    "message": "success",
    "totalPage": null,
    "totalElement": null,
    "data": [
        {
        "orderId": "E173397853621515",
        "memberId": 1836567906821896,
        "type": "LIMIT_PRICE",
        "amount": 1,
        "symbol": "INJ/USDT",
        "tradedAmount": 0,
        "turnover": 0,
        "coinSymbol": "INJ",
        "baseSymbol": "USDT",
        "status": "TRADING",
        "direction": "BUY",
        "price": 29,
        "time": 1733978536215,
        "completedTime": null,
        "canceledTime": null,
        "useDiscount": "0",
        "orderResource": "CUSTOMER",
        "strategyId": null,
        "fee": null,
        "newClientOrderId": "shg123123",
        "exchangeAccount": null,
        "orderType": null,
        "detail": null,
        "completed": true,
        "averagePrice": null,
        "hedgingAveragePrice": null
    }
]
}

POST /api/batchOrders (HMAC SHA256)

Place an order.

Weight (UID): 1

Parameters:

Parameter Type Required Description
batchOrders list YES Order list, supports up to 5 orders
recvWindow LONG NO Maximum allowed window, not exceeding 60000
timestamp LONG YES Request timestamp

where batchOrders should fill in the order parameters in list of JSON format


Cancel Order (TRADE)

Response

Response: ""

DELETE /api/Order (HMAC SHA256)

Cancel an active order.

Weight (IP): 1

Parameters:

Parameter Type Required Description
symbol STRING YES Trading pair
orderId LONG NO System-generated order ID
newClientOrderId STRING NO Custom client ID for the order to be canceled
recvWindow LONG NO Maximum window for request, should not exceed 60000
timestamp LONG YES Request timestamp

Batch Cancel Order (TRADE)

Description

This endpoint allows you to batch cancel up to 10 orders. You can identify the orders using either orderIdList or origClientOrderIdList.

Request

Method: DELETE
Endpoint: /api/batchOrders

Parameters

Name Type Required Description
symbol STRING YES Trading pair, e.g., BTCUSDT.
orderIdList LIST NO System order numbers, supports up to 10 orders. Example: [1234567,2345678].
origClientOrderIdList LIST NO User-defined order numbers, supports up to 10 orders. Example: ["my_id_1","my_id_2"].
recvWindow LONG NO Optional; maximum value is 60000 (60 seconds).
timestamp LONG YES Current server time in milliseconds.

Note: Either orderIdList or origClientOrderIdList must be sent, but not both.


Query Order (USER_DATA)

Response

{
  "symbol": "LTCBTC",                       // Trading pair
  "orderId": 1,                             // System-generated order ID
  "orderListId": -1,                        // OCO order ID, -1 if none
  "newClientOrderId": "myOrder1",           // Custom client ID
  "price": "0.1",                           // Order price
  "origQty": "1.0",                         // Original quantity set by the user
  "executedQty": "0.0",                     // Quantity of the order executed
  "cummulativeQuoteQty": "0.0",             // Total quote value of executed order
  "status": "NEW",                          // Order status
  "timeInForce": "GTC",                     // Time in force
  "type": "LIMIT",                          // Order type (e.g., LIMIT, MARKET)
  "side": "BUY",                            // Order side (BUY or SELL)
  "stopPrice": "0.0",                       // Stop price (if applicable)
  "icebergQty": "0.0",                      // Iceberg order quantity (if applicable)
  "time": 1499827319559,                    // Order timestamp
  "updateTime": 1499827319559,              // Last update timestamp
  "isWorking": true,                        // Whether the order is still in the order book
  "origQuoteOrderQty": "0.000000"           // Original quote value of the order
}

GET /api/Order (HMAC SHA256)

Query the status of an order.

Weight (IP): 2

Parameters:

Parameter Type Required Description
symbol STRING YES Trading pair
orderId STRING NO Order ID
newClientOrderId STRING NO Custom client ID for the order
recvWindow LONG NO Maximum window for request, should not exceed 60000
timestamp LONG YES Request timestamp

Note:

Data Source: Database


Current Open Orders (USER_DATA)

Response

[
  {
    "symbol": "LTC/BTC",                   // Trading pair
    "orderId": 1,                           // System-generated order ID
    "orderListId": -1,                      // OCO order ID, -1 if none
    "clientOrderId": "myOrder1",            // Custom client ID
    "price": "0.1",                         // Order price
    "origQty": "1.0",                       // Original quantity set by the user
    "executedQty": "0.0",                   // Quantity of the order executed
    "cummulativeQuoteQty": "0.0",           // Total quote value of executed order
    "status": "NEW",                        // Order status
    "timeInForce": "GTC",                   // Time in force
    "type": "LIMIT",                        // Order type (LIMIT, MARKET, etc.)
    "side": "BUY",                          // Order side (BUY or SELL)
    "stopPrice": "0.0",                     // Stop price (if applicable)
    "icebergQty": "0.0",                    // Iceberg order quantity (if applicable)
    "time": 1499827319559,                  // Order timestamp
    "updateTime": 1499827319559,            // Last update timestamp
    "isWorking": true,                      // Whether the order is still in the order book
    "origQuoteOrderQty": "0.000000"         // Original quote value of the order
  }
]

GET /api/openOrders (HMAC SHA256)

Get all open orders for a specified trading pair. Be cautious when calling without the trading pair parameter.

Weight (IP): 3 for a single trading pair; 40 if no trading pair is specified.

Parameters:

Parameter Type Required Description
symbol STRING NO Trading pair
recvWindow LONG NO Maximum window for request, should not exceed 60000
timestamp LONG YES Request timestamp

Data Source: Database


Query All Orders (USER_DATA)

Response

[
  {
    "symbol": "LTCBTC",                   // Trading pair
    "orderId": 1,                         // System-generated order ID
    "orderListId": -1,                    // OCO order ID, -1 if none
    "clientOrderId": "myOrder1",          // Custom client ID
    "price": "0.1",                       // Order price
    "origQty": "1.0",                     // Original order quantity set by the user
    "executedQty": "0.0",                 // Executed order quantity
    "cummulativeQuoteQty": "0.0",         // Total quote value of executed order
    "status": "NEW",                      // Order status
    "timeInForce": "GTC",                 // Time in force
    "type": "LIMIT",                      // Order type (LIMIT, MARKET, etc.)
    "side": "BUY",                        // Order side (BUY or SELL)
    "stopPrice": "0.0",                   // Stop price (if applicable)
    "icebergQty": "0.0",                  // Iceberg order quantity (if applicable)
    "time": 1499827319559,                // Order timestamp
    "updateTime": 1499827319559,          // Last update timestamp
    "isWorking": true,                    // Whether the order is still in the order book
    "origQuoteOrderQty": "0.000000"       // Original quote value of the order
  }
]

GET /api/allOrders (HMAC SHA256)

Retrieve all account orders (valid, canceled, or completed).

Weight (IP): 10 (with symbol)

Parameters:

Parameter Type Required Description
symbol STRING YES Trading pair
orderId LONG NO Order ID
startTime LONG NO Start time for filtering orders
endTime LONG NO End time for filtering orders
limit INT NO Default 500; Max 1000.
recvWindow LONG NO Maximum window for request, should not exceed 60000
timestamp LONG YES Request timestamp

Note:

Data Source: Database


Account Information (USER_DATA)

Response

[
  {
    "address": "",                      // Account address
    "balance": 0,                        // Account balance
    "coin": {
      "accountType": 0,                  // Account type
      "allBalance": 0,                   // Total balance
      "blockHeight": 0,                  // Blockchain height
      "canAutoWithdraw": "",             // Auto-withdrawal permission
      "canRecharge": "",                 // Recharge permission
      "canTransfer": "",                 // Transfer permission
      "canWithdraw": "",                 // Withdrawal permission
      "cnyRate": 0,                      // CNY exchange rate
      "coinType": "",                    // Coin type
      "coldWalletAddress": "",           // Cold wallet address
      "depositAddress": "",              // Deposit address
      "enableRpc": "",                   // RPC status
      "hasLegal": true,                   // Legal currency status
      "hotAllBalance": 0,                 // Hot wallet balance
      "infolink": "",                    // Information link
      "information": "",                 // Additional information
      "isPlatformCoin": "",              // Platform coin status
      "mainCoinType": "",                // Main coin type
      "maxTxFee": 0,                     // Maximum transaction fee
      "maxWithdrawAmount": 0,             // Maximum withdrawal amount
      "minRechargeAmount": 0,             // Minimum recharge amount
      "minTxFee": 0,                     // Minimum transaction fee
      "minWithdrawAmount": 0,             // Minimum withdrawal amount
      "minerFee": 0,                     // Mining fee
      "name": "",                         // Coin name
      "nameCn": "",                       // Coin name (Chinese)
      "sort": 0,                          // Sorting order
      "status": "",                       // Account status
      "unit": "",                         // Unit of the coin
      "usdRate": 0,                       // USD exchange rate
      "withdrawScale": 0,                 // Withdrawal scale
      "withdrawThreshold": 0              // Withdrawal threshold
    },
    "frozenBalance": 0,                   // Frozen balance
    "id": 0,                              // Account ID
    "isLock": "",                         // Lock status
    "memberId": 0,                        // Member ID
    "memo": "",                           // Additional notes
    "toReleased": 0                       // Amount to be released
  }
]

GET /api/account (HMAC SHA256)

Retrieve current account information.

Weight (IP): 10

Parameters:

Parameter Type Required Description
recvWindow LONG NO Maximum window for request, should not exceed 60000
timestamp LONG YES Request timestamp

Data Source: Cache => Database


Account Trade History (USER_DATA)

Response

[
  {
    "symbol": "BNBBTC",              // Trading pair
    "id": 28457,                     // Trade ID
    "orderId": 100234,               // Order ID
    "orderListId": -1,               // OCO order ID, -1 if none
    "price": "4.00000100",           // Trade price
    "qty": "12.00000000",            // Trade quantity
    "quoteQty": "48.000012",         // Trade value (quote)
    "commission": "10.10000000",     // Commission amount
    "commissionAsset": "BNB",        // Commission asset type
    "time": 1499865549590,           // Trade timestamp
    "isBuyer": true,                 // Whether the user is the buyer
    "isMaker": false,                // Whether the user is the maker
    "isBestMatch": true,             // Whether the trade was the best match
    "type": "LIMIT_PRICE",           // Order type
    "amount": 1.0,                   // Order amount
    "tradedAmount": 1.0,             // Traded amount
    "turnover": 27570.0,             // Turnover value
    "status": "COMPLETED",           // Order status
    "direction": "BUY"               // Order direction (BUY or SELL)
  }
]

GET /api/myTrades (HMAC SHA256)

Retrieve the trade history for a specific trading pair.

Weight (IP): 10

Parameters:

Parameter Type Required Description
symbol STRING YES Trading pair
orderId LONG NO Must be used together with symbol
startTime LONG NO Start time for filtering trades
endTime LONG NO End time for filtering trades
fromId LONG NO Starting Trade ID. Defaults to the latest trade
limit INT NO Default is 500; Maximum is 1000
recvWindow LONG NO Maximum allowed window for the request (<= 60000)
timestamp LONG YES Request timestamp

Note:

Data Source: Database


Contract API

WebSocket Market Data Push

Real-time Subscription/Unsubscription of Data Streams

Subscribe to a Data Stream

{ 
  "sub": ["BTCUSDT@Kline_contract_1min"]
}

Unsubscribe from a Data Stream

{
  "cancel": ["BTCUSDT@Kline_contract_1min"]
}

K-line Data Push

StreamName: <symbol>@Kline_contract_<interval>

K-line intervals:

Response

{
  "closePrice": 27776.08,       // Close price
  "count": 330,                 // Number of trades
  "highestPrice": 27783.06,     // Highest price
  "lowestPrice": 27774.98,      // Lowest price
  "openPrice": 27774.98,        // Open price
  "period": "1min",             // K-line interval
  "time": 1685432160000,        // Timestamp
  "turnover": 397563.8825656,   // Trading volume
  "volume": 14.31145            // Quantity traded
}

Ticker Data Push

StreamName: <symbol>@ticker_contract

Response

{
  "high": 28447.14,             // Highest price in the last 24 hours
  "lastDayClose": 0,            // Close price from the previous day
  "low": 27546.0,               // Lowest price in the last 24 hours
  "open": 27272.17,             // Opening price for the day
  "price": 27875.6,             // Latest trade price
  "symbol": "BTC/USDT",         // Symbol
  "timestamp": 1685439793093,   // Timestamp
  "turnover": 945039033.2096055,// Turnover volume
  "volume": 63.8112             // Total traded volume
}

Generate ListenKey (USER_DATA)

GET /open/order_update_key

Response

{
  "code": 0, 
  "message": "vYmf6uHNUKv1+DW77hJQ8g==",   // ListenKey
  "totalPage": null, 
  "totalElement": null, 
  "data": null
}

Order Data Updates

When the status of an active order changes, data will be pushed.

Order Status:

StreamName: <symbol>@orders@<ListenKey>

Response

{
  "baseSymbol": "USDT",                        // Settlement currency
  "coinSymbol": "BTC",                         // Coin currency
  "contractId": 1,                             // Contract ID
  "contractOrderEntrustId": "CE168553470927350", // Contract system order ID
  "createTime": 1685534709273,                 // Creation time
  "currentPrice": 27100.7,                     // Order price when placed
  "direction": "BUY",                          // Order direction (BUY/SELL)
  "entrustPrice": 27110,                       // Entrusted price
  "entrustType": "OPEN",                       // Entrust type (OPEN/CLOSE)
  "isBlast": 0,                                // Whether the order is a liquidation order (0: No, 1: Yes)
  "isFromSpot": 0,                             // Whether the order is from spot (0: No, 1: Yes)
  "memberId": 35084,                           // User ID
  "openFee": 0.1,                              // Fee
  "patterns": "FIXED",                         // Position mode (e.g., Cross, Isolated)
  "principalAmount": 100.0,                    // Principal amount
  "principalUnit": "USDT",                     // Principal currency (e.g., USDT)
  "profitAndLoss": 0,                          // Profit and loss
  "shareNumber": 100.0,                        // Share quantity (USDT amount)
  "status": "ENTRUST_SUCCESS",                 // Order status
  "symbol": "BTC/USDT",                        // Contract symbol
  "tradedPrice": 27100.7,                      // Average trade price
  "tradedVolume": 10,                          // Volume traded
  "triggerPrice": 0,                           // Trigger price (if any)
  "triggeringTime": 0,                         // Trigger time (if any)
  "type": "LIMIT_PRICE",                       // Order type
  "volume": 10                                  // Order volume
}

Contract Account and Trading API

Query Supported Trading Pairs (NONE)

Endpoint: GET /contract-swap/symbol

Response Example:

[
  {
    "id": "1",
    "name": "BTC/USDT Perpetual Contract",  // Contract Name
    "symbol": "BTC/USDT",                   // Trading Pair
    "coinSymbol": "BTC",                    // Trading Coin
    "baseSymbol": "USDT"                    // Settlement Coin
  }
]

Query Current Order Book (NONE)

Endpoint: GET /contract-swap/exchange-plate

Response Example:

{
  "ask": {                     // Sell Orders
    "minAmount": 0.00010,       // Minimum Order Quantity for this price level
    "highestPrice": 58102.08,   // Highest Price in the Order Book
    "symbol": "BTC/USDT",       // Trading Pair
    "lowestPrice": 58011.41,    // Lowest Price in the Order Book
    "maxAmount": 2.549815,      // Maximum Order Quantity for this price level
    "items": [
      {
        "price": 58011.41,      // Order Price
        "amount": 0.566004      // Order Quantity
      },
      {
        "price": 58011.5,
        "amount": 0.001039
      }
    ],
    "direction": "SELL"
  },
  "bid": {                      // Buy Orders
    "minAmount": 0.00010,
    "highestPrice": 58011.4,
    "symbol": "BTC/USDT",
    "lowestPrice": 57918.01,
    "maxAmount": 1.838743,
    "items": [
      {
        "price": 58011.4,
        "amount": 0.012215
      },
      {
        "price": 58006.62,
        "amount": 0.01312
      }
    ],
    "direction": "BUY"
  }
}

Query Latest Trade Records (NONE)

Endpoint: GET /contract-swap/latest-trade

Response Example:

[
  {
    "symbol": "BTC/USDT",        // Trading Pair
    "price": 58011.4,            // Trade Price
    "amount": 0.000905,          // Trade Quantity
    "buyTurnover": null,
    "sellTurnover": 52.5003170,
    "direction": "SELL",         // Trade Direction
    "buyOrderId": null,
    "sellOrderId": "102560210048",
    "time": 1637338147157        // Trade Time
  }
]

Request Parameters:

Name Type Required Description
symbol STRING YES Trading Pair, e.g., BTC/USDT
size INT YES Number of records to query

Query Historical K-Line Data (NONE)

Endpoint: GET /contract-swap/history

Response Example:

[
  [
    1606838400000,       // Timestamp
    604.13,              // Opening Price
    609.11,              // Highest Price
    575.0,               // Lowest Price
    589.42,              // Closing Price
    59523720.0480131599  // Trade Volume
  ]
]

Request Parameters:

Name Type Required Description
symbol STRING YES Trading Pair, e.g., BTC/USDT
from LONG YES Start Time, e.g., 1637476202000
to LONG YES End Time, e.g., 1637908202563
resolution STRING YES Time Interval (1, 5, 15, 30, 60, 240, 1D, 1W, 1M)

Query All Contract Wallet Information (USER_DATA)

Endpoint: GET /contract-swap-wallet/list

Response Example:

{
  "data": [
    {
      "contractCoin": {
        "id": 1,
        "name": "BTC Perpetual contract",
        "symbol": "BTC/USDT",
        "coinSymbol": "BTC",
        "baseSymbol": "USDT",
        "sort": 1,
        "coinScale": 4,
        "baseCoinScale": 4,
        "type": "PERPETUAL",
        "enable": 1,
        "visible": 1,
        "exchangeable": 1,
        "enableOpenSell": 1,
        "enableOpenBuy": 1,
        "enableMarketSell": 1,
        "enableMarketBuy": 1,
        "enableTriggerEntrust": 1,
        "spreadType": 1,
        "spread": 0E-8,
        "leverageType": 1,
        "leverage": "10,20,30,40,50,60,70,80,90,100",
        "shareNumber": 100.00000000,
        "minShare": 1.00000000,
        "maxShare": 1000.00000000,
        "intervalHour": 8,
        "feePercent": 0.00100000,
        "maintenanceMarginRate": 0.00500000,
        "openFee": 0.00010000,
        "closeFee": 0.00010000,
        "takerFee": 0.00010000,
        "makerFee": 0.00010000,
        "totalProfit": 2166637.60691300,
        "totalLoss": 486591.95330400,
        "totalOpenFee": 3825.88000000,
        "totalCloseFee": 3653.18000000,
        "currentTime": null,
        "currentPrice": 58097.2,
        "usdtRate": 7.0
      },
      "usdtBalance": 0E-8,
      "usdtFrozenBalance": 0E-8,
      "usdtPattern": "FIXED",
      "usdtBuyLeverage": 10.00000000,
      "usdtSellLeverage": 10.00000000,
      "usdtBuyPosition": 0E-8,
      "usdtFrozenBuyPosition": 0E-8,
      "usdtBuyPrice": 0E-8,
      "usdtBuyPrincipalAmount": 0E-8,
      "usdtSellPosition": 0E-8,
      "usdtFrozenSellPosition": 0E-8,
      "usdtShareNumber": 0E-8,
      "usdtSellPrice": 0E-8,
      "usdtSellPrincipalAmount": 0E-8,
      "usdtProfit": null,
      "usdtLoss": null,
      "coinBalance": 0E-8,
      "coinFrozenBalance": 0E-8,
      "coinPattern": "FIXED",
      "coinBuyLeverage": 10.00000000,
      "coinSellLeverage": 10.00000000,
      "coinBuyPosition": 0E-8,
      "coinFrozenBuyPosition": 0E-8,
      "coinBuyPrice": 0E-8,
      "coinBuyPrincipalAmount": 0E-8,
      "coinSellPosition": 0E-8,
      "coinFrozenSellPosition": 0E-8,
      "coinShareNumber": 0E-8,
      "coinSellPrice": 0E-8,
      "coinSellPrincipalAmount": 0E-8,
      "usdtTotalProfitAndLoss": 0,
      "coinTotalProfitAndLoss": 0,
      "currentPrice": null,
      "cnyRate": 7
    }
  ],
  "code": 0,
  "message": "success",
  "totalPage": null,
  "totalElement": null
}

Fund Transfer (TRADE)

Response

Endpoint: POST /contract-swap-wallet/trans

Rate Limit (IP): 20

Parameters:

Name Type Required Description
unit STRING YES Currency unit for the transfer
from LONG YES Wallet type to transfer from (0 - Spot wallet, 1 - Contract wallet)
to LONG YES Wallet type to transfer to (0 - Spot wallet, 1 - Contract wallet)
fromWalletId LONG YES From wallet ID
toWalletId LONG YES To wallet ID
amount NUMBER YES Transfer amount

You can retrieve fromWalletId and toWalletId through the "Query All Contract Account Wallets" and "Account Information" APIs.


Open Contract Order (TRADE)

Response

{
  "code": 0, 
  "message": "Order successfully", 
  "totalPage": null, 
  "totalElement": null,
  "data": {
    "id": 1158, 
    "contractId": 1, 
    "memberId": 35084,
    "contractOrderEntrustId": "CE168553755909846",
    "patterns": "FIXED",
    "entrustType": "OPEN",
    "direction": "BUY", 
    "type": "LIMIT_PRICE", 
    "symbol": "BTC/USDT", 
    "coinSymbol": "BTC", 
    "baseSymbol": "USDT", 
    "triggerPrice": 27300, 
    "entrustPrice": 27300, 
    "tradedPrice": 0, 
    "principalUnit": "USDT",
    "principalAmount": 10.0,
    "currentPrice": 27100.0,
    "openFee": 0.01, 
    "closeFee": null,
    "shareNumber": 100.0, 
    "volume": 1, 
    "tradedVolume": 0,
    "profitAndLoss": 0,
    "status": "ENTRUST_ING",
    "createTime": 1685537559098,
    "triggeringTime": 0, 
    "isFromSpot": 0,
    "isBlast": 0,
    "isReward": 0
  }
}

Endpoint: POST /contract-swap-order/open

Rate Limit (IP): 20

Parameters:

Name Type Required Description
symbol STRING YES Contract trading pair symbol
direction LONG YES 0 - Long position, 1 - Short position
type LONG YES 0 - Market order, 1 - Limit order, 2 - Stop order
triggerPrice NUMBER YES Trigger price for stop orders, 0 for market and limit orders
entrustPrice NUMBER YES Entrust price (0 for market orders)
leverage NUMBER YES Leverage: 10, 20, 30, ..., 100
volume NUMBER YES Number of contracts (e.g., 1 contract)

Close Contract Order (TRADE)

Response

{
  "code": 0, 
  "message": "Order successfully", 
  "totalPage": null, 
  "totalElement": null,
  "data": {
    "id": 1158, 
    "contractId": 1, 
    "memberId": 35084,
    "contractOrderEntrustId": "CE168553755909846",
    "patterns": "FIXED",
    "entrustType": "OPEN",
    "direction": "BUY", 
    "type": "LIMIT_PRICE", 
    "symbol": "BTC/USDT", 
    "coinSymbol": "BTC", 
    "baseSymbol": "USDT", 
    "triggerPrice": 27300, 
    "entrustPrice": 27300, 
    "tradedPrice": 0, 
    "principalUnit": "USDT",
    "principalAmount": 10.0,
    "currentPrice": 27100.0,
    "openFee": 0.01, 
    "closeFee": null,
    "shareNumber": 100.0, 
    "volume": 1, 
    "tradedVolume": 0,
    "profitAndLoss": 0,
    "status": "ENTRUST_ING",
    "createTime": 1685537559098,
    "triggeringTime": 0, 
    "isFromSpot": 0,
    "isBlast": 0,
    "isReward": 0
  }
}

Endpoint: POST /contract-swap-order/close

Rate Limit (IP): 20

Parameters:

Name Type Required Description
symbol STRING YES Contract trading pair symbol
direction LONG YES 0 - Long position, 1 - Short position
type LONG YES 0 - Market order, 1 - Limit order, 2 - Stop order
triggerPrice NUMBER NO Trigger price for stop orders
entrustPrice NUMBER YES Entrust price (0 for market orders)
volume NUMBER YES Number of contracts (e.g., 1 contract)

Query Current Open Orders (USER_DATA)

Response

{
  "content": [
    {
      "id": 604,
      "contractId": 1, 
      "memberId": 600814,
      "contractOrderEntrustId": "CE163790762255990",
      "patterns": "FIXED",
      "entrustType": "OPEN",
      "direction": "BUY",
      "type": "LIMIT_PRICE",
      "symbol": "BTC/USDT",
      "coinSymbol": "BTC",
      "baseSymbol": "USDT",
      "triggerPrice": 0.00,
      "entrustPrice": 47733.65,
      "tradedPrice": 0.00,
      "principalUnit": "USDT",
      "principalAmount": 6.66660000,
      "currentPrice": 57710.38000000,
      "openFee": 0.02000000,
      "closeFee": null,
      "shareNumber": 100.00000000,
      "volume": 2.00000000,
      "tradedVolume": 0E-8,
      "profitAndLoss": 0E-8,
      "status": "ENTRUST_ING",
      "createTime": 1637907622559,
      "triggeringTime": 0,
      "isFromSpot": 0,
      "isBlast": 0,
      "isReward": 0
    }
  ],
  "pageable": {
    "sort": {
      "unsorted": false,
      "sorted": true
    },
    "pageSize": 50,
    "pageNumber": 0,
    "offset": 0,
    "paged": true,
    "unpaged": false
  },
  "last": true,
  "totalElements": 1,
  "totalPages": 1,
  "first": true,
  "numberOfElements": 1
}

Endpoint: GET /contract-swap-order/current

Rate Limit (IP): 20

Parameters:

Name Type Required Description
symbol STRING YES Contract trading pair symbol
pageNo INT YES Page number
pageSize INT YES Number of records per page

Cancel Open Contract Order (TRADE)

Endpoint: POST /contract-swap-order/cancel

Rate Limit (IP): 20

Parameters:

Name Type Required Description
entrustId STRING YES Entrust order ID, from the content.id in the order list response

Query Current Position Details (USER_DATA)

Endpoint: GET /contract-swap-order/position-detail

Rate Limit (IP): 20

Parameters:

Name Type Required Description
symbol STRING YES Contract trading pair symbol

Adjust Margin (USER_DATA)

Endpoint: GET /contract-swap-order/ajust-principal

Rate Limit (IP): 20

Parameters:

Name Type Required Description
symbol STRING YES Contract trading pair symbol
principal NUMBER YES Margin to adjust
direction STRING YES

Adjust Margin (USER_DATA)

Response

Endpoint: GET /contract-swap-order/ajust-principal

Rate Limit (IP): 20

Parameters:

Name Type Required Description
symbol STRING YES Contract trading pair symbol
principal NUMBER YES Margin to adjust
direction STRING YES Position direction (1 - Short, 0 - Long)
type LONG YES Action type (0 - Increase, 1 - Decrease)