REST API Edit
production environment: https://sapi.wexex.io
Basic Information of the Interface Edit
Due to reasons such as high latency and poor stability, it is not recommended to access the API through a proxy.
GET request parameters are placed in query Params, POST request parameters are placed in request body.
Please set the request header information to: Content-Type=application/json
For requests that start other than /public, the request message needs to be signed.
Frequency Limiting Rules Edit
Some interfaces will have limited flow control (the corresponding interface will have a limited flow description). The flow limit is mainly divided into gateway flow limit and WAF flow limit.
If the interface request triggers the gateway flow limit, 429 will be returned, indicating that the access frequency exceeds the limit, and the IP or apiKey will be blocked.
Gateway flow limiting is divided into:
- IP flow limiting
- apiKey flow limiting
Example descriptions:
-
IP flow limit:
100/s/ip- indicates the limit of the number of requests per second per IP for this interface. -
apiKey flow limit:
50/s/apiKey- indicates the limit of the number of requests per second per apiKey for this interface.
Signature Instructions Edit
Since WEX needs to provide some open interfaces for third-party platforms, the issue of data security needs to be considered.
Such as:
- Whether the data has been tampered with
- Whether the data is outdated
- Whether the data can be submitted repeatedly
- The access frequency of the interface
Among these, whether data has been tampered with is the most important issue.
Steps:
-
Appkey & Secretkey Apply for
appkeyandsecretkeyin the user center first, each user’s keys are different. -
Timestamp Add
timestamp. Its value should be the unix timestamp (milliseconds) of the time when the request is sent. The time of the data is calculated based on this value. -
Signature Add
signature, its value is obtained by the signature algorithm rule. -
RecvWindow Add
recvwindow(defines the valid time of the request). Valid time is fixed at a certain value. When a request is received, the server checks if: serverTime - timestamp < recvwindow. Any request older than 5000 ms is invalid. If the client’s timestamp is more than 1 second ahead of server time, the request is invalid. Note: Online conditions are not always 100% reliable. That’s why we provide therecvWindowparameter. For high-frequency trading, adjustrecvWindowto meet timeliness needs. RecvWindow longer than 5 seconds is not recommended. -
Algorithm Add
algorithms(signature method). Recommended:HmacSHA256. Supported algorithms: HmacMD5, HmacSHA1, HmacSHA224, HmacSHA256 (recommended), HmacSHA384, HmacSHA512
Signature generation Edit
Take https://sapi.wexex.io/v4/order as an example.
The following appKey/secret are for demo only (Linux bash with echo, openssl, curl):
appKey: 3976eb88-76d0-4f6e-a6b2-a57980770085
secretKey: bc6630d0231fda5cd98794f52c4998659beda290
Required Headers:
validate-algorithms: HmacSHA256
validate-appkey: 3976eb88-76d0-4f6e-a6b2-a57980770085
validate-recvwindow: 5000
validate-timestamp: 1641446237201
validate-signature: 2b5eb11e18796d12d88f13dc27dbbd02c2cc51ff7059765ed9821957d82bb4d9
Sample Request Body:
{
"type": "LIMIT",
"timeInForce": "GTC",
"side": "BUY",
"symbol": "btc_usdt",
"price": "39000",
"quantity": "2"
}
1. Data Part Concatenation (Y)
method: uppercase HTTP method, e.g. GET, POST, DELETE, PUT
path: concrete RESTful path after filling variables, e.g. /sign/test/bb/aa
query: sort all key=value by key (lexicographical), join with &. Example: userName=dfdfdf&password=ggg
body:
JSON: use the raw JSON string (no conversion/sorting)
x-www-form-urlencoded: sort all key=value by key (lexicographical), join with &. Example: userName=dfdfdf&password=ggg
form-data: not supported
If multiple forms exist, concatenate in order: path -> query -> body.
Method example:
POST
Path example:
/v4/order
The above concatenated value is recorded as path
Parameters passed query example:
symbol=btc_usdt
The above concatenated value is recorded as query
Parameters via body example:
x-www-form-urlencoded:
symbol=btc_usdt&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1
The above concatenated value is recorded as body
json:
{"symbol":"btc_usdt","side":"BUY","type":"LIMIT","timeInForce":"GTC","quantity":2,"price":39000}
The above concatenated value is recorded as body
Mixed use of query and body (divided into form and json format):
query:
symbol=btc_usdt&side=BUY&type=LIMIT
The above concatenated value is recorded as query
body:
{"symbol":"btc_usdt","side":"BUY","type":"LIMIT"}
The above concatenated value is recorded as body
Finally, splice by # with leading markers:
Y = #method#path#query#body
Notice:
query present, body empty: Y = #method#path#query
query empty, body present: Y = #method#path#body
both present: Y = #method#path#query#body
2. Header Part Concatenation (X)
Sort the following header keys in natural ascending alphabetical order, then join with &:
validate-algorithms=HmacSHA256&validate-appkey=3976eb88-76d0-4f6e-a6b2-a57980770085&validate-recvwindow=5000&validate-timestamp=1641446237201
3. Generate Signature
Concatenate original = X + Y (no delimiter beyond the # already in Y), then compute:
signature = org.apache.commons.codec.digest.HmacUtils.hmacSha256Hex(secretKey, original);
Add the generated value to the request header: validate-signature: <signature>
4. Complete Example
Sample original signature message:
validate-algorithms=HmacSHA256&validate-appkey=2063495b-85ec-41b3-a810-be84ceb78751&validate-recvwindow=60000&validate-timestamp=1666026215729#POST#/v4/order#{"symbol":"BTC_USDT","side":"BUY","type":"LIMIT","timeInForce":"GTC","bizType":"SPOT","price":3,"quantity":2}
Matters needing attention:
Ensure Content-Type, signature original message, and final request payload are consistent.
validate-timestamp should be milliseconds of the send time; pair with a reasonable validate-recvwindow to tolerate network jitter.
When body is JSON, use the exact raw JSON string for signing (don't reorder keys or prettify).
API Key Application Steps Edit
Some interfaces may require the user’s API Key. Please create your API Key in the user center of the WEX website or App.
Response Format Edit
All interface returns are in JSON format.
{
"rc": 0,
"result": {},
"mc": "SUCCESS",
"ma": []
}
Response Code Edit
HTTP Status Codes
| httpStatus | Description |
|---|---|
| 200 | The request is successful, please check the rc and mc sections further |
| 404 | Interface does not exist |
| 429 | The request is too frequent, please control the request rate according to the speed limit requirement |
| 500 | Service exception |
| 502 | Gateway exception |
| 503 | Service unavailable, please try again later |
Return Code (rc)
| rc | Description |
|---|---|
| 0 | Business success |
| 1 | Business failure |
Message Code (mc)
| mc | Message |
|---|---|
| SUCCESS | success |
| FAILURE | fail |
| AUTH_001 | Missing request header validate-appkey |
| AUTH_002 | Missing request header validate-timestamp |
| AUTH_003 | Missing request header validate-recvwindow |
| AUTH_004 | Bad request header validate-recvwindow |
| AUTH_005 | Missing request header validate-algorithms |
| AUTH_006 | Bad request header validate-algorithms |
| AUTH_007 | Missing request header validate-signature |
| AUTH_101 | ApiKey does not exist |
| AUTH_102 | ApiKey is not activated |
| AUTH_103 | Signature error |
| AUTH_104 | Unbound IP request |
| AUTH_105 | Outdated message |
| AUTH_106 | Exceeded apikey permission |
| SYMBOL_001 | Symbol not exist |
| SYMBOL_002 | Symbol offline |
| SYMBOL_003 | Symbol suspend trading |
| SYMBOL_004 | Symbol country disallow trading |
| SYMBOL_005 | The symbol does not support trading via API |
| SYMBOL_007 | The trading pair does not support order modification |
| SYMBOL_010 | This market does not support your trading |
| SYMBOL_011 | Due to high risk, this trading pair is temporarily restricted. Contact customer service for approval. |
| ORDER_001 | Platform rejection |
| ORDER_002 | Insufficient funds |
| ORDER_003 | Trading pair suspended |
| ORDER_004 | No transaction |
| ORDER_005 | Order not exist |
| ORDER_006 | Too many open orders |
| ORDER_007 | The sub-account has no transaction authority |
| ORDER_008 | The order price or quantity precision is abnormal |
| ORDER_F0101 | Trigger Price Filter - Min |
| ORDER_F0102 | Trigger Price Filter - Max |
| ORDER_F0103 | Trigger Price Filter - Step Value |
| ORDER_F0201 | Trigger Quantity Filter - Min |
| ORDER_F0202 | Trigger Quantity Filter - Max |
| ORDER_F0203 | Trigger Quantity Filter - Step Value |
| ORDER_F0301 | Trigger QUOTE_QTY Filter - Min Value |
| ORDER_F0401 | Trigger PROTECTION_ONLINE Filter or PROTECTION_LIMIT Filter |
| ORDER_F0501 | Trigger PROTECTION_LIMIT Filter - Buy Max Deviation |
| ORDER_F0502 | Trigger PROTECTION_LIMIT Filter - Sell Max Deviation |
| ORDER_F0503 | Trigger PROTECTION_LIMIT Filter - Buy Limit Coefficient |
| ORDER_F0504 | Trigger PROTECTION_LIMIT Filter - Sell Limit Coefficient |
| ORDER_F0601 | Trigger PROTECTION_MARKET Filter |
| ORDER_F0704 | Liquidation price limit for leveraged limit orders |
| COMMON_001 | The user does not exist |
| COMMON_002 | System busy, please try it later |
| COMMON_003 | Operation failed, please try it later |
| CURRENCY_001 | Currency information is abnormal |
| DEPOSIT_001 | Deposit is not open |
| DEPOSIT_002 | Security level low, bind 2FA (phone/email/Google) before deposit |
| DEPOSIT_003 | Incorrect address format |
| DEPOSIT_004 | Address already exists |
| DEPOSIT_005 | Cannot find offline wallet address |
| DEPOSIT_006 | No deposit address, try later |
| DEPOSIT_007 | Address is being generated |
| DEPOSIT_008 | Deposit not available |
| WITHDRAW_001 | Withdraw is not open |
| WITHDRAW_002 | Invalid withdrawal address |
| WITHDRAW_003 | Security level low, bind 2FA before withdraw |
| WITHDRAW_004 | Withdrawal address not added |
| WITHDRAW_005 | Withdrawal address cannot be empty |
| WITHDRAW_006 | Memo cannot be empty |
| WITHDRAW_008 | Risk control triggered, withdrawal not supported |
| WITHDRAW_009 | Withdraw failed, restricted by T+1 rule |
| WITHDRAW_010 | Invalid withdrawal precision |
| WITHDRAW_011 | Insufficient free balance |
| WITHDRAW_012 | Exceeded daily withdrawal limit |
| WITHDRAW_013 | Exceeded daily withdrawal limit, upgrade KYC for more |
| WITHDRAW_014 | Address cannot be used in internal transfer |
| WITHDRAW_015 | Amount not enough for fee |
| WITHDRAW_016 | Withdrawal address already exists |
| WITHDRAW_017 | Withdrawal processed, cannot cancel |
| WITHDRAW_018 | Memo must be a number |
| WITHDRAW_019 | Memo incorrect |
| WITHDRAW_020 | Reached daily withdrawal cap |
| WITHDRAW_021 | Withdrawal limited, max {0} this time |
| WITHDRAW_022 | Must be greater than {0} |
| WITHDRAW_023 | Must be less than {0} |
| WITHDRAW_024 | Withdraw not supported |
| WITHDRAW_025 | Please create FIO address on deposit page |
| FUND_001 | Duplicate request (bizId can only be requested once) |
| FUND_002 | Insufficient account balance |
| FUND_003 | Transfer not supported |
| FUND_004 | Unfreeze failed |
| FUND_005 | Transfer prohibited |
| FUND_014 | Transfer-in and transfer-out account IDs cannot be the same |
| FUND_015 | From and to business types cannot be the same |
| FUND_016 | Leverage transfer requires symbol |
| FUND_017 | Parameter error |
| FUND_018 | Invalid freeze record |
| FUND_019 | Freeze users not equal |
| FUND_020 | Freeze currency not equal |
| FUND_021 | Operation not supported |
| FUND_022 | Freeze record not exist |
| FUND_044 | Amount length max 113 |
| SYMBOL_001 | Symbol not exist |
| TRANSFER_001 | Duplicate request (bizId can only be requested once) |
| TRANSFER_002 | Insufficient balance |
| TRANSFER_003 | User not registered |
| TRANSFER_004 | Currency not transferable |
| TRANSFER_005 | User’s currency not transferable |
| TRANSFER_006 | Transfer prohibited |
| TRANSFER_007 | Request timed out |
| TRANSFER_008 | Abnormal transfer to leveraged account |
| TRANSFER_009 | Abnormal transfer from leveraged account |
| TRANSFER_010 | Leverage cleared, transfer prohibited |
| TRANSFER_011 | Leverage with borrowing, transfer prohibited |
| TRANSFER_012 | Currency transfer prohibited |
| GATEWAY_0001 | Trigger risk control |
| GATEWAY_0002 | Trigger risk control |
| GATEWAY_0003 | Trigger risk control |
| GATEWAY_0004 | Trigger risk control |
Public module Edit
Order state
| State | Description |
|---|---|
| NEW | The order has been accepted by the engine. |
| PARTIALLY_FILLED | A part of the order has been filled. |
| FILLED | The order has been completed. |
| CANCELED | The order has been canceled by the user. |
| REJECTED | The order was not accepted by the engine and not processed. |
| EXPIRED | The order has expired (e.g. Order canceled due to timeout or canceled due to premium) |
Order type
| Type | Description |
|---|---|
| LIMIT | Limit price order |
| MARKET | Market price order |
Symbol state
| State | Description |
|---|---|
| ONLINE | The symbol is online |
| OFFLINE | The symbol is offline |
| DELISTED | The symbol has been delisted |
Time in force
This sets how long an order will be active before expiration.
| TimeInForces | Description |
|---|---|
| GTC | It remains valid until the transaction is concluded. |
| IOC | Cancel the part that cannot be transacted immediately (taking orders) |
| FOK | Cancellation if all transactions cannot be completed immediately |
| GTX | Only pending orders, the triggering of transaction conditions will be cancelled immediately |
Deposit/Withdraw status
| Status | Description |
|---|---|
| SUBMIT | The withdrawal amount is not frozen. |
| REVIEW | The withdrawal amount has been frozen and is pending review. |
| AUDITED | The withdraw has been reviewed and is ready to on-chaining. |
| AUDITED_AGAIN | Reexamine |
| PENDING | The deposit or withdraw is already on-chaining. |
| SUCCESS | The deposit or withdraw is success. |
| FAIL | The deposit or withdraw failed. |
| CANCEL | The deposit or withdraw has been canceled by the user. |
BizType
| Status | Description |
|---|---|
| SPOT | Spot account |
| LEVER | Leverage account |
| FINANCE | Financial account |
| FUTURES_U | USDT-M futures account |
| FUTURES_C | COIN-M futures account |
FAQ Edit
-
AUTH_105 The server verifies the request header parameters
validate-timestamp(validTimeStamp) andvalidate-recvwindow(recvwindow).The following rules must be followed:
dealTimeStamp (server time when the request is processed, in milliseconds) - validTimeStamp < recvwindow
Otherwise AUTH_105 will be returned.
To avoid this error:
validate-timestampis recommended to use the time when the request was sent, in milliseconds.validate-recvwindowshould be set a little larger.
Contact us Edit
WEX API Telegram Group: WEX API Support Group
- For any general questions about the API not covered in the documentation.
- For any MM questions
WEX Customer Support: Website and App online customer service
- For cases such as missing funds, help with 2FA, etc.
Get server time Edit
/v4/public/time
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"serverTime": 1662435658062
}
}
Get client ip Edit
/v4/public/client
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"ip": "192.168.1.1"
}
}
Get symbol information Edit
/v4/public/symbol
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | trading pair eg:btc_usdt | ||
| symbols | array | false | Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt | ||
| version | string | false | Version number, if request version equals response version, list will not be returned (reduce IO). eg: 2e14d2cd5czcb2c2af2c1db6 |
Limit Flow Rules
1.single symbol:10/s/ip
2.multiple symbols:10/s/ip
FILTER
PRICE FILTER
min: minimum price allowedmax: maximum price allowedtickSize: step interval → price = minPrice + (integer * tickSize)
Logical pseudocode:
- price >= min
- price <= max
- (price-minPrice) % tickSize == 0
QUANTITY FILTER
min: minimum allowedmax: maximum allowedtickSize: step interval
Logical pseudocode:
- quantity >= min
- quantity <= max
- (quantity-minQuantity) % tickSize == 0
QUOTE_QTY FILTER
- If
minis null → no restriction - LIMIT orders → price * quantity >= min
- MARKET BUY orders → quoteQty >= min
PROTECTION_LIMIT FILTER
buyMaxDeviation,buyPriceLimitCoefficient,sellMaxDeviation,sellPriceLimitCoefficient
Buy: price >= latestPrice - latestPrice * buyMaxDeviation
price <= latestPrice + latestPrice * buyPriceLimitCoefficient
Sell: price <= latestPrice + latestPrice * sellMaxDeviation
price >= latestPrice - latestPrice * sellPriceLimitCoefficient
PROTECTION_MARKET FILTER
maxDeviation: maximum deviation
Buy: latestPrice + latestPrice * maxDeviation >= sellBestPrice
Sell: latestPrice - latestPrice * maxDeviation <= buyBestPrice
PROTECTION_ONLINE FILTER
maxPriceMultiple,durationSeconds
price <= openPrice * maxPriceMultiple
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"time": 1662444177871,
"version": "7cd2cfab0dc979339f1de904bd90c9cb",
"symbols": [
{
"symbol": "btc_usdt", //trading pair
"state": "ONLINE", //trading pair status [ONLINE=online;OFFLINE=offline,DELISTED=delisted]
"tradingEnabled": true, //is trading enabled
"openapiEnabled": true, //is OPENAPI enabled
"nextStateTime": null, //next state timestamp
"nextState": null, //next state
"depthMergePrecision": 5, //depth merge precision
"baseCurrency": "btc", //base asset
"baseCurrencyPrecision": 5, //base asset precision
"quoteCurrency": "usdt", //quote asset
"quoteCurrencyPrecision": 6, //quote asset precision
"pricePrecision": 4, //price precision
"quantityPrecision": 6, //quantity precision
"takerFeeRate": 0.001, //taker fee rate
"makerFeeRate": 0.002, //maker fee rate
"orderTypes": [ //order types [LIMIT=limit order;MARKET=market order]
"LIMIT",
"MARKET"
],
"timeInForces": [ //time-in-force [GTC=good till canceled; IOC=immediate or cancel; FOK=fill or kill; GTX=post-only cancel]
"GTC",
"FOK",
"IOC",
"GTX"
],
"displayWeight": 1, //display weight, higher value is displayed first
"displayLevel": "FULL", //display level [FULL=full display;SEARCH=search display;DIRECT=direct access;NONE=do not display]
"filters": [
{
"filter": "PROTECTION_LIMIT",
"buyMaxDeviation": "0.8",
"sellMaxDeviation": "0.8"
},
{
"filter": "PROTECTION_MARKET",
"maxDeviation": "0.1"
},
{
"filter": "PROTECTION_ONLINE",
"durationSeconds": "300",
"maxPriceMultiple": "5"
},
{
"filter": "PRICE",
"min": null,
"max": null,
"tickSize": null
},
{
"filter": "QUANTITY",
"min": null,
"max": null,
"tickSize": null
},
{
"filter": "QUOTE_QTY",
"min": null
}
]
}
]
}
}
Get depth data Edit
/v4/public/depth
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | trading pair eg:btc_usdt | ||
| limit | number | false | 100 | minimum number of queries is 100 | 1~500 |
Limit Flow Rules
10/s/ip
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"timestamp": 1662445330524, //timestamp
"lastUpdateId": 137333589606963580, //last update ID
"bids": [ //bids [price, order quantity]
[
"200.0000",
"0.996000"
],
[
"100.0000",
"0.001000"
],
[
"20.0000",
"10.000000"
]
],
"asks": [] //asks [price, order quantity]
}
}
Get K-line data Edit
/v4/public/kline
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | trading pair eg:btc_usdt | ||
| interval | string | true | K line type, eg:1m | [1m;3m;5m;15m;30m;1h;2h;4h;6h;8h;12h;1d;3d;1w;1M] | |
| startTime | number | false | start timestamp | ||
| endTime | number | false | end timestamp | ||
| limit | number | false | 100 | 1~1000 |
Limit Flow Rules
10/s/ip
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"t": 1662601014832, //open time
"o": "30000", //open price
"c": "32000", //close price
"h": "35000", //highest price
"l": "25000", //lowest price
"q": "512", //transaction quantity
"v": "15360000" //transaction volume
}
]
}
Query the list of recent transactions Edit
/v4/public/trade/recent
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | trading pair | ||
| limit | number | false | 200 | 1~1000 |
Limit Flow Rules
10/s/ip
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"i": 0, //ID
"t": 0, //trade time
"p": "string", //trade price
"q": "string", //trade quantity
"v": "string", //trade volume
"b": true //whether buyer is the maker
}
]
}
Query historical transaction list Edit
/v4/public/trade/history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | trading pair | ||
| limit | number | false | 200 | 1~1000 | |
| direction | string | true | query direction | PREV - previous page, NEXT - next page | |
| fromId | number | false | Start ID, e.g. 6216559590087220004 |
Limit Flow Rules
10/s/ip
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"i": 0, //ID
"t": 0, //trade time
"p": "string", //trade price
"q": "string", //trade quantity
"v": "string", //trade amount
"b": true //whether the buyer is the maker
}
]
}
Full ticker Edit
/v4/public/ticker
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | trading pair eg:btc_usdt | ||
| symbols | array | false | Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt | ||
| tags | string | false | Set of tags, separated by commas, currently only supports spot |
Limit Flow Rules
1.single symbol:10/s/ip
2.multiple symbols:10/s/ip
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": [
{
"s": "btc_usdt", //trading pair
"t": 1662444879425, //update time
"cv": "0.00", //price change
"cr": "0.0000", //price change percentage
"o": "200.00", //opening price (first trade)
"l": "200.00", //lowest price
"h": "200.00", //highest price
"c": "200.00", //closing price (last trade)
"q": "0.002", //trading volume
"v": "0.40", //trading value
"ap": null, //best ask price
"aq": null, //best ask quantity
"bp": null, //best bid price
"bq": null //best bid quantity
}
]
}
Get latest prices ticker Edit
/v4/public/ticker/price
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | trading pair eg:btc_usdt | ||
| symbols | array | false | Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt | ||
| tags | string | false | Set of tags, separated by commas, currently only supports spot |
Limit Flow Rules
1.single symbol:10/s/ip
2.multiple symbols:10/s/ip
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": [
{
"s": "btc_usdt", //trading pair
"t": 1661856036925, //timestamp
"p": "9000.0000" //price
}
]
}
Get the best pending order ticker Edit
/v4/public/ticker/book
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | trading pair eg:btc_usdt | ||
| symbols | array | false | Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt | ||
| tags | string | false | Set of tags, separated by commas, currently only supports spot |
Limit Flow Rules
1.single symbol:10/s/ip
2.multiple symbols:10/s/ip
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": [
{
"s": "btc_usdt", //trading pair
"t": 1661856036925, //update time
"ap": null, //best ask price
"aq": null, //best ask quantity
"bp": null, //best bid price
"bq": null //best bid quantity
}
]
}
Get 24h statistics ticker Edit
/v4/public/ticker/24h
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | trading pair eg:btc_usdt | ||
| symbols | array | false | Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt | ||
| tags | string | false | Set of tags, separated by commas, currently only supports spot |
Limit Flow Rules
1.single symbol:10/s/ip
2.multiple symbols:10/s/ip
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": [
{
"s": "btc_usdt", //symbol
"t": 1661856036925, //time
"cv": "0.0000", //price change value
"cr": "0.00", //price change rate
"o": "9000.0000", //open price
"l": "9000.0000", //lowest price
"h": "9000.0000", //highest price
"c": "9000.0000", //close price
"q": "0.0136", //transaction quantity
"v": "122.9940" //transaction volume
}
]
}
Get single Edit
/v4/order/{orderId}
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | number | true | Order ID |
Limit Flow Rules
10/s/apikey
public String orderGet(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"symbol": "BTC_USDT",
"orderId": "6216559590087220004",
"clientOrderId": "16559590087220001",
"baseCurrency": "string",
"quoteCurrency": "string",
"side": "BUY", //order side: BUY, SELL
"type": "LIMIT", //order type: LIMIT, MARKET
"timeInForce": "GTC", //effective way: GTC, IOC, FOK, GTX
"price": "40000",
"origQty": "2", //original quantity
"origQuoteQty": "48000", //original amount
"executedQty": "1.2", //executed quantity
"leavingQty": "string", //remaining quantity (0 if cancelled or rejected)
"tradeBase": "2", //transaction quantity
"tradeQuote": "48000", //transaction amount
"avgPrice": "42350", //average transaction price
"fee": "string", //handling fee
"feeCurrency": "string",
"state": "NEW", //order state: NEW, PARTIALLY_FILLED, FILLED, CANCELED, REJECTED, EXPIRED
"time": 1655958915583, //order time
"ip": "127.0.0.1", //IP address
"updatedTime": 1655958915583
}
}
Query single Edit
/v4/order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | number | false | Order ID | ||
| clientOrderId | string | false | Client order ID |
Limit Flow Rules
50/s/apikey
public String orderGet(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"symbol": "BTC_USDT",
"orderId": "6216559590087220004",
"clientOrderId": "16559590087220001",
"baseCurrency": "string",
"quoteCurrency": "string",
"side": "BUY", //Order side: BUY, SELL
"type": "LIMIT", //Order type: LIMIT, MARKET
"timeInForce": "GTC", //Effective way: GTC, IOC, FOK, GTX
"price": "40000",
"origQty": "2", //Original quantity
"origQuoteQty": "48000", //Original amount
"executedQty": "1.2", //Executed quantity
"leavingQty": "string", //Remaining quantity (0 if cancelled or rejected)
"tradeBase": "2", //Transaction quantity
"tradeQuote": "48000", //Transaction amount
"avgPrice": "42350", //Average transaction price
"fee": "string", //Handling fee
"feeCurrency": "string",
"state": "NEW", //Order state
"time": 1655958915583, //Order creation time
"updatedTime": 1655958915583 //Last updated time
}
}
Submit order Edit
/v4/order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | |||
| clientOrderId | string | false | Pattern: ^[a-zA-Z0-9_]{4,22}$ | ||
| side | string | true | BUY,SELL | ||
| type | string | true | order type:LIMIT,MARKET | ||
| timeInForce | string | true | effective way:GTC, FOK, IOC, GTX | ||
| bizType | string | true | SPOT, LEVER | ||
| price | number | false | price. Required if it is the LIMIT price; blank if it is the MARKET price | ||
| quantity | number | false | quantity. Required if it is the LIMIT price or the order is placed at the market price by quantity | ||
| quoteQty | number | false | amount. Required if it is the LIMIT price or the order is the market price when placing an order by amount | ||
| nftId | string | false | nft id |
Remark
Create a BUY order based on market price, quantity must be null, quoteQty required. Create a SELL order based on market price, quoteQty must be null, quantity required.
Limit Flow Rules
20/s/apikey
public String orderPost(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"orderId": "6216559590087220004",
"ip": "127.0.0.1"
}
}
Cancel order Edit
/v4/order/{orderId}
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | number | true |
Limit Flow Rules
N/A
public String orderDel(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"cancelId": "6216559590087220004"
}
}
Get batch Edit
/v4/batch-order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderIds | string | true | order Ids eg: 6216559590087220004, 6216559590087220004 |
Response field information, refer to the Get single interface.
public String batchOrderGet(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"symbol": "BTC_USDT",
"orderId": "6216559590087220004",
"clientOrderId": "16559590087220001",
"baseCurrency": "string",
"quoteCurrency": "string",
"side": "BUY",
"type": "LIMIT",
"timeInForce": "GTC",
"price": "40000",
"origQty": "2",
"origQuoteQty": "48000",
"executedQty": "1.2",
"leavingQty": "string",
"tradeBase": "2",
"tradeQuote": "48000",
"avgPrice": "42350",
"fee": "string",
"feeCurrency": "string",
"state": "NEW",
"time": 1655958915583,
"ip": "127.0.0.1",
"updatedTime": 1655958915583
}
]
}
Submit batch order Edit
/v4/batch-order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| clientBatchId | string | false | Client batch number. Pattern: ^[a-zA-Z0-9_]{4,32}$ | ||
| items | array | true | Array | ||
| item.symbol | string | true | Trading pair | ||
| item.clientOrderId | string | false | Pattern: ^[a-zA-Z0-9_]{4,32}$ | ||
| item.side | string | true | Order side | BUY, SELL | |
| item.type | string | true | Order type | LIMIT, MARKET | |
| item.timeInForce | string | true | Effective way | GTC, FOK, IOC, GTX | |
| item.bizType | string | true | Business type | SPOT, LEVER | |
| item.price | number | false | Price. Required if it is LIMIT; blank if it is MARKET | ||
| item.quantity | number | false | Quantity. Required if it is LIMIT or MARKET by quantity | ||
| item.quoteQty | number | false | Amount. Required if it is LIMIT or MARKET by amount |
Limit Flow Rules
30/s/apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"batchId": "123",
"items": [
{
"index": "0",
"clientOrderId": "123",
"orderId": "123",
"reject": "false",
"reason": "invalid price precision"
}
]
}
}
Cancel batch order Edit
/v4/batch-order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| clientBatchId | string | false | client batch id | ||
| orderIds | array | true | 6216559590087220004, 6216559590087220005 |
Note: The parameters should be placed in the request body in the form of JSON.
public String batchOrderDel(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {}
}
Query the current pending order Edit
/v4/open-order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair, if not filled in, represents all | ||
| bizType | string | false | SPOT, LEVER | ||
| side | string | false | BUY, SELL |
Limit Flow Rules
10/s/apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"symbol": "BTC_USDT",
"orderId": "6216559590087220004",
"clientOrderId": "16559590087220001",
"baseCurrency": "string",
"quoteCurrency": "string",
"side": "BUY",
"type": "LIMIT",
"timeInForce": "GTC",
"price": "40000",
"origQty": "2",
"origQuoteQty": "48000",
"executedQty": "1.2",
"leavingQty": "string",
"tradeBase": "2",
"tradeQuote": "48000",
"avgPrice": "42350",
"fee": "string",
"feeCurrency": "string",
"state": "NEW",
"time": 1655958915583,
"ip": "127.0.0.1",
"updatedTime": 1655958915583
}
]
}
Cancel the current pending order Edit
/v4/open-order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair, if not filled in, represents all | ||
| bizType | string | true | SPOT, LEVER | ||
| side | string | false | BUY, SELL |
Limit Flow Rules
10/s/apikey
Note: The parameters should be placed in the request body in the form of JSON.
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {}
}
Query historical orders Edit
/v4/history-order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair, if not filled in, represents all | ||
| bizType | string | false | SPOT, LEVER | ||
| side | string | false | BUY, SELL | ||
| type | string | false | LIMIT, MARKET | ||
| state | string | false | order state, PARTIALLY_FILLED, FILLED, CANCELED, REJECTED, EXPIRED | ||
| fromId | number | false | Start ID | ||
| direction | string | false | query direction:PREV, NEXT | ||
| limit | number | false | 20 | Limit number, max 100 | |
| startTime | number | false | Start time (e.g. 1657682804112) | ||
| endTime | number | false | End time | ||
| hiddenCanceled | bool | false | Whether to hide canceled orders |
Limit Flow Rules
10/s/apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"hasPrev": true,
"hasNext": true,
"items": [
{
"symbol": "BTC_USDT",
"orderId": "6216559590087220004",
"clientOrderId": "16559590087220001",
"baseCurrency": "string",
"quoteCurrency": "string",
"side": "BUY",
"type": "LIMIT",
"timeInForce": "GTC",
"price": "40000",
"origQty": "2",
"origQuoteQty": "48000",
"executedQty": "1.2",
"leavingQty": "string",
"tradeBase": "2",
"tradeQuote": "48000",
"avgPrice": "42350",
"fee": "string",
"feeCurrency": "string",
"state": "NEW",
"time": 1655958915583,
"ip": "127.0.0.1",
"updatedTime": 1655958915583
}
]
}
}
Update Order(Limit) Edit
/v4/order/{orderId}
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | number | true | order ID | ||
| price | number | true | Price | ||
| quantity | number | true | Quantity |
Limit Flow Rules
50/s/apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"orderId": "6216559590087220004",
"modifyId": "407329711723834560"
}
}
Query trade Edit
/v4/trade
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair, if not filled, represents all | ||
| bizType | string | false | Business type: SPOT, LEVER | ||
| orderSide | string | false | Order side: BUY, SELL | ||
| orderType | string | false | Order type: LIMIT, MARKET | ||
| orderId | number | false | Order ID | ||
| fromId | number | false | Start ID | ||
| direction | string | false | Query direction: PREV, NEXT | ||
| limit | number | false | 20 | Limit number, max 100 | |
| startTime | number | false | Start time (e.g. 1657682804112) | ||
| endTime | number | false | End time |
This endpoint retrieves trade records. Supports filtering by trading pair, business type, side, order type, time range, and pagination.
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"hasPrev": true,
"hasNext": true,
"items": [
{
"symbol": "BTC_USDT", // Trading pair
"tradeId": "6316559590087222001", // Trade ID
"orderId": "6216559590087220004", // Order ID
"orderSide": "BUY", // Order direction
"orderType": "LIMIT", // Order type
"bizType": "SPOT", // Business type
"time": 1655958915583, // Trade time
"price": "40000", // Trade price
"quantity": "1.2", // Trade quantity
"quoteQty": "48000", // Trade amount
"baseCurrency": "BTC", // Base currency
"quoteCurrency": "USDT", // Quote currency
"takerMaker": "taker", // Taker/Maker
"deductType": "COUPON", // Fee deduction type: COUPON / PLATFORM_CURRENCY / null
"deductFee": "0.003", // Deducted fee amount if using coupon; otherwise null
"fee": "0.5", // Fee amount (or platform currency amount if deducted)
"feeCurrency": "USDT", // Fee currency
"couponAmount": "0.002", // Coupon amount if used; otherwise null
"couponCurrency": "usdt" // Coupon currency if used; otherwise null
}
]
}
}
Get currency information Edit
/v4/public/currencies
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"id": 11, // currency id
"currency": "usdt", // currency symbol
"fullName": "usdt", // full currency name
"logo": null, // currency logo
"cmcLink": null, // CoinMarketCap link
"weight": 100, // weight / ranking
"maxPrecision": 6, // maximum precision
"depositStatus": 1, // deposit status (0 closed, 1 open)
"withdrawStatus": 1, // withdrawal status (0 closed, 1 open)
"convertEnabled": 1, // small asset conversion (0 closed, 1 open)
"transferEnabled": 1 // transfer switch (0 closed, 1 open)
}
]
}
Get a single currency asset Edit
/v4/balance
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| currency | string | true | Currency, e.g. usdt |
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"currency": "usdt", // currency
"currencyId": 0, // currency ID
"frozenAmount": 0, // frozen amount
"availableAmount": 0, // available amount
"totalAmount": 0, // total amount
"convertBtcAmount": 0 // equivalent BTC amount
}
}
Get a list of currency assets Edit
/v4/balances
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| currencies | string | false | List of currencies, comma separated, e.g. usdt,btc |
Limit Rule
10 requests/second/apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"totalBtcAmount": 0,
"assets": [
{
"currency": "string", // currency
"currencyId": 0, // currency ID
"frozenAmount": 0, // frozen amount
"availableAmount": 0, // available amount
"totalAmount": 0, // total amount
"convertBtcAmount": 0 // converted BTC amount
}
]
}
}
Get information of currencies (available for deposit and withdraw) Edit
/v4/public/wallet/support/currency
Remark
The currency and chain in the response need to be used in other deposit/withdrawal API
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"currency": "BTC", //currency name
"supportChains": [
{
"chain": "Bitcon", //supported transfer network
"depositEnabled": true, //deposit is supported or not
"withdrawEnabled": true //withdraw is supported or not
"withdrawFeeAmount": 0.2, //withdraw fee
"withdrawMinAmount": 10, //minimum withdrawal amount
"depositFeeRate": 0.2 //deposit fee rate
}
]
},
{
"currency": "ETH", //currency name
"supportChains": [
{
"chain": "Ethereum", //supported transfer network
"depositEnabled": true, //deposit is supported or not
"withdrawEnabled": true //withdraw is supported or not
"withdrawFeeAmount": 0.2, //withdraw fee
"withdrawMinAmount": 10, //minimum withdrawal amount
"depositFeeRate": 0.2 //deposit fee rate
}
]
}
]
}
Get the deposit address Edit
/v4/deposit/address
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| chain | string | true | network for deposit | ||
| currency | string | true | currency name |
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"address": "0xfa3abfa50eb2006f5be7831658b17aca240d8526", //wallet address
"memo": ""
}
}
Get history records of deposit Edit
/v4/deposit/history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| currency | string | false | Currency name, can be obtained from the response of "Get the supported currencies for deposit or withdrawal" API | ||
| chain | string | false | Transfer networks, can be obtained from the response of "Get the supported currencies for deposit or withdrawal" API | ||
| status | string | false | The status of deposit | SUBMIT、REVIEW、AUDITED、PENDING、SUCCESS、FAIL、CANCEL | |
| fromId | long | false | Start ID, e.g. 6216559590087220004 | ||
| direction | string | false | NEXT | query direction | query direction:PREV, NEXT |
| limit | int | false | 10 | Limit number, max 200 | 1<=limit<=200 |
| startTime | long | false | Start time used for filtering deposit list, timestamp in milliseconds | ||
| endTime | long | false | End time used for filtering deposit list, timestamp in milliseconds |
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"hasPrev": true, //Is there a previous page
"hasNext": true, //Is there a next page
"items": [
{
"id": 169669597, //Unique ID of the deposit record
"currency": "xlm2", //Currency name
"chain": "XLM", //Transfer Network
"memo": "441824256", //memo
"status": "SUCCESS", //The status of deposit
"amount": "0.1", //Deposit amount
"confirmations": 12, //Number of block confirmations
"transactionId": "28dd15b5c119e00886517f129e5e1f8283f0286b277bcd3cd1f95f7fd4a1f7fc", //Unique ID of transaction
"address": "GBY6UIYEYLAAXRQXVO7X5I4BSSCS54EAHTUILXWMW6ONPM3PNEA3LWEC", //Target address of deposit
"fromAddr": "GBTISB3JK65DG6LEEYYFW33RMMDHBQ65AEUPE5VDBTCLYYFS533FTG6Q", //From address of deposit
"createdTime": 1667260957000 //Time of deposit record in millisecondstime
}
]
}
}
Withdraw Edit
/v4/withdraw
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| currency | string | true | Currency name, which can be obtained from the 'Get the supported currencies for deposit or withdrawal' interface | ||
| chain | string | true | The name of the transfer network, which can be obtained from the interface of 'Get the supported currencies for deposit or withdrawal' interface | ||
| amount | number | true | Withdrawal amount, including handling fee | ||
| address | string | true | Withdrawal address | ||
| memo | String | false | memo,For EOS similar chains that require memo must be transferred |
Note: The parameters are placed in the body in the form of json
{
"currency":"zb",
"chain":"Ethereum",
"amount":1000,
"address":"0xfa3abfa50eb2006f5be7831658b17aca240d8526",
"memo":""
}
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"id": 100 //Long Withdrawal record id, used for querying withdrawal history later
}
}
Withdrawal history Edit
/v4/withdraw/history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| currency | string | false | Currency name, which can be obtained from the 'Get the supported currencies for deposit or withdrawal' interface | ||
| chain | string | false | The name of the transfer network, which can be obtained from the interface of 'Get the supported currencies for deposit or withdrawal' interface | ||
| status | string | false | The status of the withdrawal record, string type,Refer to public module-Deposit/withdrawal status | SUBMIT、REVIEW、AUDITED、AUDITED_AGAIN、PENDING、SUCCESS、FAIL、CANCEL | |
| fromId | Long | false | The Id of the last pagination, that is, the primary key id of the record | ||
| direction | String | false | NEXT | Page direction | NEXT:next page,PREV:previous page |
| limit | int | false | 10 | Number of records per page, maximum 200 | 1<=limit<=200 |
| startTime | Long | false | Query range start boundary, timestamp in milliseconds | ||
| endTime | Long | false | Query range end boundary, timestamp in milliseconds |
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"hasPrev": true, //Is there a previous page
"hasNext": true, //Is there a next page
"items": [
{
"id": 763111, //Withdrawal record id
"currency": "usdt", //currency name
"chain": "Ethereum", //Withdraw network
"address": "0xfa3abf", //Withdrawal target address
"memo": "",
"status": "REVIEW", //Refer to public module-Deposit/withdrawal record status
"amount": "30", //Withdrawal Amount
"fee": "0", //Withdrawal fee
"confirmations": 0, //number of block confirmations
"transactionId": "", //transaction hash
"createdTime": 1667763470000 //Withdrawal application time, timestamp in milliseconds
},
{
"id": 763107,
"currency": "usdt",
"chain": "Tron",
"address": "TYnJJw",
"memo": "",
"status": "REVIEW",
"amount": "50",
"fee": "1",
"confirmations": 0,
"transactionId": "",
"createdTime": 1667428286000
}
]
}
}
Transfer between user business systems Edit
/v4/balance/transfer
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| bizId | string | true | Unique id for idempotent processing | Maximum length is 128 | |
| from | enum | true | Fund transfer out account | bizType enmu | |
| to | enum | true | Fund transfer in account | bizType enum | |
| currency | string | true | Currency name must be all lowercase (usdt,btc) | ||
| symbol | string | false | The transfer symbol must be all lowercase (this field must be passed if one of the transfer-in and transfer-out parties is leverage) | ||
| amount | bigDecimal | true | Transfer amount |
public String transferPost(){
}
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": 123456 //The returned unique id of the transfer, it is recommended to store it for reconciliation
}
Transfer between sub-account business systems Edit
/v4/balance/account/transfer
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| bizId | string | true | Unique id for idempotent processing | Maximum length is 128 | |
| from | enum | true | Fund transfer out account | bizType enmu | |
| to | enum | true | Fund transfer in account | bizType enum | |
| currency | string | true | Currency name must be all lowercase (usdt,btc) | ||
| symbol | string | false | The transfer symbol must be all lowercase (this field must be passed if one of the transfer-in and transfer-out parties is leverage) | ||
| amount | bigDecimal | true | Transfer amount | ||
| toAccountId | long | true | Transfer-in account id (must belong to the same user as the transfer-out account ID) | ||
| fromAccountId | long | false | Transfer-out account id |
public String accountTransferPost(){
}
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": 123456 //The returned unique id of the transfer, it is recommended to store it for reconciliation
}
General WSS information Edit
Base Address
wss://stream.wexex.io/public
Request Header
Sec-WebSocket-Extensions: permessage-deflate
# Minimal Python example (websocket-client)
# pip install websocket-client
import websocket
url = "wss://stream.wexex.io/public"
headers = ["Sec-WebSocket-Extensions: permessage-deflate"]
ws = websocket.WebSocket()
ws.connect(url, header=headers)
print("Connected to WEX public WSS")
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {}
}
Request message format Edit
{
"method": "subscribe",
"params": [
"{topic}@{arg},{arg}",
"{topic}@{arg}"
],
"id": "{id}" //call back ID
}
{
"method": "unsubscribe",
"params": [
"{topic}@{arg},{arg}"
],
"id": "{id}" //call back ID
}
{
"code": 0,
"msg": "success"
}
Response message format Edit
{
"id": "{id}", //call back ID
"code": 1, //result 0=success;1=fail;2=listenKey invalid
"msg": ""
}
{"id":"123", "code": 0, "msg": "success"}
{"id":"123", "code": 401, "msg": "token expire"}
Push message format Edit
{
"topic": "trade",
"event": "trade@btc_usdt", //title
"data": { }
}
{
"topic": "trade",
"event": "trade@btc_usdt",
"data": {
"s": "btc_usdt", // symbol
"i": 6316559590087222000, // tradeId
"t": 1655992403617, // time
"oi": 6616559590087222666, // orderId
"p": "43000", // price
"q": "0.21", // quantity
"v": "9030", // quoteQty
"b": true // whether is buyerMaker or not
}
}
Heartbeat Edit
Each link of the client needs to send a text “ping” periodically, and the server will reply with “pong”. If the server does not receive a ping message from the client within 1 minute, it will actively disconnect the link.
"ping"
"pong"
Subscription parameters Edit
format
{topic}@{arg},{arg},…
{
"code": 0,
"msg": "success"
}
Orderbook manage Edit
How to manage a local order book correctly
1.Open a stream to wss://stream.wexex.io/public , e.g. depth_update@btc_usdt.
2.Buffer the events you receive from the stream.
3.Get a depth snapshot from https://sapi.wexex.io/v4/public/depth?symbol=btc_usdt&limit=500
4.Drop any event where i <= lastUpdateId in the snapshot.
5.The first processed event should have fi <= lastUpdateId+1 AND i >= lastUpdateId+1.
6.While listening to the stream, each new event’s fi should be equal to the previous event’s i+1.
7.The data in each event is the absolute quantity for a price level.
8.If the quantity is 0, remove the price level.
9.Receiving an event that removes a price level that is not in your local order book can happen and is normal.
Note: Due to depth snapshots having a limit on the number of price levels, a price level outside of the initial snapshot that doesn’t have a quantity change won’t have an update in the Diff Depth Stream. Consequently, those price levels will not be visible in the local order book even when applying all updates from the Diff Depth Stream correctly. This can cause the local order book to have some slight differences with the real order book. However, for most use cases the depth limit of 500 is enough to understand the market and trade effectively.
Trade record Edit
request
format: trade@{symbol}
eg: trade@btc_usdt
rate: real
{
"topic": "trade",
"event": "trade@btc_usdt",
"data": {
"s": "btc_usdt", // symbol
"i": 6316559590087222000, // tradeId
"t": 1655992403617, // trade time
"oi": 6616559590087222666, // orderId
"p": "43000", // trade price
"q": "0.21", // qty, trade quantity
"v": "9030", // quoteQty
"b": true // whether is buyerMaker or not
}
}
K-line Edit
request
format: kline@{symbol},{interval}
interval: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
eg: kline@btc_usdt,5m
rate: 1000ms
{
"topic": "kline",
"event": "kline@btc_usdt,5m",
"data": {
"s": "btc_usdt", // symbol
"t": 1656043200000, // time
"i": "5m", // interval
"o": "44000", // open price
"c": "50000", // close price
"h": "52000", // highest price
"l": "36000", // lowest price
"q": "34.2", // qty(quantity)
"v": "230000" // volume
}
}
Limited depth Edit
request
format: depth@{symbol},{levels}
levels: 5, 10, 20, 50
eg: depth@btc_usdt,20
rate: 1000ms
{
"topic": "depth",
"event": "depth@btc_usdt,20",
"data": {
"s": "btc_usdt", // symbol
"i": 1657699200000, // updateId
"a": [ // asks(sell order)
[ //[0]price, [1]quantity
"34000", //price
"1.2" //quantity
],
[
"34001",
"2.3"
]
],
"b": [ // bids(buy order)
[
"32000",
"0.2"
],
[
"31000",
"0.5"
]
]
}
}
Incremental depth Edit
request
format: depth_update@{symbol}
eg: depth_update@btc_usdt
rate: 100ms
{
"topic": "depth_update",
"event": "depth_update@btc_usdt",
"data": {
"s": "btc_usdt", // symbol
"fi": 121, // firstUpdateId = previous lastUpdateId + 1
"i": 123, // lastUpdateId
"a": [ // asks sell order
[ // [0]price, [1]quantity
"34000", //price
"1.2" //quantity
],
[
"34001",
"2.3"
]
],
"b": [ // bids buy order
[
"32000",
"0.2"
],
[
"31000",
"0.5"
]
]
}
}
Ticker Edit
request
format: ticker@{symbol}
eg: ticker@btc_usdt
rate: 1000ms
{
"topic": "ticker",
"event": "ticker@btc_usdt",
"data": {
"s": "btc_usdt", // symbol
"t": 1657586700119, // time(Last transaction time)
"cv": "-200", // priceChangeValue(24 hour price change)
"cr": "-0.02", // priceChangeRate 24-hour price change (percentage)
"o": "30000", // open price
"c": "39000", // close price
"h": "38000", // highest price
"l": "40000", // lowest price
"q": "4", // quantity
"v": "150000" // volume
}
}
All ticker Edit
request
format: tickers
rate: 1000ms, only when there are changes
{
"topic": "tickers",
"event": "tickers",
"data": [ ] // refer to ticker(real-time push)
}
General WSS information Edit
wss://stream.wexex.io/private
Request message format Edit
param format
{topic}@{arg},{arg},…
-
listenKey must be applied via the /v4/ws-token endpoint.
-
id is a custom request identifier for matching responses.
{
"method": "subscribe",
"params": [
"{topic}@{arg},{arg}", //event
"{topic}@{arg}"
],
"listenKey": "512312356123123123", //the listener Key, Apply accessToken through /v4/ws-token interface
"id": "{id}"
}
{
"method": "unsubscribe",
"params": [
"{topic}@{arg},{arg}", //event
"{topic}@{arg}"
],
"listenKey": "512312356123123123", //the listener Key, Apply accessToken through /v4/ws-token interface
"id": "{id}"
}
Response message format Edit
{
"id": "{id}", //call back ID
"code": 1, //result 0=success;1=fail;2=listenKey invalid
"msg": ""
}
Get token Edit
/v4/ws-token
Notes:
-
Limit flow rules: 1 request / 10s / apikey
-
The accessToken is valid for 2 days.
-
Calling this endpoint again will reset the validity period.
-
accessToken is equivalent to listenKey, used for establishing WebSocket connections.
curl --location --request POST 'https://sapi.wexex.io/v4/ws-token' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'validate-algorithms: HmacSHA256' \
--header 'validate-recvwindow: 60000' \
--header 'validate-appkey: xxxxxxxxxx' \
--header 'validate-timestamp: xxxxxxxxxx' \
--header 'validate-signature: xxxxxxxxxx'
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"accessToken": "eyJhbqGciOiJSUzI1NiJ9.eyJhY2NvdW50SWQiOiIyMTQ2Mjg1MzIyNTU5Iiwic3ViIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsInNjb3BlIjoiYXV0aCIsImlzcyI6Inh0LmNvbSIsImxhc3RBdXRoVGltZSI6MTY2MzgxMzY5MDk1NSwic2lnblR5cGUiOiJBSyIsInVzZXJOYW1lIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsImV4cCI6MTY2NjQwNTY5MCwiZGV2aWNlIjoidW5rbm93biIsInVzZXJJZCI6MjE0NjI4NTMyMjU1OX0.h3zJlJBQrK2x1HvUxsKivnn6PlSrSDXXXJ7WqHAYSrN2CG5XPTKc4zKnTVoYFbg6fTS0u1fT8wH7wXqcLWXX71vm0YuP8PCvdPAkUIq4-HyzltbPr5uDYd0UByx0FPQtq1exvsQGe7evXQuDXx3SEJXxEqUbq_DNlXPTq_JyScI",
"refreshToken": "eyJhbGciOiqJSUzI1NiJ9.eyJhY2NvdW50SWQiOiIyMTQ2Mjg1MzIyNTU5Iiwic3ViIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsInNjb3BlIjoicmVmcmVzaCIsImlzcyI6Inh0LmNvbSIsImxhc3RBdXRoVGltZSI6MTY2MzgxMzY5MDk1NSwic2lnblR5cGUiOiJBSyIsInVzZXJOYW1lIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsImV4cCI6MTY2NjQwNTY5MCwiZGV2aWNlIjoidW5rbm93biIsInVzZXJJZCI6MjE0NjI4NTMyMjU1OX0.Fs3YVm5YrEOzzYOSQYETSmt9iwxUHBovh2u73liv1hLUec683WGfktA_s28gMk4NCpZKFeQWFii623FvdfNoteXR0v1yZ2519uNvNndtuZICDdv3BQ4wzW1wIHZa1skxFfqvsDnGdXpjqu9UFSbtHwxprxeYfnxChNk4ssei430"
}
}
Push message format Edit
{
"topic": "trade", // channel name
"event": "trade@btc_usdt", // event identifier with symbol
"data": { } // payload
}
{
"topic": "trade",
"event": "trade@btc_usdt",
"data": {
"s": "btc_usdt",
"i": 6316559590087222000,
"t": 1655992403617,
"oi": 6616559590087222666,
"p": "43000",
"q": "0.21",
"v": "9030",
"b": true
}
}
Change of balance Edit
Subscription format: balance
This push notification is triggered when a user’s account balance changes. Supports both SPOT and LEVER business types. Useful for tracking real-time balance changes after trades, deposits, withdrawals, or transfers.
{
"method": "subscribe",
"params": ["balance"],
"listenKey": "512312356123123123"
}
{
"topic": "balance",
"event": "balance",
"data": {
"a": "123", // accountId
"t": 1656043204763, // time happened time (ms)
"c": "btc", // currency
"b": "123", // balance total spot balance
"f": "11", // frozen amount
"z": "SPOT", // bizType [SPOT,LEVER]
"s": "btc_usdt" // symbol
}
}
Change of order Edit
Subscription format: order
This push notification is triggered when an order status changes.
Possible order states (st):
-
NEW - New order created
-
PARTIALLY_FILLED - Partially filled
-
FILLED - Fully filled
-
CANCELED - Order canceled
-
REJECTED - Order rejected
-
EXPIRED - Order expired
{
"method": "subscribe",
"params": ["order"],
"listenKey": "512312356123123123"
}
{
"topic": "order",
"event": "order",
"data": {
"s": "btc_usdt", // symbol
"bc": "btc", // base currency
"qc": "usdt", // quotation currency
"t": 1656043204763, // happened time (ms)
"ct": 1656043204663, // create time (ms)
"i": "6216559590087220004", // order id
"ci": "test123", // client order id
"st": "PARTIALLY_FILLED", // state NEW/PARTIALLY_FILLED/FILLED/CANCELED/REJECTED/EXPIRED
"sd": "BUY", // side BUY/SELL
"tp": "LIMIT", // type LIMIT/MARKET
"oq": "4", // original quantity
"oqq": 48000, // original quotation quantity
"eq": "2", // executed quantity
"lq": "2", // remaining quantity
"p": "4000", // price
"ap": "30000", // avg price
"f": "0.002" // fee
}
}
Order filled Edit
Subscription format: trade
This push notification is triggered when a trade (order fill) occurs. Indicates execution details including trade ID, order ID, price, quantity, and maker/taker info. Useful for tracking completed trades in real time.
{
"method": "subscribe",
"params": ["trade"],
"listenKey": "512312356123123123"
}
{
"topic": "trade",
"event": "trade",
"data": {
"s": "btc_usdt", // symbol
"i": 6316559590087222000, // tradeId
"t": 1655992403617, // trade time (ms)
"oi": 6616559590087222666, // orderId
"p": "43000", // price
"q": "0.21", // quantity
"v": "9030", // quoteQty trade amount
"b": true, // whether buyer is maker (true=buyerMaker)
"tm": 1 // taker/maker: 1 = taker, 2 = maker
}
}
REST API Edit
生产环境: https://sapi.wexex.io
接口基本信息 Edit
由于延迟高、稳定性差等原因,不建议通过代理访问 API。
GET 请求参数放在 query Params 中,POST 请求参数放在 request body 中。
请将请求头信息设置为:Content-Type=application/json
对于以 /public 开头以外的请求,请求消息需要进行签名。
频率限制规则 Edit
某些接口会有限流控制(相应接口会有限流说明)。 限流主要分为网关限流和 WAF 限流。
如果接口请求触发网关限流,将返回 429, 表示访问频率超过限制,IP 或 apiKey 将被封禁。
网关限流分为:
- IP 限流
- apiKey 限流
示例说明:
-
IP 限流:
100/s/ip- 表示该接口每个 IP 每秒的请求次数限制。 -
apiKey 限流:
50/s/apiKey- 表示该接口每个 apiKey 每秒的请求次数限制。
签名说明 Edit
由于 WEX 需要为第三方平台提供一些开放接口,因此需要考虑数据安全问题。
例如:
- 数据是否被篡改
- 数据是否已过期
- 数据能否重复提交
- 接口的访问频率
其中,数据是否被篡改是最重要的问题。
步骤:
-
Appkey & Secretkey 首先在用户中心申请
appkey和secretkey,每个用户的密钥都不同。 -
Timestamp 添加
timestamp。 其值应为发送请求时的 unix 时间戳(毫秒)。 数据的时间基于此值计算。 -
Signature 添加
signature,其值通过签名算法规则获得。 -
RecvWindow 添加
recvwindow(定义请求的有效时间)。 有效时间固定为某个值。 当收到请求时,服务器会检查:serverTime - timestamp < recvwindow。 任何超过 5000 毫秒的请求都无效。 如果客户端的时间戳比服务器时间提前超过 1 秒,请求无效。 注意: 网络条件并非总是 100% 可靠。这就是我们提供recvWindow参数的原因。 对于高频交易,调整recvWindow以满足时效性需求。 不建议使用超过 5 秒的 RecvWindow。 -
Algorithm 添加
algorithms(签名方法)。 推荐:HmacSHA256。 支持的算法:HmacMD5、HmacSHA1、HmacSHA224、HmacSHA256(推荐)、HmacSHA384、HmacSHA512
签名生成 Edit
以 https://sapi.wexex.io/v4/order 为例。
以下 appKey/secret 仅用于演示(Linux bash 使用 echo、openssl、curl):
appKey: 3976eb88-76d0-4f6e-a6b2-a57980770085
secretKey: bc6630d0231fda5cd98794f52c4998659beda290
必需的请求头:
validate-algorithms: HmacSHA256
validate-appkey: 3976eb88-76d0-4f6e-a6b2-a57980770085
validate-recvwindow: 5000
validate-timestamp: 1641446237201
validate-signature: 2b5eb11e18796d12d88f13dc27dbbd02c2cc51ff7059765ed9821957d82bb4d9
请求体示例:
{
"type": "LIMIT",
"timeInForce": "GTC",
"side": "BUY",
"symbol": "btc_usdt",
"price": "39000",
"quantity": "2"
}
1. 数据部分拼接 (Y)
method: 大写的 HTTP 方法,如 GET、POST、DELETE、PUT
path: 填充变量后的具体 RESTful 路径,如 /sign/test/bb/aa
query: 按 key 字典序排序所有 key=value,用 & 连接,例如:userName=dfdfdf&password=ggg
body:
JSON: 使用原始 JSON 字符串(不转换/排序)
x-www-form-urlencoded: 按 key 字典序排序所有 key=value,用 & 连接,例如:userName=dfdfdf&password=ggg
form-data: 不支持
如果存在多种形式,按顺序拼接:path -> query -> body。
方法 method 示例:
POST
路径 path 示例:
/v4/order
上述拼接值记作为 path
参数通过 query 示例:
symbol=btc_usdt
上述值拼接记作 query
参数通过 body 示例:
x-www-form-urlencoded:
symbol=btc_usdt&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1
上述值拼接记作 body
json:
{"symbol":"btc_usdt","side":"BUY","type":"LIMIT","timeInForce":"GTC","quantity":2,"price":39000}
上述值拼接记作 body
混合使用 query 与 body(分为表单与 json 两种格式):
query:
symbol=btc_usdt&side=BUY&type=LIMIT
上述拼接值记作 query
body:
{"symbol":"btc_usdt","side":"BUY","type":"LIMIT"}
上述拼接值记作 body
最终用 # 拼接,带前导标记:
Y = #method#path#query#body
注意:
query 存在,body 为空:Y = #method#path#query
query 为空,body 存在:Y = #method#path#body
都存在:Y = #method#path#query#body
2. 请求头部分拼接 (X)
将以下请求头键按自然升序字母顺序排序,然后用 & 连接:
validate-algorithms=HmacSHA256&validate-appkey=3976eb88-76d0-4f6e-a6b2-a57980770085&validate-recvwindow=5000&validate-timestamp=1641446237201
3. 生成签名
拼接 original = X + Y(除了 Y 中已有的 # 外没有分隔符),然后计算:
signature = org.apache.commons.codec.digest.HmacUtils.hmacSha256Hex(secretKey, original);
将生成的值添加到请求头:validate-signature: <signature>
4. 完整示例
原始签名消息示例:
validate-algorithms=HmacSHA256&validate-appkey=2063495b-85ec-41b3-a810-be84ceb78751&validate-recvwindow=60000&validate-timestamp=1666026215729#POST#/v4/order#{"symbol":"BTC_USDT","side":"BUY","type":"LIMIT","timeInForce":"GTC","bizType":"SPOT","price":3,"quantity":2}
注意事项:
确保 Content-Type、签名原始消息和最终请求载荷保持一致。
validate-timestamp 应为发送时间的毫秒数;配合合理的 validate-recvwindow 来容忍网络抖动。
当 body 是 JSON 时,使用原始 JSON 字符串进行签名(不要重新排序键或美化格式)。
API Key 申请步骤 Edit
某些接口可能需要用户的 API Key。请在 WEX 网站或 App 的用户中心创建 API Key。
响应格式 Edit
所有接口返回都是 JSON 格式。
{
"rc": 0,
"result": {},
"mc": "SUCCESS",
"ma": []
}
响应代码 Edit
HTTP 状态码
| httpStatus | 描述 |
|---|---|
| 200 | 请求成功,请进一步检查 rc 和 mc 部分 |
| 404 | 接口不存在 |
| 429 | 请求过于频繁,请根据限速要求控制请求频率 |
| 500 | 服务异常 |
| 502 | 网关异常 |
| 503 | 服务不可用,请稍后重试 |
返回码 (rc)
| rc | 描述 |
|---|---|
| 0 | 业务成功 |
| 1 | 业务失败 |
消息代码 (mc)
| mc | 消息 |
|---|---|
| SUCCESS | 成功 |
| FAILURE | 失败 |
| AUTH_001 | 缺少请求头 validate-appkey |
| AUTH_002 | 缺少请求头 validate-timestamp |
| AUTH_003 | 缺少请求头 validate-recvwindow |
| AUTH_004 | 请求头 validate-recvwindow 错误 |
| AUTH_005 | 缺少请求头 validate-algorithms |
| AUTH_006 | 请求头 validate-algorithms 错误 |
| AUTH_007 | 缺少请求头 validate-signature |
| AUTH_101 | ApiKey 不存在 |
| AUTH_102 | ApiKey 未激活 |
| AUTH_103 | 签名错误 |
| AUTH_104 | 未绑定 IP 请求 |
| AUTH_105 | 消息已过期 |
| AUTH_106 | 超出 apikey 权限 |
| SYMBOL_001 | 交易对不存在 |
| SYMBOL_002 | 交易对已下线 |
| SYMBOL_003 | 交易对暂停交易 |
| SYMBOL_004 | 交易对所属国家禁止交易 |
| SYMBOL_005 | 该交易对不支持 API 交易 |
| SYMBOL_007 | 该交易对不支持订单修改 |
| SYMBOL_010 | 该市场不支持您的交易 |
| SYMBOL_011 | 由于风险较高,该交易对暂时受到限制。请联系客服申请审批。 |
| ORDER_001 | 平台拒绝 |
| ORDER_002 | 资金不足 |
| ORDER_003 | 交易对暂停 |
| ORDER_004 | 禁止交易 |
| ORDER_005 | 订单不存在 |
| ORDER_006 | 挂单数量过多 |
| ORDER_007 | 子账户无交易权限 |
| ORDER_008 | 订单价格或数量精度异常 |
| ORDER_F0101 | 触发价格过滤器 - 最小值 |
| ORDER_F0102 | 触发价格过滤器 - 最大值 |
| ORDER_F0103 | 触发价格过滤器 - 步进值 |
| ORDER_F0201 | 触发数量过滤器 - 最小值 |
| ORDER_F0202 | 触发数量过滤器 - 最大值 |
| ORDER_F0203 | 触发数量过滤器 - 步进值 |
| ORDER_F0301 | 触发报价数量过滤器 - 最小值 |
| ORDER_F0401 | 触发在线保护过滤器或限价保护过滤器 |
| ORDER_F0501 | 触发限价保护过滤器 - 买入最大偏差 |
| ORDER_F0502 | 触发限价保护过滤器 - 卖出最大偏差 |
| ORDER_F0503 | 触发限价保护过滤器 - 买入限价系数 |
| ORDER_F0504 | 触发限价保护过滤器 - 卖出限价系数 |
| ORDER_F0601 | 触发市价保护过滤器 |
| ORDER_F0704 | 杠杆限价单的平仓价格限制 |
| COMMON_001 | 用户不存在 |
| COMMON_002 | 系统繁忙,请稍后再试 |
| COMMON_003 | 操作失败,请稍后再试 |
| CURRENCY_001 | 币种信息异常 |
| DEPOSIT_001 | 充值未开放 |
| DEPOSIT_002 | 安全等级低,充值前请绑定双因素认证(手机/邮箱/谷歌) |
| DEPOSIT_003 | 地址格式错误 |
| DEPOSIT_004 | 地址已存在 |
| DEPOSIT_005 | 找不到离线钱包地址 |
| DEPOSIT_006 | 无充值地址,请稍后再试 |
| DEPOSIT_007 | 地址正在生成中 |
| DEPOSIT_008 | 充值不可用 |
| WITHDRAW_001 | 提现未开放 |
| WITHDRAW_002 | 提现地址无效 |
| WITHDRAW_003 | 安全等级低,提现前请绑定双因素认证 |
| WITHDRAW_004 | 未添加提现地址 |
| WITHDRAW_005 | 提现地址不能为空 |
| WITHDRAW_006 | 备注不能为空 |
| WITHDRAW_008 | 触发风控,不支持提现 |
| WITHDRAW_009 | 提现失败,受 T+1 规则限制 |
| WITHDRAW_010 | 提现精度无效 |
| WITHDRAW_011 | 可用余额不足 |
| WITHDRAW_012 | 超出每日提现限额 |
| WITHDRAW_013 | 超出每日提现限额,升级 KYC 可提高限额 |
| WITHDRAW_014 | 地址不能用于内部转账 |
| WITHDRAW_015 | 金额不足以支付手续费 |
| WITHDRAW_016 | 提现地址已存在 |
| WITHDRAW_017 | 提现已处理,无法取消 |
| WITHDRAW_018 | 备注必须是数字 |
| WITHDRAW_019 | 备注错误 |
| WITHDRAW_020 | 已达到每日提现上限 |
| WITHDRAW_021 | 提现受限,本次最多 {0} |
| WITHDRAW_022 | 必须大于 {0} |
| WITHDRAW_023 | 必须小于 {0} |
| WITHDRAW_024 | 不支持提现 |
| WITHDRAW_025 | 请在充值页面创建 FIO 地址 |
| FUND_001 | 重复请求(bizId 只能请求一次) |
| FUND_002 | 账户余额不足 |
| FUND_003 | 不支持转账 |
| FUND_004 | 解冻失败 |
| FUND_005 | 禁止转账 |
| FUND_014 | 转入和转出账户 ID 不能相同 |
| FUND_015 | 来源和目标业务类型不能相同 |
| FUND_016 | 杠杆转账需要交易对 |
| FUND_017 | 参数错误 |
| FUND_018 | 无效的冻结记录 |
| FUND_019 | 冻结用户不一致 |
| FUND_020 | 冻结币种不一致 |
| FUND_021 | 不支持该操作 |
| FUND_022 | 冻结记录不存在 |
| FUND_044 | 金额长度最大 113 |
| SYMBOL_001 | 交易对不存在 |
| TRANSFER_001 | 重复请求(bizId 只能请求一次) |
| TRANSFER_002 | 余额不足 |
| TRANSFER_003 | 用户未注册 |
| TRANSFER_004 | 币种不可转账 |
| TRANSFER_005 | 用户的币种不可转账 |
| TRANSFER_006 | 禁止转账 |
| TRANSFER_007 | 请求超时 |
| TRANSFER_008 | 转入杠杆账户异常 |
| TRANSFER_009 | 转出杠杆账户异常 |
| TRANSFER_010 | 杠杆已清算,禁止转账 |
| TRANSFER_011 | 杠杆有借款,禁止转账 |
| TRANSFER_012 | 币种禁止转账 |
| GATEWAY_0001 | 触发风控 |
| GATEWAY_0002 | 触发风控 |
| GATEWAY_0003 | 触发风控 |
| GATEWAY_0004 | 触发风控 |
公共模块 Edit
订单状态
| 状态 | 描述 |
|---|---|
| NEW | 订单已被引擎接受。 |
| PARTIALLY_FILLED | 订单已部分成交。 |
| FILLED | 订单已完全成交。 |
| CANCELED | 订单已被用户取消。 |
| REJECTED | 订单未被引擎接受且未处理。 |
| EXPIRED | 订单已过期(例如:因超时取消或因溢价取消) |
订单类型
| 类型 | 描述 |
|---|---|
| LIMIT | 限价单 |
| MARKET | 市价单 |
交易对状态
| 状态 | 描述 |
|---|---|
| ONLINE | 交易对已上线 |
| OFFLINE | 交易对已下线 |
| DELISTED | 交易对已退市 |
有效时间
设置订单在过期前的有效时长。
| 有效时间类型 | 描述 |
|---|---|
| GTC | 成交为止:订单一直有效直到成交。 |
| IOC | 立即成交或取消:无法立即成交的部分将被取消(吃单) |
| FOK | 全部成交或取消:如果不能全部立即成交则取消 |
| GTX | 只做挂单:只挂单,如触发成交条件将立即取消 |
充值/提现状态
| 状态 | 描述 |
|---|---|
| SUBMIT | 提现金额未冻结。 |
| REVIEW | 提现金额已冻结,待审核。 |
| AUDITED | 提现已审核,准备上链。 |
| AUDITED_AGAIN | 重新审核 |
| PENDING | 充值或提现正在上链中。 |
| SUCCESS | 充值或提现成功。 |
| FAIL | 充值或提现失败。 |
| CANCEL | 充值或提现已被用户取消。 |
业务类型
| 状态 | 描述 |
|---|---|
| SPOT | 现货账户 |
| LEVER | 杠杆账户 |
| FINANCE | 理财账户 |
| FUTURES_U | USDT 本位合约账户 |
| FUTURES_C | 币本位合约账户 |
常见问题 Edit
-
AUTH_105 服务器会验证请求头参数
validate-timestamp(validTimeStamp) 和validate-recvwindow(recvwindow)。必须遵循以下规则:
dealTimeStamp(服务器处理请求的时间,毫秒) - validTimeStamp < recvwindow
否则将返回 AUTH_105。
为避免此错误:
validate-timestamp建议使用发送请求时的时间,单位为毫秒。validate-recvwindow应设置得稍大一些。
联系我们 Edit
WEX API Telegram 群组:WEX API Support Group
- 用于文档中未涵盖的 API 相关问题。
- 用于做市商(MM)相关问题
WEX 客户支持:网站和 App 在线客服
- 用于资金丢失、双因素认证帮助等情况。
获取服务器时间 Edit
/v4/public/time
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"serverTime": 1662435658062
}
}
获取客户端 IP Edit
/v4/public/client
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"ip": "192.168.1.1"
}
}
获取交易对信息 Edit
/v4/public/symbol
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 例如:btc_usdt | ||
| symbols | array | false | 交易对集合,优先级高于symbol。例如:btc_usdt,eth_usdt | ||
| version | string | false | 版本号,如果请求版本等于响应版本,将不返回列表(减少 IO)。 例如:2e14d2cd5czcb2c2af2c1db6 |
限流规则
1.单个交易对:10次/秒/IP
2.多个交易对:10次/秒/IP
过滤器
价格过滤器 PRICE FILTER
min:允许的最小价格max:允许的最大价格tickSize:步进间隔 → price = minPrice + (整数 * tickSize)
逻辑伪代码:
- price >= min
- price <= max
- (price-minPrice) % tickSize == 0
数量过滤器 QUANTITY FILTER
min:允许的最小值max:允许的最大值tickSize:步进间隔
逻辑伪代码:
- quantity >= min
- quantity <= max
- (quantity-minQuantity) % tickSize == 0
报价数量过滤器 QUOTE_QTY FILTER
- 如果
min为 null → 无限制 - 限价单 → price * quantity >= min
- 市价买单 → quoteQty >= min
限价保护过滤器 PROTECTION_LIMIT FILTER
buyMaxDeviation、buyPriceLimitCoefficient、sellMaxDeviation、sellPriceLimitCoefficient
买入:price >= latestPrice - latestPrice * buyMaxDeviation
price <= latestPrice + latestPrice * buyPriceLimitCoefficient
卖出:price <= latestPrice + latestPrice * sellMaxDeviation
price >= latestPrice - latestPrice * sellPriceLimitCoefficient
市价保护过滤器 PROTECTION_MARKET FILTER
maxDeviation:最大偏差
买入:latestPrice + latestPrice * maxDeviation >= sellBestPrice
卖出:latestPrice - latestPrice * maxDeviation <= buyBestPrice
上线保护过滤器 PROTECTION_ONLINE FILTER
maxPriceMultiple、durationSeconds
price <= openPrice * maxPriceMultiple
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"time": 1662444177871, //时间
"version": "7cd2cfab0dc979339f1de904bd90c9cb", //内容版本
"symbols": [
{
"symbol": "btc_usdt", //交易对
"state": "ONLINE", //交易对状态[ONLINE=上线的;OFFLINE=下线的,DELISTED=退市]
"tradingEnabled": true, //是否启用交易
"openapiEnabled": true, //是否启用OPENAPI
"nextStateTime": null, //下一个状态时间
"nextState": null, //下一个状态
"depthMergePrecision": 5, //深度合并精度
"baseCurrency": "btc", //标的资产
"baseCurrencyPrecision": 5, //标的资产精度
"quoteCurrency": "usdt", //报价资产
"quoteCurrencyPrecision": 6, //报价资产精度
"pricePrecision": 4, //交易价格精度
"quantityPrecision": 6, //交易数量精度
"takerFeeRate": 0.001, //吃单手续费率
"makerFeeRate": 0.002, //挂单手续费率
"orderTypes": [ //订单类型[LIMIT=限价单;MARKET=市价单]
"LIMIT",
"MARKET"
],
"timeInForces": [ //有效方式[GTC=成交为止,一直有效; IOC=无法立即成交(吃单)的部分就撤销; FOK=无法全部立即成交就撤销; GTX=无法成为挂单方就撤销]
"GTC",
"FOK",
"IOC",
"GTX"
],
"displayWeight": 1, //展示权重,越大越靠前
"displayLevel": "FULL", //展示级别,[FULL=完全展示,SEARCH=搜索展示,DIRECT=直达展示,NONE=不展示]
"filters": [ //过滤器
{
"filter": "PROTECTION_LIMIT",
"buyMaxDeviation": "0.8",
"sellMaxDeviation": "0.8"
},
{
"filter": "PROTECTION_MARKET",
"maxDeviation": "0.1"
},
{
"filter": "PROTECTION_ONLINE",
"durationSeconds": "300",
"maxPriceMultiple": "5"
},
{
"filter": "PRICE",
"min": null,
"max": null,
"tickSize": null
},
{
"filter": "QUANTITY",
"min": null,
"max": null,
"tickSize": null
},
{
"filter": "QUOTE_QTY",
"min": null
}
]
}
]
}
}
获取深度数据 Edit
/v4/public/depth
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 例如:btc_usdt | ||
| limit | number | false | 100 | 最小查询数量为 100 | 1~500 |
限流规则
10次/秒/IP
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"timestamp": 1662445330524, //时间戳
"lastUpdateId": 137333589606963580, //最后更新记录
"bids": [ //买盘 [价位,挂单量]
[
"200.0000",
"0.996000"
],
[
"100.0000",
"0.001000"
],
[
"20.0000",
"10.000000"
]
],
"asks": [] //卖盘 [价位,挂单量]
}
}
获取 K 线数据 Edit
/v4/public/kline
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 例如:btc_usdt | ||
| interval | string | true | K 线类型, 例如:1m | [1m;3m;5m;15m;30m;1h;2h;4h;6h;8h;12h;1d;3d;1w;1M] | |
| startTime | number | false | 开始时间戳 | ||
| endTime | number | false | 结束时间戳 | ||
| limit | number | false | 100 | 1~1000 |
限流规则
10次/秒/IP
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"t": 1662601014832, //开盘时间
"o": "30000", //开盘价
"c": "32000", //收盘价
"h": "35000", //最高价
"l": "25000", //最低价
"q": "512", //成交量
"v": "15360000" //成交额
}
]
}
查询最近成交列表 Edit
/v4/public/trade/recent
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 | ||
| limit | number | false | 200 | 1~1000 |
限流规则
10次/秒/IP
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"i": 0, //ID
"t": 0, //成交时间
"p": "string", //成交价
"q": "string", //成交量
"v": "string", //成交额
"b": true //是否是buyerMaker
}
]
}
查询历史成交列表 Edit
/v4/public/trade/history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 | ||
| limit | number | false | 200 | 1~1000 | |
| direction | string | true | 查询方向 | PREV - 上一页,NEXT - 下一页 | |
| fromId | number | false | 起始 ID,例如 6216559590087220004 |
限流规则
10次/秒/IP
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"i": 0, //ID
"t": 0, //成交时间
"p": "string", //成交价
"q": "string", //成交量
"v": "string", //成交额
"b": true //是否是buyerMaker
}
]
}
全量行情 Edit
/v4/public/ticker
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 例如:btc_usdt | ||
| symbols | array | false | 交易对集合,优先级高于symbol。例如:btc_usdt,eth_usdt | ||
| tags | string | false | 标签集合,逗号分隔,目前仅支持 spot |
限流规则
1.单一交易对:10次/秒/IP
2.多个交易对:10次/秒/IP
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": [
{
"s": "btc_usdt", //交易对
"t": 1662444879425, //更新时间
"cv": "0.00", //价格变动
"cr": "0.0000", //价格变动百分比
"o": "200.00", //最早一笔
"l": "200.00", //最低
"h": "200.00", //最高
"c": "200.00", //最后一笔
"q": "0.002", //成交量
"v": "0.40", //成交额
"ap": null, //卖一价
"aq": null, //卖一量
"bp": null, //买一价
"bq": null //买一量
}
]
}
获取最新价格行情 Edit
/v4/public/ticker/price
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 例如:btc_usdt | ||
| symbols | array | false | 交易对集合,优先级高于symbol。例如:btc_usdt,eth_usdt | ||
| tags | string | false | 标签集合,用逗号分隔,目前仅支持 spot |
限流规则
1.单个交易对:10次/秒/IP
2.多个交易对:10次/秒/IP
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": [
{
"s": "btc_usdt", //交易对
"t": 1661856036925, //时间
"p": "9000.0000" //价格
}
]
}
获取最优挂单行情 Edit
/v4/public/ticker/book
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 例如:btc_usdt | ||
| symbols | array | false | 交易对集合,优先级高于symbol。例如:btc_usdt,eth_usdt | ||
| tags | string | false | 标签集合,用逗号分隔,目前仅支持 spot |
限流规则
1.单个交易对:10次/秒/IP
2.多个交易对:10次/秒/IP
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": [
{
"s": "btc_usdt", //交易对
"t": 1661856036925, //更新时间
"ap": null, //卖一价
"aq": null, //卖一量
"bp": null, //买一价
"bq": null //买一量
}
]
}
获取 24 小时统计行情 Edit
/v4/public/ticker/24h
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 例如:btc_usdt | ||
| symbols | array | false | 交易对集合,优先级高于symbol。例如:btc_usdt,eth_usdt | ||
| tags | string | false | 标签集合,用逗号分隔,目前仅支持 spot |
限流规则
1.单个交易对:10次/秒/IP
2.多个交易对:10次/秒/IP
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": [
{
"s": "btc_usdt", //交易对(symbol)
"t": 1661856036925, //时间(time)
"cv": "0.0000", //价格变动(change value)
"cr": "0.00", //价格变动百分比(change rate)
"o": "9000.0000", //最早一笔(open)
"l": "9000.0000", //最低(low)
"h": "9000.0000", //最高(high)
"c": "9000.0000", //最后一笔(close)
"q": "0.0136", //成交量(quantity)
"v": "122.9940" //成交额(volume)
}
]
}
获取单个订单 Edit
/v4/order/{orderId}
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | number | true | 订单ID |
限频规则
10次/秒/每apikey
public String orderGet(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"symbol": "BTC_USDT", //交易对
"orderId": "6216559590087220004", //订单号
"clientOrderId": "16559590087220001", //客户端订单号
"baseCurrency": "string", //标的币种
"quoteCurrency": "string", //报价币种
"side": "BUY", //订单方向: BUY, SELL
"type": "LIMIT", //订单类型: LIMIT, MARKET
"timeInForce": "GTC", //有效方式: GTC, IOC, FOK, GTX
"price": "40000", //价格
"origQty": "2", //原始数量
"origQuoteQty": "48000", //原始金额
"executedQty": "1.2", //已成交数量
"leavingQty": "string", //待成交数量 (取消/拒绝时为0)
"tradeBase": "2", //成交数量
"tradeQuote": "48000", //成交金额
"avgPrice": "42350", //平均成交价格
"fee": "string", //手续费
"feeCurrency": "string", //手续费币种
"state": "NEW", //订单状态: NEW, PARTIALLY_FILLED, FILLED, CANCELED, REJECTED, EXPIRED
"time": 1655958915583, //下单时间
"ip": "127.0.0.1", //请求IP
"updatedTime": 1655958915583 //最后更新时间
}
}
查询单个订单 Edit
/v4/order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | number | false | 订单 ID | ||
| clientOrderId | string | false | 客户订单 ID |
限流规则
50次/秒/每个API Key
public String orderGet(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"symbol": "BTC_USDT", //交易对
"orderId": "6216559590087220004", //订单号
"clientOrderId": "16559590087220001", //客户端订单号
"baseCurrency": "string", //标的币种
"quoteCurrency": "string", //报价币种
"side": "BUY", //订单方向 BUY=买单, SELL=卖单
"type": "LIMIT", //订单类型 LIMIT=限价单, MARKET=市价单
"timeInForce": "GTC", //有效方式 GTC, IOC, FOK, GTX
"price": "40000", //价格
"origQty": "2", //原始数量
"origQuoteQty": "48000", //原始金额
"executedQty": "1.2", //已成交数量
"leavingQty": "string", //剩余未成交数量 (若取消或拒绝则为 0)
"tradeBase": "2", //成交数量
"tradeQuote": "48000", //成交金额
"avgPrice": "42350", //平均成交价格
"fee": "string", //手续费
"feeCurrency": "string", //手续费币种
"state": "NEW", //订单状态
"time": 1655958915583, //下单时间
"updatedTime": 1655958915583 //最后更新时间
}
}
提交订单 Edit
/v4/order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 | ||
| clientOrderId | string | false | 自定义订单号,正则: ^[a-zA-Z0-9_]{4,22}$ | ||
| side | string | true | 订单方向 BUY, SELL | ||
| type | string | true | 订单类型 LIMIT, MARKET | ||
| timeInForce | string | true | 有效方式 GTC, FOK, IOC, GTX | ||
| bizType | string | true | 业务类型 SPOT, LEVER | ||
| price | number | false | 价格。当为 LIMIT 订单时必填;MARKET 订单不需要填写 | ||
| quantity | number | false | 数量。当为 LIMIT 订单或按数量市价单时必填 | ||
| quoteQty | number | false | 金额。当为 LIMIT 订单或按金额市价单时必填 | ||
| nftId | string | false | NFT ID |
备注
创建买入市价单时,quantity 必须为空,quoteQty 必填。创建卖出市价单时,quoteQty 必须为空,quantity 必填。
限流规则
20/s/apikey
public String orderPost(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"orderId": "6216559590087220004",
"ip": "127.0.0.1"
}
}
取消订单 Edit
/v4/order/{orderId}
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | number | true | 订单ID |
限频规则
无限制
public String orderDel(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"cancelId": "6216559590087220004"
}
}
批量查询 Edit
/v4/batch-order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderIds | string | true | 订单 ID 列表,例如: 6216559590087220004, 6216559590087220005 |
返回字段信息与 查询单个订单接口 相同。
public String batchOrderGet(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"symbol": "BTC_USDT",
"orderId": "6216559590087220004",
"clientOrderId": "16559590087220001",
"baseCurrency": "string",
"quoteCurrency": "string",
"side": "BUY",
"type": "LIMIT",
"timeInForce": "GTC",
"price": "40000",
"origQty": "2",
"origQuoteQty": "48000",
"executedQty": "1.2",
"leavingQty": "string",
"tradeBase": "2",
"tradeQuote": "48000",
"avgPrice": "42350",
"fee": "string",
"feeCurrency": "string",
"state": "NEW",
"time": 1655958915583,
"ip": "127.0.0.1",
"updatedTime": 1655958915583
}
]
}
提交批量订单 Edit
/v4/batch-order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| clientBatchId | string | false | 客户端批次号。正则规则:^[a-zA-Z0-9_]{4,32}$ | ||
| items | array | true | 订单数组 | ||
| item.symbol | string | true | 交易对 | ||
| item.clientOrderId | string | false | 客户端订单号。正则规则:^[a-zA-Z0-9_]{4,32}$ | ||
| item.side | string | true | 买卖方向 | BUY, SELL | |
| item.type | string | true | 订单类型 | LIMIT, MARKET | |
| item.timeInForce | string | true | 有效方式 | GTC, FOK, IOC, GTX | |
| item.bizType | string | true | 业务类型 | SPOT, LEVER | |
| item.price | number | false | 价格。LIMIT 必填,MARKET 可为空 | ||
| item.quantity | number | false | 数量。LIMIT 必填,或按数量下 MARKET 订单时必填 | ||
| item.quoteQty | number | false | 金额。LIMIT 必填,或按金额下 MARKET 订单时必填 |
限流规则
30次/秒/apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"batchId": "123",
"items": [
{
"index": "0",
"clientOrderId": "123",
"orderId": "123",
"reject": "false",
"reason": "invalid price precision"
}
]
}
}
批量撤单 Edit
/v4/batch-order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| clientBatchId | string | false | 客户端批次号 | ||
| orderIds | array | true | 订单 ID 列表 [6216559590087220004, 6216559590087220005] |
注意:参数需放置在请求体中,以 JSON 格式传递。
public String batchOrderDel(){
}
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {}
}
查询当前挂单 Edit
/v4/open-order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对,不填则表示全部 | ||
| bizType | string | false | 业务类型 SPOT, LEVER | ||
| side | string | false | 订单方向 BUY, SELL |
限频规则
10次/秒/每apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"symbol": "BTC_USDT",
"orderId": "6216559590087220004",
"clientOrderId": "16559590087220001",
"baseCurrency": "string",
"quoteCurrency": "string",
"side": "BUY",
"type": "LIMIT",
"timeInForce": "GTC",
"price": "40000",
"origQty": "2",
"origQuoteQty": "48000",
"executedQty": "1.2",
"leavingQty": "string",
"tradeBase": "2",
"tradeQuote": "48000",
"avgPrice": "42350",
"fee": "string",
"feeCurrency": "string",
"state": "NEW",
"time": 1655958915583,
"ip": "127.0.0.1",
"updatedTime": 1655958915583
}
]
}
取消当前挂单 Edit
/v4/open-order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对,不填则表示全部 | ||
| bizType | string | true | 业务类型 SPOT, LEVER | ||
| side | string | false | 订单方向 BUY, SELL |
限频规则
10次/秒/每apikey
注意:参数需以 JSON 格式放置于请求体中。
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {}
}
查询历史订单 Edit
/v4/history-order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对,不填表示全部 | ||
| bizType | string | false | 业务类型 SPOT, LEVER | ||
| side | string | false | 买卖方向 BUY, SELL | ||
| type | string | false | 订单类型 LIMIT, MARKET | ||
| state | string | false | 订单状态 PARTIALLY_FILLED, FILLED, CANCELED, REJECTED, EXPIRED | ||
| fromId | number | false | 起始ID | ||
| direction | string | false | 查询方向: PREV, NEXT | ||
| limit | number | false | 20 | 限制数量,最大100 | |
| startTime | number | false | 开始时间(示例:1657682804112) | ||
| endTime | number | false | 结束时间 | ||
| hiddenCanceled | bool | false | 是否隐藏已取消订单 |
限流规则
10次/秒/每apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"hasPrev": true,
"hasNext": true,
"items": [
{
"symbol": "BTC_USDT",
"orderId": "6216559590087220004",
"clientOrderId": "16559590087220001",
"baseCurrency": "string",
"quoteCurrency": "string",
"side": "BUY",
"type": "LIMIT",
"timeInForce": "GTC",
"price": "40000",
"origQty": "2",
"origQuoteQty": "48000",
"executedQty": "1.2",
"leavingQty": "string",
"tradeBase": "2",
"tradeQuote": "48000",
"avgPrice": "42350",
"fee": "string",
"feeCurrency": "string",
"state": "NEW",
"time": 1655958915583,
"ip": "127.0.0.1",
"updatedTime": 1655958915583
}
]
}
}
更新订单(限价) Edit
/v4/order/{orderId}
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | number | true | 订单ID | ||
| price | number | true | 价格 | ||
| quantity | number | true | 数量 |
限流规则
50次/秒/每apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"orderId": "6216559590087220004",
"modifyId": "407329711723834560"
}
}
查询成交记录 Edit
/v4/trade
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对,如不填写则代表所有 | ||
| bizType | string | false | 业务类型:SPOT-现货, LEVER-杠杆 | ||
| orderSide | string | false | 订单方向:BUY-买, SELL-卖 | ||
| orderType | string | false | 订单类型:LIMIT-限价, MARKET-市价 | ||
| orderId | number | false | 订单ID | ||
| fromId | number | false | 起始ID | ||
| direction | string | false | 查询方向:PREV, NEXT | ||
| limit | number | false | 20 | 限制数量,最大100 | |
| startTime | number | false | 开始时间(例如:1657682804112) | ||
| endTime | number | false | 结束时间 |
此接口用于查询成交记录。支持按交易对、业务类型、订单方向、订单类型、时间范围进行筛选,并支持分页查询。
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"hasPrev": true,
"hasNext": true,
"items": [
{
"symbol": "BTC_USDT", // 交易对
"tradeId": "6316559590087222001", // 成交ID
"orderId": "6216559590087220004", // 订单ID
"orderSide": "BUY", // 订单方向
"orderType": "LIMIT", // 订单类型
"bizType": "SPOT", // 业务类型
"time": 1655958915583, // 成交时间
"price": "40000", // 成交价格
"quantity": "1.2", // 成交数量
"quoteQty": "48000", // 成交金额
"baseCurrency": "BTC", // 基础币种
"quoteCurrency": "USDT", // 计价币种
"takerMaker": "taker", // 吃单方/挂单方
"deductType": "COUPON", // 手续费抵扣类型:COUPON / PLATFORM_CURRENCY / null
"deductFee": "0.003", // 使用优惠券时的抵扣费用金额;否则为null
"fee": "0.5", // 手续费金额(或使用平台币抵扣时的平台币数量)
"feeCurrency": "USDT", // 手续费币种
"couponAmount": "0.002", // 使用优惠券时的优惠券金额;否则为null
"couponCurrency": "usdt" // 使用优惠券时的优惠券币种;否则为null
}
]
}
}
获取币种信息 Edit
/v4/public/currencies
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"id": 11, // 币种 ID
"currency": "usdt", // 币种简称
"fullName": "usdt", // 币种全称
"logo": null, // 币种 Logo
"cmcLink": null, // CMC 链接
"weight": 100, // 币种权重
"maxPrecision": 6, // 最大精度
"depositStatus": 1, // 充值状态 (0 关闭,1 开启)
"withdrawStatus": 1, // 提现状态 (0 关闭,1 开启)
"convertEnabled": 1, // 小额资产兑换 (0 关闭,1 开启)
"transferEnabled": 1 // 转账开关 (0 关闭,1 开启)
}
]
}
获取单一币种资产 Edit
/v4/balance
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| currency | string | true | 币种,例如:usdt |
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"currency": "usdt", // 币种
"currencyId": 0, // 币种ID
"frozenAmount": 0, // 冻结数量
"availableAmount": 0, // 可用数量
"totalAmount": 0, // 总数量
"convertBtcAmount": 0 // 折合BTC数量
}
}
获取币种资产列表 Edit
/v4/balances
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| currencies | string | false | 币种列表,逗号分隔,例如:usdt,btc |
限流规则
10次/秒/apikey
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"totalBtcAmount": 0,
"assets": [
{
"currency": "string", // 币种
"currencyId": 0, // 币种ID
"frozenAmount": 0, // 冻结数量
"availableAmount": 0, // 可用数量
"totalAmount": 0, // 总数量
"convertBtcAmount": 0 // 折算BTC数量
}
]
}
}
获取WEX可充提的币种 Edit
/v4/public/wallet/support/currency
备注
currency 、chain 字段需要在后续充值/提现接口中使用
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": [
{
"currency": "BTC", //币种
"supportChains": [
{
"chain": "Bitcon", //支持的转账网络
"depositEnabled": true, //是否支持充值,true:支持,false:不支持
"withdrawEnabled": true, //是否支持提现,true:支持,false:不支持
"withdrawFeeAmount": 0.2, //提现手续费
"withdrawMinAmount": 10, //最小提现数量
"depositFeeRate": 0.2 //充值费率,百分比
}
]
},
{
"currency": "ETF", //币种
"supportChains": [
{
"chain": "Ethereum", //支持的转账网络
"depositEnabled": true, //是否支持充值,true:支持,false:不支持
"withdrawEnabled": true, //是否支持提现,true:支持,false:不支持
"withdrawFeeAmount": 0.2, //提现手续费
"withdrawMinAmount": 10, //最小提现数量
"depositFeeRate": 0.2 //充值费率,百分比
}
]
}
]
}
获取充值地址 Edit
/v4/deposit/address
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| chain | string | true | 转账网络名称 | ||
| currency | string | true | 币种名称 |
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"address": "0xfa3abfa50eb2006f5be7831658b17aca240d8526", //钱包地址
"memo": ""
}
}
充值历史 Edit
/v4/deposit/history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| currency | string | false | 币种名称,可从“获取WEX可充提的币种”接口中获取 | ||
| chain | string | false | 转账网络名称,可从“获取WEX可充提的币种”接口中获取 | ||
| status | string | false | 充值记录的状态 | SUBMIT、REVIEW、AUDITED、PENDING、SUCCESS、FAIL、CANCEL | |
| fromId | long | false | 上次开始分页的Id,即记录的主键id | ||
| direction | string | false | NEXT | 分页方向 | NEXT:下一页,PREV:上一页 |
| limit | int | false | 10 | 每页记录数,最大不超过200 | 1<=limit<=200 |
| startTime | long | false | 查询范围开始边界,毫秒级时间戳 | ||
| endTime | long | false | 查询范围结束边界,毫秒级时间戳 |
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"hasPrev": true, //是否有上一页
"hasNext": true, //是否有下一页
"items": [
{
"id": 169669597, //提现记录id
"currency": "xlm2", //币种名称
"chain": "XLM", //转账网络名称
"memo": "441824256", //memo
"status": "SUCCESS", //充值状态
"amount": "0.1", //充值金额
"confirmations": 12, //区块确认数
"transactionId": "28dd15b5c119e00886517f129e5e1f8283f0286b277bcd3cd1f95f7fd4a1f7fc", //交易哈希
"address": "GBY6UIYEYLAAXRQXVO7X5I4BSSCS54EAHTUILXWMW6ONPM3PNEA3LWEC", //充值目标地址
"fromAddr": "GBTISB3JK65DG6LEEYYFW33RMMDHBQ65AEUPE5VDBTCLYYFS533FTG6Q", //来源地址
"createdTime": 1667260957000 //充值时间,毫秒级时间戳
}
]
}
}
提现 Edit
/v4/withdraw
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| currency | string | true | 币种名称,可从'获取WEX可充提的币种'接口中获取 | ||
| chain | string | true | 转账网络名称,可从'获取WEX可充提的币种'接口中获取 | ||
| amount | number | true | 提现金额,包含手续费部分 | ||
| address | string | true | 提现地址 | ||
| memo | String | false | memo,对于EOS类似的需要memo的链必传 |
注意:参数以json形式放在body中
{
"currency":"zb",
"chain":"Ethereum",
"amount":1000,
"address":"0xfa3abfa50eb2006f5be7831658b17aca240d8526",
"memo":""
}
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"id": 100 //Long 提现记录id,用于后期查询提现历史记录
}
}
提现历史 Edit
/v4/withdraw/history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| currency | string | false | 币种名称,可从'获取WEX可充提的币种'接口中获取 | ||
| chain | string | false | 转账网络名称,可从'获取WEX可充提的币种'接口中获取 | ||
| status | string | false | 提现记录的状态,字符串类型(含义见公共模块-充值/提现记录状态码及含义) | SUBMIT、REVIEW、AUDITED、AUDITED_AGAIN、PENDING、SUCCESS、FAIL、CANCEL | |
| fromId | Long | false | 上次开始分页的Id,即记录的主键id | ||
| direction | String | false | NEXT | 分页方向 | NEXT:下一页,PREV:上一页 |
| limit | int | false | 10 | 每页记录数,最大不超过200 | 1<=limit<=200 |
| startTime | Long | false | 查询范围开始边界,毫秒级时间戳 | ||
| endTime | Long | false | 查询范围结束边界,毫秒级时间戳 |
{
"rc": 0,
"mc": "string",
"ma": [
{}
],
"result": {
"hasPrev": true, //是否有上一页
"hasNext": true, //是否有下一页
"items": [
{
"id": 763111, //提现记录id
"currency": "usdt", //币种名称
"chain": "Ethereum", //提现网络
"address": "0xfa3abfa50eb2", //提现目标地址
"memo": "",
"status": "REVIEW", //状态,含义见公共模块-充值/提现记录状态码及含义
"amount": "30", //提现金额
"fee": "0", //提现手续费
"confirmations": 0, //区块确认数
"transactionId": "", //交易哈希
"createdTime": 1667763470000
},
{
"id": 763107,
"currency": "usdt",
"chain": "Tron",
"address": "TYnJJwaJKkqVvE2zEfUvFbHgKxVBY5zGq9",
"memo": "",
"status": "REVIEW",
"amount": "50",
"fee": "1",
"confirmations": 0,
"transactionId": "",
"createdTime": 1667428286000
}
]
}
}
用户业务系统间划转 Edit
/v4/balance/transfer
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| bizId | string | true | 唯一id 用作重复请求幂等 | 最大长度为128 | |
| from | enum | true | 划出业务账户 | bizType 枚举 | |
| to | enum | true | 划入业务账户 | bizType 枚举 | |
| currency | string | true | 币种名称必须全部小写(usdt,btc) | ||
| symbol | string | false | 划转交易对必须全部小写(划入划出有一方是杠杆此字段必传) | ||
| amount | bigDecimal | true | 划转的数量 |
public String transferPost(){
}
{
"rc": 0,
"mc": "string",
"ma": [],
"result": 123456 //返回的划转唯一id 建议存储用来对账
}
子账户业务系统间划转 Edit
/v4/balance/account/transfer
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| bizId | string | true | 唯一id 用作重复请求幂等 | 最大长度为128 | |
| from | enum | true | 划出业务账户 | bizType 枚举 | |
| to | enum | true | 划入业务账户 | bizType 枚举 | |
| currency | string | true | 币种名称必须全部小写(usdt,btc) | ||
| symbol | string | false | 划转交易对必须全部小写(划入划出有一方是杠杆此字段必传) | ||
| amount | bigDecimal | true | 划转的数量 | ||
| toAccountId | long | true | 划入账户id(必须和划出账户id属于同一个用户否则不支持) | ||
| fromAccountId | long | false | 划出账户id |
public String accountTransferPost(){
}
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": 123456 //返回的划转唯一id 建议存储用来对账
}
WebSocket 基础信息 Edit
基础地址
wss://stream.wexex.io/public
请求头
Sec-WebSocket-Extensions: permessage-deflate
# Python 最小示例 (websocket-client)
# pip install websocket-client
import websocket
url = "wss://stream.wexex.io/public"
headers = ["Sec-WebSocket-Extensions: permessage-deflate"]
ws = websocket.WebSocket()
ws.connect(url, header=headers)
print("已连接到 WEX 公共 WSS")
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {}
}
请求消息格式 Edit
{
"method": "subscribe",
"params": [
"{topic}@{arg},{arg}",
"{topic}@{arg}"
],
"id": "{id}" //回调 ID
}
{
"method": "unsubscribe",
"params": [
"{topic}@{arg},{arg}"
],
"id": "{id}" //回调 ID
}
{
"code": 0,
"msg": "success"
}
响应消息格式 Edit
{
"id": "{id}", //回调 ID
"code": 1, //结果 0=成功; 1=失败; 2=listenKey 无效
"msg": ""
}
{"id":"123", "code": 0, "msg": "success"}
{"id":"123", "code": 401, "msg": "token expire"}
推送消息格式 Edit
{
"topic": "trade", //事件
"event": "trade@btc_usdt", //主题
"data": { } //数据
}
{
"topic": "trade",
"event": "trade@btc_usdt",
"data": {
"s": "btc_usdt", // 交易对
"i": 6316559590087222000, // 交易ID
"t": 1655992403617, // 时间
"oi": 6616559590087222666, // 订单ID
"p": "43000", // 价格
"q": "0.21", // 数量
"v": "9030", // 计价数量
"b": true // 是否买方做市(buyerMaker)
}
}
心跳 Edit
客户端的每个连接需要定期发送文本 “ping”,服务器将回复 “pong”。 如果服务器在 1 分钟内没有收到客户端的 ping 消息,将主动断开连接。
"ping"
"pong"
订阅参数 Edit
格式
{topic}@{arg},{arg},…
{
"code": 0,
"msg": "success"
}
订单簿管理 Edit
如何正确管理本地订单簿
1.建立到 wss://stream.wexex.io/public 的连接,例如 depth_update@btc_usdt。
2.缓存从数据流接收到的事件。
3.从 https://sapi.wexex.io/v4/public/depth?symbol=btc_usdt&limit=500 获取深度快照。
4.丢弃快照中 i <= lastUpdateId 的所有事件。
5.第一个处理的事件应满足 fi <= lastUpdateId+1 且 i >= lastUpdateId+1。
6.监听数据流时,每个新事件的 fi 应等于前一个事件的 i+1。
7.每个事件中的数据是价格档位的绝对数量。
8.如果数量为 0,则移除该价格档位。
9.接收到移除本地订单簿中不存在的价格档位的事件是正常现象。
注意: 由于深度快照对价格档位数量有限制,初始快照之外且数量未发生变化的价格档位不会在增量深度流中更新。因此,即使正确应用增量深度流的所有更新,这些价格档位也不会在本地订单簿中显示。这可能导致本地订单簿与实际订单簿存在细微差异。不过,对于大多数使用场景,500 档深度限制足以理解市场并进行有效交易。
成交记录 Edit
请求
格式: trade@{symbol}
示例: trade@btc_usdt
频率: 实时
{
"topic": "trade",
"event": "trade@btc_usdt",
"data": {
"s": "btc_usdt", // 交易对
"i": 6316559590087222000, // 交易ID
"t": 1655992403617, // 成交时间
"oi": 6616559590087222666, // 订单ID
"p": "43000", // 成交价格
"q": "0.21", // 成交数量
"v": "9030", // 计价数量
"b": true // 方向(buyerMaker)
}
}
K线 Edit
请求
格式: kline@{symbol},{interval}
时间间隔: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
示例: kline@btc_usdt,5m
频率: 1000ms
{
"topic": "kline",
"event": "kline@btc_usdt,5m",
"data": {
"s": "btc_usdt", // 交易对
"t": 1656043200000, // 时间
"i": "5m", // 间隔
"o": "44000", // 开盘价
"c": "50000", // 收盘价
"h": "52000", // 最高价
"l": "36000", // 最低价
"q": "34.2", // 成交量
"v": "230000" // 成交额
}
}
限定深度 Edit
请求
格式: depth@{symbol},{levels}
档位: 5, 10, 20, 50
示例: depth@btc_usdt,20
频率: 1000ms
{
"topic": "depth",
"event": "depth@btc_usdt,20",
"data": {
"s": "btc_usdt", // 交易对
"i": 1657699200000, // updateId
"a": [ // asks 卖盘
[ //[0]价格, [1]数量
"34000", //价格
"1.2" //数量
],
[
"34001",
"2.3"
]
],
"b": [ // bids 买盘
[
"32000",
"0.2"
],
[
"31000",
"0.5"
]
]
}
}
增量深度 Edit
请求
格式: depth_update@{symbol}
示例: depth_update@btc_usdt
频率: 100ms
{
"topic": "depth_update",
"event": "depth_update@btc_usdt",
"data": {
"s": "btc_usdt", // 交易对
"fi": 121, // firstUpdateId 等于上一次推送的lastUpdateId + 1
"i": 123, // lastUpdateId
"a": [ // asks 卖盘
[ // [0]价格, [1]数量
"34000", //价格
"1.2" //数量
],
[
"34001",
"2.3"
]
],
"b": [ // bids 买盘
[
"32000",
"0.2"
],
[
"31000",
"0.5"
]
]
}
}
行情 Edit
请求
格式: ticker@{symbol}
示例: ticker@btc_usdt
频率: 1000ms
{
"topic": "ticker",
"event": "ticker@btc_usdt",
"data": {
"s": "btc_usdt", // 交易对
"t": 1657586700119, // 最后成交时间
"cv": "-200", // 24小时价格变化
"cr": "-0.02", // 24小时价格变化(百分比)
"o": "30000", // 开盘价
"c": "39000", // 收盘价
"h": "38000", // 最高价
"l": "40000", // 最低价
"q": "4", // 成交量
"v": "150000" // 成交额
}
}
所有行情 Edit
请求
格式: tickers
频率: 1000ms(只推送有变化部分)
{
"topic": "tickers",
"event": "tickers",
"data": [ ] // 同 ticker
}
WebSocket 基本信息 Edit
wss://stream.wexex.io/private
请求消息格式 Edit
参数格式
{topic}@{arg},{arg},…
-
请求消息用于订阅或取消订阅 WebSocket 主题。
-
listenKey 必须通过 /v4/ws-token 接口获取。
-
id 是用于匹配响应的自定义请求标识符。
{
"method": "subscribe",
"params": [
"{topic}@{arg},{arg}", //事件订阅
"{topic}@{arg}"
],
"listenKey": "512312356123123123", //监听Key,通过/v4/ws-token接口获取accessToken
"id": "{id}"
}
{
"method": "unsubscribe",
"params": [
"{topic}@{arg},{arg}", //事件订阅
"{topic}@{arg}"
],
"listenKey": "512312356123123123", //监听Key,通过/v4/ws-token接口获取accessToken
"id": "{id}"
}
响应消息格式 Edit
{
"id": "{id}", //回调 ID
"code": 1, //结果 0=成功; 1=失败; 2=listenKey 无效
"msg": ""
}
获取令牌 Edit
/v4/ws-token
说明:
-
限流规则:1 次请求 / 10秒 / apikey
-
accessToken 有效期为 2 天。
-
再次调用此接口将重置有效期。
-
accessToken 相当于 listenKey,用于建立 WebSocket 连接。
curl --location --request POST 'https://sapi.wexex.io/v4/ws-token' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'validate-algorithms: HmacSHA256' \
--header 'validate-recvwindow: 60000' \
--header 'validate-appkey: xxxxxxxxxx' \
--header 'validate-timestamp: xxxxxxxxxx' \
--header 'validate-signature: xxxxxxxxxx'
{
"rc": 0,
"mc": "SUCCESS",
"ma": [],
"result": {
"accessToken": "eyJhbqGciOiJSUzI1NiJ9.eyJhY2NvdW50SWQiOiIyMTQ2Mjg1MzIyNTU5Iiwic3ViIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsInNjb3BlIjoiYXV0aCIsImlzcyI6Inh0LmNvbSIsImxhc3RBdXRoVGltZSI6MTY2MzgxMzY5MDk1NSwic2lnblR5cGUiOiJBSyIsInVzZXJOYW1lIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsImV4cCI6MTY2NjQwNTY5MCwiZGV2aWNlIjoidW5rbm93biIsInVzZXJJZCI6MjE0NjI4NTMyMjU1OX0.h3zJlJBQrK2x1HvUxsKivnn6PlSrSDXXXJ7WqHAYSrN2CG5XPTKc4zKnTVoYFbg6fTS0u1fT8wH7wXqcLWXX71vm0YuP8PCvdPAkUIq4-HyzltbPr5uDYd0UByx0FPQtq1exvsQGe7evXQuDXx3SEJXxEqUbq_DNlXPTq_JyScI",
"refreshToken": "eyJhbGciOiqJSUzI1NiJ9.eyJhY2NvdW50SWQiOiIyMTQ2Mjg1MzIyNTU5Iiwic3ViIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsInNjb3BlIjoicmVmcmVzaCIsImlzcyI6Inh0LmNvbSIsImxhc3RBdXRoVGltZSI6MTY2MzgxMzY5MDk1NSwic2lnblR5cGUiOiJBSyIsInVzZXJOYW1lIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsImV4cCI6MTY2NjQwNTY5MCwiZGV2aWNlIjoidW5rbm93biIsInVzZXJJZCI6MjE0NjI4NTMyMjU1OX0.Fs3YVm5YrEOzzYOSQYETSmt9iwxUHBovh2u73liv1hLUec683WGfktA_s28gMk4NCpZKFeQWFii623FvdfNoteXR0v1yZ2519uNvNndtuZICDdv3BQ4wzW1wIHZa1skxFfqvsDnGdXpjqu9UFSbtHwxprxeYfnxChNk4ssei430"
}
}
推送消息格式 Edit
{
"topic": "trade", //频道名称
"event": "trade@btc_usdt", //事件标识符(含交易对)
"data": { } //数据载荷
}
{
"topic": "trade",
"event": "trade@btc_usdt",
"data": {
"s": "btc_usdt",
"i": 6316559590087222000,
"t": 1655992403617,
"oi": 6616559590087222666,
"p": "43000",
"q": "0.21",
"v": "9030",
"b": true
}
}
余额变动 Edit
订阅格式: balance
当用户账户余额发生变化时触发此推送通知。 支持 SPOT 和 LEVER 两种业务类型。 可用于实时跟踪交易、充值、提现或转账后的余额变化。
{
"method": "subscribe",
"params": ["balance"],
"listenKey": "512312356123123123"
}
{
"topic": "balance",
"event": "balance",
"data": {
"a": "123", // 账户 ID
"t": 1656043204763, // 事件时间(毫秒)
"c": "btc", // 币种
"b": "123", // 现货总余额
"f": "11", // 冻结金额
"z": "SPOT", // 业务类型 [SPOT, LEVER]
"s": "btc_usdt" // 交易对
}
}
订单变动 Edit
订阅格式: order
当订单状态发生变化时触发此推送通知。
可能的订单状态(st):
-
NEW - 新订单创建
-
PARTIALLY_FILLED - 部分成交
-
FILLED - 完全成交
-
CANCELED - 订单取消
-
REJECTED - 订单拒绝
-
EXPIRED - 订单过期
{
"method": "subscribe",
"params": ["order"],
"listenKey": "512312356123123123"
}
{
"topic": "order",
"event": "order",
"data": {
"s": "btc_usdt", // 交易对
"bc": "btc", // 基础币种
"qc": "usdt", // 报价币种
"t": 1656043204763, // 发生时间(毫秒)
"ct": 1656043204663, // 创建时间(毫秒)
"i": "6216559590087220004", // 订单 ID
"ci": "test123", // 客户订单 ID
"st": "PARTIALLY_FILLED", // 状态 NEW/PARTIALLY_FILLED/FILLED/CANCELED/REJECTED/EXPIRED
"sd": "BUY", // 方向 BUY/SELL
"tp": "LIMIT", // 类型 LIMIT/MARKET
"oq": "4", // 原始数量
"oqq": 48000, // 原始报价数量
"eq": "2", // 已成交数量
"lq": "2", // 剩余数量
"p": "4000", // 价格
"ap": "30000", // 平均价格
"f": "0.002" // 手续费
}
}
订单成交 Edit
订阅格式: trade
当发生成交(订单成交)时触发此推送通知。 包含成交详情,如成交 ID、订单 ID、价格、数量和 maker/taker 信息。 可用于实时跟踪已完成的交易。
{
"method": "subscribe",
"params": ["trade"],
"listenKey": "512312356123123123"
}
{
"topic": "trade",
"event": "trade",
"data": {
"s": "btc_usdt", // 交易对
"i": 6316559590087222000, // 成交 ID
"t": 1655992403617, // 成交时间(毫秒)
"oi": 6616559590087222666, // 订单 ID
"p": "43000", // 价格
"q": "0.21", // 数量
"v": "9030", // 报价数量
"b": true, // 买方是否为 maker(true=买方为 maker)
"tm": 1 // Taker/maker:1 = taker,2 = maker
}
}
Basic Information of the Interface Edit
Base URLs
- USDT-M:
https://fapi.wexex.io(for USDT-margined futures) - Coin-M:
https://dapi.wexex.io(for Coin-margined futures)
Network Recommendation
It is not recommended to access WEX APIs via proxy due to high latency and poor stability.
Request Methods
- GET requests: Parameters should be passed in the QueryString.
- POST requests: Parameters can be passed in the RequestBody or QueryString.
When parameters are in the QueryString, include the header: Content-Type: application/x-www-form-urlencoded
When parameters are in the RequestBody, include the header: Content-Type: application/json
API Categories
WEX API endpoints are divided into Public Interfaces and User Interfaces.
Public Interfaces - No authentication required. Parameters are placed in the QueryString. Usually use the GET method.
User Interfaces - Require authentication via HTTP headers. Along with QueryString or RequestBody parameters, the following four headers are required:
| Header | Description |
|---|---|
validate-appkey |
User API key |
validate-timestamp |
Current timestamp (in milliseconds) |
validate-signature |
Request signature |
Content-Type |
Request content type |
Endpoints that do not require signature authentication will be explicitly indicated.
Authentication References
- How to obtain an APPKEY: See Apply for API Key section.
- How to generate a signature: See Obtain Signature section.
Rate Limits
- Asset-related endpoints: Up to 3 requests per second.
- Other endpoints: Up to 10 requests per second per user, and 1000 requests per minute per IP.
If the frequency limit is exceeded, the account will be locked for 10 minutes.
Signature Statement Edit
Signature Parameters Description
Since WEX provides open APIs to third-party platforms, data security must be ensured - for example, preventing data tampering, avoiding outdated data, blocking duplicate submissions, and controlling request frequency. Among these, data integrity verification is the most crucial aspect.
Signature Parameters
- validate-appkey - Public key obtained after applying for the API Key
- validate-timestamp - Request timestamp in milliseconds (Unix time). Request validity is determined based on this value and
validate-recvwindow - validate-signature - Some API requests require a signature. See details in the Obtain Signature section.
- validate-recvwindow - Defines the validity period of a request. Default is 5 seconds; maximum is 60 seconds. If the timestamp is more than 5000ms earlier than server time, the request is invalid. If the client timestamp is more than 1 second ahead of server time, the request will also be rejected. It is not recommended to exceed 5 seconds.
- validate-algorithms - Signature is generated using an HSC-based algorithm. Default: HmacSHA256. Supported: HmacMD5, HmacSHA1, HmacSHA224, HmacSHA256, HmacSHA384, HmacSHA512
Request Header Signature Parameters
| Name | Required | Example | Description |
|---|---|---|---|
| validate-appkey | TRUE | dbefbc809e3e83c283a984c3a1459732ea7db1360ca80c5c2c8867408d28cc83 | Public key |
| validate-timestamp | TRUE | 1641446237201 | Unix timestamp (milliseconds) |
| validate-signature | TRUE | 0a7d0b5e802eb5e52ac0cfcd6311b0faba6e2503a9a8d1e2364b38617877574d | Generated signature |
| validate-recvwindow | FALSE | 5000 (ms) | Validity time window |
| validate-algorithms | FALSE | HmacSHA256 | Default HmacSHA256 |
| api-version | FALSE | 1 | Reserved field, API version number |
| validate-signversion | FALSE | 1 | Reserved field, signature version |
Obtain Signature Edit
Generate Signature
Note: ${?} and $? refer to variable substitution.
To generate a signature (signature), use the SECRET KEY obtained with your API Key to encrypt the unencrypted_string.
Rules
-
If HTTP request parameters are in QueryString:
unencrypted_string = ${fixed_header}#${end_point}#${query_string}When multiple key-value pairs exist inquery_string, sort the keys alphabetically and concatenate with&, for example:keya=value&keyb=value&keyc=value -
If HTTP request parameters are in RequestBody:
unencrypted_string = ${fixed_header}#${end_point}#${request_body}
fixed_header Format
fixed_header = "validate-appkey=${your_appkey}&validate-timestamp=${current_timestamp}"
Each part of unencrypted_string is joined with #.
Example Breakdown
Suppose current timestamp = ***** and your APPKEY = ++++++
fixed_header="validate-appkey=++++++&validate-timestamp=*****"
end_point="/future/user/v1/balance/detail"
query_string="coin=btc"
Then: unencrypted_string="validate-appkey=++++++&validate-timestamp=*****#/future/user/v1/balance/detail#coin=btc"
Generate the Signature
After obtaining the unencrypted_string, you can use the encryption algorithm along with the SECRETKEY to obtain the signature SIGNATURE for the unencrypted_string.
After generating the signature, include SIGNATURE in the HTTP request header as the value of validate-signature.
How to Apply for API Key Edit
Some interfaces require users to apply for an API Key. After obtaining the API Key, users will receive a pair of keys - one for the APPKEY to be included in the HTTP request header and the other for generating the signature. Please create your API Key in the user center of the WEX website or App.
Error Code Edit
| HTTP Code | Response Type | Description |
|---|---|---|
| 200 | OK | API called successfully (function execution may still fail) |
| 400 | BAD_REQUEST | The request URL contains blacklisted keywords, or missing validate-appkey / validate-timestamp headers |
| 403 | FORBIDDEN | Host invalid, tenant disabled, time window expired, IP not in whitelist, signature verification failed, or AppKey unauthorized |
| 405 | METHOD_NOT_ALLOWED | Host header is null |
| 429 | TOO_MANY_REQUESTS | Rate limit exceeded |
| 500 | INTERNAL_SERVER_ERROR | Client IP missing, domain not found, or tenant domain info unavailable |
| 502 | BAD_GATEWAY | Unknown error occurred |
| 503 | SERVICE_UNAVAILABLE | Downstream service not found or temporarily unavailable |
Changelog Edit
New API Endpoints (2025-12-05)
A total of 14 new endpoints have been added, covering Biz-order and Biz-user modules.
Biz-order:
| No. | API Name | Method | Path |
|---|---|---|---|
| 1 | Get Reverse Plan Orders | GET | /future/trade/v1/entrust/reverse-plan-list |
| 2 | Get Historical Reverse Plan Orders | GET | /future/trade/v1/entrust/reverse-plan-list-history |
| 3 | Get Historical TP/SL Orders | GET | /future/trade/v1/entrust/profit-list-history |
| 4 | Get Historical Orders with Trades | GET | /future/trade/v1/order/trade-history |
| 5 | Get All Trade Details (No Pagination) | GET | /future/trade/v1/order/trade-list-all |
| 6 | Get All Orders | GET | /future/trade/v1/order-entrust/list |
| 7 | Get Active Positions | GET | /future/trade/v1/position/list/active |
| 8 | Get Leverage Info | GET | /future/trade/v1/position/leverage/list |
| 9 | Get Historical Positions | GET | /future/trade/v1/position/list-history |
| 10 | Get Cross Margin Maintenance | GET | /future/trade/v1/position/cross-margin/{symbol} |
Biz-user:
| No. | API Name | Method | Path |
|---|---|---|---|
| 11 | Get Auto-Deleveraging History | GET | /future/user/v1/auto-deleverage/history |
| 12 | Get Single Coin Balance | GET | /future/user/v1/compat/balance/{coin} |
| 13 | Get Take-Over Records | GET | /future/user/v1/taker-over/list |
| 14 | Get Historical TP/SL Orders | GET | /future/trade/v1/entrust/profit-list-history |
2025-11-05
Optimized documentation structure and added request examples. No change to API behavior or response schema.
2025-11-04
Structure changes - Renamed most sub-item/page titles for consistency. Removed the Subscription parameters page. Moved several sub-items into General WebSocket Information.
2025-11-03
Information architecture - Removed submodules: Rate limit rules, API library, Response format. Added submodule: Changelog. Renamed submodule: Error codes to General error codes.
Get client ip Edit
/future/public/client
This method does not require a signature.
{
"returnCode": 0,
"msgInfo": "success",
"error": null,
"result": {
"ip": "192.168.1.1"
}
}
Get Trading Pair Currency Edit
/future/market/v1/public/symbol/coins
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [],
"returnCode": 0
}
Get Configuration Information for Single Trading Pair Edit
/future/market/v1/public/symbol/detail
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"baseCoin": "", //Target Assets
"baseCoinDisplayPrecision": 0, //Displayed target currency precision
"baseCoinPrecision": 0, //Target currency precision
"cnDesc": "", //Chinese description of the contract
"cnName": "", //Contract Chinese name
"cnRemark": "", //Contract Remarks (Chinese)
"contractSize": 0, //Contract multiplier(face value)
"contractType": "", //Contract type, perpetual, delivery
"deliveryCompletion": false, //Whether the delivery is completed
"deliveryDate": 0, //delivery time
"deliveryPrice": 0, //delivery price
"depthPrecisionMerge": 0, //Handicap Precision Consolidation
"enDesc": "", //English description of the contract
"enName": "", //Contract English name
"enRemark": "", //Contract Remarks (English)
"initLeverage": 0, //Initial leverage
"initPositionType": "", //Initial position type
"isDisplay": false, //whether to display
"isOpenApi": false, //Whether to support OpenApi
"labels": [], //Label
"liquidationFee": 0, //Forced liquidation fee
"makerFee": 0, //Maker fee
"marketTakeBound": 0, //Market order maximum price deviation
"maxEntrusts": 0, //Maximum active orders
"maxNotional": 0, //Maximum Notional Value
"maxOpenOrders": 0, //Maximum open orders
"maxPrice": 0, //Maximum price
"minNotional": 0, //Minimum notional value
"minPrice": 0, //Minimum price
"minQty": 0, //Minimum quantity
"minStepPrice": 0, //Smallest tick
"multiplierDown": 0, //Floor percentage of sell limit order
"multiplierUp": 0, //Cap percentage of buy limit order
"onboardDate": 0, //List time
"pair": "", //Target trading pair
"plates": [],
"predictEventParam": "", //Event Correlation Parameters
"predictEventSort": "", //Event Correlation Sorting
"predictEventType": "", //Forecast event type
"pricePrecision": 0, //Price precision
"productType": "", //Contract type
"quantityPrecision": 0, //Quantity precision
"quoteCoin": "", //Quote currency
"quoteCoinDisplayPrecision": 0,
"quoteCoinPrecision": 0,
"state": 0,
"supportEntrustType": "",
"supportOrderType": "",
"supportPositionType": "",
"supportTimeInForce": "",
"symbol": "",
"symbolGroupId": 0,
"takerFee": 0,
"tradeSwitch": false,
"underlyingType": ""
},
"returnCode": 0
}
Get Configuration Information for Listed And Tradeable Symbols Edit
/future/market/v3/public/symbol/list
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"baseCoin": "", //Target Assets
"baseCoinDisplayPrecision": 0, //Displayed target currency precision
"cnDesc": "", //Contract description
"cnName": "", //Contract name
"cnRemark": "", //Contract Remarks
"contractSize": 0, //Contract multiplier(face value)
"contractType": "", //Contract type, perpetual, delivery
"deliveryCompletion": false,
"deliveryDate": 0,
"deliveryPrice": 0,
"depthPrecisionMerge": 0,
"enDesc": "",
"enName": "",
"enRemark": "",
"initLeverage": 0,
"initPositionType": "",
"isDisplay": false,
"isOpenApi": false,
"labels": [],
"liquidationFee": 0,
"makerFee": 0,
"marketTakeBound": 0,
"maxEntrusts": 0,
"maxNotional": 0,
"maxOpenOrders": 0,
"maxPrice": 0,
"minNotional": 0,
"minPrice": 0,
"minQty": 0,
"minStepPrice": 0,
"multiplierDown": 0,
"multiplierUp": 0,
"onboardDate": 0,
"pair": "",
"plates": [],
"predictEventParam": "",
"predictEventSort": "",
"predictEventType": "",
"pricePrecision": 0,
"productType": "",
"quantityPrecision": 0, // Deprecated
"quoteCoin": "",
"quoteCoinDisplayPrecision": 0,
"quoteCoinPrecision": 0,
"baseCoinPrecision": 0,
"state": 0,
"supportEntrustType": "",
"supportOrderType": "",
"supportPositionType": "",
"supportTimeInForce": "",
"offTime": "", // Contract plan de-listing time
"symbol": "",
"symbolGroupId": 0,
"takerFee": 0,
"tradeSwitch": false,
"underlyingType": ""
}
],
"returnCode": 0
}
See Leverage Stratification of Single Trading Pair Edit
/future/market/v1/public/leverage/bracket/detail
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:eth_usdt |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"leverageBrackets": [
{
"bracket": 0, // Level
"maintMarginRate": 0, // Maintain margin rate
"maxLeverage": 0, // Maximum leverage
"maxNominalValue": 0, // Maximum notional value
"maxStartMarginRate": 0, // Maximum initial margin rate
"minLeverage": 0, // Minimum leverage
"startMarginRate": 0, // Initial margin rate
"symbol": "" // Trading pair
}
],
"symbol": ""
},
"returnCode": 0
}
Get Market Information for Specific Trading Pair Edit
/future/market/v1/public/q/ticker
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:eth_usdt |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"a": "", // 24h volume
"c": "", // Latest price
"h": "", // Highest price in 24 hours
"l": "", // Lowest price in 24 hours
"o": "", // The first transaction price 24 hours ago
"r": "", // 24h Price Fluctuation Limit
"s": "", // Trading pair
"t": 0, // Time
"v": "" // 24h turnover
},
"returnCode": 0
}
Get Market Information for All Trading Pairs Edit
/future/market/v1/public/q/tickers
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"a": "", // 24h volume
"c": "", // Latest price
"h": "", // Highest price in 24 hours
"l": "", // Lowest price in 24 hours
"o": "", // The first transaction price 24 hours ago
"r": "", // 24h Price Fluctuation Limit
"s": "", // Trading pair
"t": 0, // Time
"v": "" // 24h turnover
}
],
"returnCode": 0
}
Get Latest Transaction Information of Trading Pairs Edit
/future/market/v1/public/q/deal
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt | ||
| num | integer | false | 50 | Quantity |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"a": 0, // Volume
"m": "", // Order side
"p": 0, // Price
"s": "", // Trading pair
"t": 0 // Time
}
],
"returnCode": 0
}
Get Depth Data of Trading Pairs Edit
/future/market/v1/public/q/depth
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt | ||
| level | integer | true | Level (min:1, max:50) | 1~50 |
Limit Flow Rules
10/s/ip
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"a": [], // Buy
"b": [], // Sell
"s": "", // Trading pair
"t": 0, // Time
"u": 0 // updateId
},
"returnCode": 0
}
Get Index Price for Single Trading Pair Edit
/future/market/v1/public/q/symbol-index-price
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"p": 0, // Price
"s": "", // Trading pair
"t": 0 // Time
},
"returnCode": 0
}
Get Index Price for All Trading Pairs Edit
/future/market/v1/public/q/index-price
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"p": 0, // Price
"s": "", // Trading pair
"t": 0 // Time
}
],
"returnCode": 0
}
Get Mark Price for Single Trading Pair Edit
/future/market/v1/public/q/symbol-mark-price
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"p": 0, // Price
"s": "", // Trading pair
"t": 0 // Time
},
"returnCode": 0
}
Get Mark Price for All Trading Pairs Edit
/future/market/v1/public/q/mark-price
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"p": 0, // Price
"s": "", // Trading pair
"t": 0 // Time
}
],
"returnCode": 0
}
Get Trading Pair Information of Kline Edit
/future/market/v1/public/q/kline
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:eth_usdt | ||
| interval | string | true | Time-interval | 1m;5m;15m;30m;1h;4h;1d;1w | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| limit | integer | false | Limit | 1~1500 |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"a": 0, // Volume
"c": 0, // Close price
"h": 0, // Highest price
"l": 0, // Lowest price
"o": 0, // Open price
"s": "", // Trading pair
"t": 0, // Time
"v": 0 // Turnover
}
],
"returnCode": 0
}
Get Aggregated Market Information for Specific Trading Pair Edit
/future/market/v1/public/q/agg-ticker
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:eth_usdt |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"a": "", // 24h volume
"ap": "", // ask price
"bp": "", // bid price
"c": "", // Latest price
"h": "", // Highest price in 24 hours
"i": "", // index price
"l": "", // Lowest price in 24 hours
"m": "", // mark price
"o": "", // The first transaction price 24 hours ago
"r": "", // 24h price fluctuation limit
"s": "", // Trading pair
"t": 0, // Time
"v": "" // 24h Turnover
},
"returnCode": 0
}
Get Aggregated Market Information for All Trading Pairs Edit
/future/market/v1/public/q/agg-tickers
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"a": "", // 24h volume
"ap": "", // ask price
"bp": "", // bid price
"c": "", // Latest price
"h": "", // Highest price in 24 hours
"i": "", // index price
"l": "", // Lowest price in 24 hours
"m": "", // mark price
"o": "", // The first transaction price 24 hours ago
"r": "", // 24h price fluctuation limit
"s": "", // Trading pair
"t": 0, // Time
"v": "" // 24h Turnover
}
],
"returnCode": 0
}
Get Funding Rate Information Edit
/future/market/v1/public/q/funding-rate
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:eth_usdt |
Limit Flow Rules
1/s/ip
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false, // Is there a next page
"hasPrev": false, // Is there a previous page
"items": [ // Datasheets
{
"collectionInternal": 0, // Billing Cycle (hour)
"createdTime": 0, // Time
"fundingRate": 0, // Latest funding rate
"id": 0, // id
"symbol": "" // Trading pair
}
]
},
"returnCode": 0
}
Get Funding Rate Records Edit
/future/market/v1/public/q/funding-rate-record
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair | ||
| direction | string | false | NEXT | Direction (PREV: Previous page; NEXT: Next page) | PREV;NEXT |
| id | integer | false | id | ||
| limit | integer | false | 10 | Limit |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false, // Is there a next page
"hasPrev": false, // Is there a previous page
"items": [ // Datasheets
{
"collectionInternal": 0, // Billing Cycle (second)
"createdTime": 0, // Time
"fundingRate": 0, // Latest funding rate
"id": 0, // id
"symbol": "" // Trading pair
}
]
},
"returnCode": 0
}
Get Ask Bid Market Information for Specific Trading Pair Edit
/future/market/v1/public/q/ticker/book
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:eth_usdt |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"ap": "", // ask price
"aq": "", // ask amount
"bp": "", // bid price
"bq": "", // bid amount
"s": "", // Trading pair
"t": 0 // Time
},
"returnCode": 0
}
Get Ask Bid Market Information for All Trading Pairs Edit
/future/market/v1/public/q/ticker/books
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"ap": "", // ask price
"aq": "", // ask amount
"bp": "", // bid price
"bq": "", // bid amount
"s": "", // Trading pair
"t": 0 // Time
}
],
"returnCode": 0
}
Get Trading Pair Risk Fund Balance Edit
/future/market/v1/public/contract/risk-balance
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:eth_usdt | ||
| direction | string | false | NEXT | Direction (PREV: Previous page; NEXT: Next page) | PREV;NEXT |
| id | integer | false | id | ||
| limit | integer | false | 10 | Limit |
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false, // Is there a next page
"hasPrev": false, // Is there a previous page
"items": [ // Datasheets
{
"amount": 0, // Balance
"coin": "", // Currency
"createdTime": 0, // Time
"id": 0 // id
}
]
},
"returnCode": 0
}
Get the open position of a trading pair Edit
/future/market/v1/public/contract/open-interest
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:eth_usdt |
Limit Flow Rules
1/s/ip
This method does not require a signature.
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"symbol": "", // Trading pair
"openInterest": "", // Open position
"openInterestUsd": 0, // Open value
"time": "" // Time
},
"returnCode": 0
}
Create Orders Edit
/future/trade/v1/order/create
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| clientOrderId | string | false | Client order ID | ||
| symbol | string | true | Trading pair | ||
| orderSide | string | true | Order side | BUY;SELL | |
| orderType | string | true | Order type | LIMIT;MARKET | |
| origQty | number | true | Quantity (Cont) | ||
| price | number | false | Price | ||
| timeInForce | string | false | GTC | Valid way | GTC;IOC;FOK;GTX |
| triggerProfitPrice | number | false | Stop profit price | ||
| triggerStopPrice | number | false | Stop loss price | ||
| positionSide | string | true | Position side | LONG;SHORT |
OrigQty Calculation Formula
origQty = Truncate((Balance * Percent * Leverage) / (Mark_price * Contract_size))
- Truncate: Take the integer part (discard decimals).
- Balance:
(walletBalance - openOrderMarginFrozen), API:/future/user/v1/compat/balance/list - Percent: User input value, e.g.,
0.2 - Leverage: Leverage multiplier, e.g.,
20 - Mark_price: Market mark price, e.g.,
88888(btc_usdt) - Contract_size: Contract face value, API:
/future/market/v1/public/symbol/detail
Example: truncate(10000 * 0.2 * 20 / 88888 / 0.0001) = 4500
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| contract_not_open | Contract not opened |
| exist_bonus_positon_not_create_reverse_position | Unable to create reverse position |
| account_error | Account has no trial fund permission |
| symbol_is_not_open_position | Trading pair is not open |
| invalid_params | Invalid parameters |
| invalid_quantity_scale | origQty must be an integer |
| coupon_unavailable | Coupon unavailable |
| welfare_coupon_not_exist | Coupon does not exist |
| coupon_exceed_max_leverage | Coupon exceeds maximum leverage |
| exceed_max_leverage | Exceeds maximum leverage |
| gateway_decommission_ip_country | Services not available to users from restricted countries/regions |
| gateway_decommission_kyc_country | Services not available to users from restricted countries/regions |
| GATEWAY_0003 | The user has triggered risk control; operation temporarily prohibited |
| GATEWAY_0006 | Account locked due to triggering risk control rules |
| GATEWAY_0007 | Account locked due to triggering risk control rules |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Update Orders Edit
/future/trade/v1/order/update
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | number | true | Order ID | ||
| price | number | true | Target price | ||
| origQty | number | true | Target quantity (cont) | ||
| triggerProfitPrice | number | false | Profit target price | ||
| triggerStopPrice | number | false | Stop-Loss price | ||
| triggerPriceType | string | false | LATEST_PRICE | Trigger price type | INDEX_PRICE; MARK_PRICE; LATEST_PRICE |
| profitDelegateOrderType | string | false | Take-Profit order type | LIMIT; MARKET | |
| profitDelegateTimeInForce | string | false | Take-Profit order validity method | GTC; IOC; FOK; GTX | |
| profitDelegatePrice | number | false | Take-Profit order price | ||
| stopDelegateOrderType | string | false | Stop-Loss order type | LIMIT; MARKET | |
| stopDelegateTimeInForce | string | false | Stop-Loss order validity method | GTC; IOC; FOK; GTX | |
| stopDelegatePrice | number | false | Stop-Loss order price | ||
| followUpOrder | boolean | false | If true, indicates chase order |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_order | Order ID does not exist |
| invalid_params | Invalid parameter setting |
| invalid_quantity | origQty must be an integer |
| invalid_price | Invalid price setting |
| invalid_trigger_profit_price | Invalid take-profit price setting |
| invalid_trigger_stop_price | Invalid stop-loss price setting |
| trigger_profit_price_less_than_order_delegate_price | Take-profit trigger price cannot be lower than the order price (Long) |
| trigger_profit_price_more_than_order_delegate_price | Take-profit trigger price cannot be higher than the order price (Short) |
| trigger_stop_price_more_than_order_delegate_price | Stop-loss trigger price cannot be higher than the order price (Long) |
| trigger_stop_price_less_than_order_delegate_price | Stop-loss trigger price cannot be lower than the order price (Short) |
| invalid_time_in_force | Invalid order time-in-force |
| on_board_30_minutes_limit_order_price_limit | Limit order price restriction within 30 minutes after listing |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Bulk Orders Edit
/future/trade/v2/order/create-batch
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| list | string | true | List collection of order data |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| gateway_decommission_ip_country | Services not available to users from restricted countries/regions |
| gateway_decommission_kyc_country | Services not available to users from restricted countries/regions |
| GATEWAY_0003 | The current user has triggered a risk control rule, operation temporarily disabled |
| GATEWAY_0006 | Account locked due to risk control |
| GATEWAY_0007 | Account locked due to risk control |
| invalid_symbol | The trading pair does not exist |
| symbol_is_not_trading | The trading pair is not currently tradable |
| openapi_not_supported | The trading pair does not support API operations |
| symbol_is_not_open_position | The trading pair cannot hold positions |
| invalid_params | Invalid parameter settings |
| invalid_quantity | origQty must be an integer |
| quantity_can_not_less_than * | origQty must be greater than * |
| user_can_not_trade | The account is currently prohibited from trading |
| sub_account_not_trade | Sub-account is not allowed to trade |
| user_can_not_open_position | The account cannot open positions |
| invalid_time_in_force | Invalid time-in-force setting |
| invalid_price | Invalid price setting |
| invalid_trigger_profit_price | Invalid take-profit price |
| invalid_trigger_stop_price | Invalid stop-loss price |
| trigger_profit_price_more_than_sell_one_price | Take-profit trigger price must be higher than the best ask (long) |
| trigger_profit_price_less_than_buy_one_price | Take-profit trigger price must be lower than the best bid (short) |
| trigger_stop_price_more_than_sell_one_price | Stop-loss trigger price must be lower than the best ask (long) |
| trigger_stop_price_less_than_buy_one_price | Stop-loss trigger price must be higher than the best bid (short) |
| trigger_profit_price_less_than_order_delegate_price | Take-profit trigger price cannot be lower than the order price (long) |
| trigger_profit_price_more_than_order_delegate_price | Take-profit trigger price cannot be higher than the order price (short) |
| trigger_stop_price_more_than_order_delegate_price | Stop-loss trigger price cannot be higher than the order price (long) |
| trigger_stop_price_less_than_order_delegate_price | Stop-loss trigger price cannot be lower than the order price (short) |
| on_board_30_minutes_limit_order_price_limit | Limit order price restricted within 30 minutes after listing |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": "",
"returnCode": 0
}
Batch Order Placement Edit
/future/trade/v2/order/atomic-create-batch
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| (JSON Array Body) | array | true | Request body is a JSON array, where each element represents an individual order |
Rate Limit
200 requests/second per apikey
Error Codes
| Error Code | Description |
|---|---|
| gateway_decommission_ip_country | Services not available to users from restricted countries/regions |
| gateway_decommission_kyc_country | Services not available to users from restricted countries/regions |
| GATEWAY_0003 | The user has triggered risk control; operation temporarily blocked |
| GATEWAY_0006 | Account locked due to risk control |
| GATEWAY_0007 | Account locked due to risk control |
| invalid_symbol | The trading pair does not exist |
| symbol_is_not_trading | The trading pair is not currently available for trading |
| openapi_not_supported | The trading pair does not support OpenAPI operations |
| symbol_is_not_open_position | The trading pair cannot open positions |
| invalid_params | Invalid parameters |
| invalid_quantity | origQty must be an integer |
| quantity_can_not_less_than * | origQty must be greater than * |
| user_can_not_trade | The account is currently prohibited from trading |
| sub_account_not_trade | The sub-account is not allowed to trade |
| user_can_not_open_position | The account cannot open new positions |
| invalid_time_in_force | Invalid timeInForce parameter |
| invalid_price | Invalid price setting |
| invalid_trigger_profit_price | Invalid take-profit trigger price |
| invalid_trigger_stop_price | Invalid stop-loss trigger price |
| trigger_profit_price_more_than_sell_one_price | Take-profit trigger price must be higher than the best ask (long position) |
| trigger_profit_price_less_than_buy_one_price | Take-profit trigger price must be lower than the best bid (short position) |
| trigger_stop_price_more_than_sell_one_price | Stop-loss trigger price must be lower than the best ask (long position) |
| trigger_stop_price_less_than_buy_one_price | Stop-loss trigger price must be higher than the best bid (short position) |
| trigger_profit_price_less_than_order_delegate_price | Take-profit trigger price cannot be lower than the order price (long) |
| trigger_profit_price_more_than_order_delegate_price | Take-profit trigger price cannot be higher than the order price (short) |
| trigger_stop_price_more_than_order_delegate_price | Stop-loss trigger price cannot be higher than the order price (long) |
| trigger_stop_price_less_than_order_delegate_price | Stop-loss trigger price cannot be lower than the order price (short) |
| on_board_30_minutes_limit_order_price_limit | Limit order price restrictions apply within 30 minutes of listing |
| order_create_size_exceed | The number of orders in a single batch exceeds the maximum limit (20 orders) |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": "",
"returnCode": 0
}
See Orders by ID Edit
/future/trade/v1/order/detail
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | integer | true | Order ID |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| null | Order not found |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"avgPrice": 0,
"closePosition": false,
"closeProfit": 0,
"createdTime": 0,
"executedQty": 0,
"forceClose": false,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"sourceId": 0,
"state": "",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
},
"returnCode": 0
}
See Orders Edit
/future/trade/v1/order/list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| clientOrderId | string | false | Client order ID | ||
| page | integer | false | 1 | Page | |
| size | integer | false | 10 | Quantity of a single page | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| state | string | false | NEW | Order state: NEW (unfilled); PARTIALLY_CANCELED; FILLED; CANCELED; REJECTED; EXPIRED; UNFINISHED; HISTORY | PREV; NEXT |
| symbol | string | false | Trading pair |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid state | Invalid state parameter |
| invalid_symbol | The trading pair does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"clientOrderId": "",
"avgPrice": 0,
"closePosition": false,
"closeProfit": 0,
"createdTime": 0,
"executedQty": 0,
"forceClose": false,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"sourceId": 0,
"state": "",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
Cancel Orders Edit
/future/trade/v1/order/cancel
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | integer | true | Order ID |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_params | Parameter error or order does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": "",
"returnCode": 0
}
Batch Cancel Orders Edit
/future/trade/v1/order/cancel-batch
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderIds | string | true | Order IDs (comma-separated) | ||
| clientOrderIds | string | false | Client order IDs (comma-separated) |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
Cancel All Orders Edit
/future/trade/v1/order/cancel-all
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair (cancel all trading pair orders if pass empty string) |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
| fail | Internal error |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
Get Open Order List Edit
/future/trade/v1/order/list-open-order
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair name (e.g. eth_usdt, btc_usdt) |
Rate Limit
10/s/apikey
{
"orderId": "538511221008857280",
"clientOrderId": "myOrder123",
"symbol": "eth_usdt",
"contractSize": 0.01,
"orderType": "LIMIT",
"orderSide": "BUY",
"positionSide": "LONG",
"positionType": "ISOLATED",
"timeInForce": "GTC",
"price": "4009.94",
"origQty": "12",
"avgPrice": "0",
"executedQty": "0",
"marginFrozen": "80.48751569",
"remark": null,
"sourceId": null,
"sourceType": "DEFAULT",
"leverage": 6,
"openPrice": null,
"state": "NEW",
"createdTime": 1758093080143,
"updatedTime": 1758093080371,
"welfareAccount": false,
"triggerPriceType": null,
"triggerProfitPrice": null,
"profitDelegateOrderType": null,
"profitDelegateTimeInForce": null,
"profitDelegatePrice": null,
"triggerStopPrice": null,
"stopDelegateOrderType": null,
"stopDelegateTimeInForce": null,
"stopDelegatePrice": null,
"markPrice": "4543.73",
"desc": null
}
See Order History Edit
/future/trade/v1/order/list-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pairs (queries all trading pairs if not passed) | ||
| direction | string | false | NEXT | Direction | PREV;NEXT |
| id | integer | false | id | ||
| limit | integer | false | 10 | Limit | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| forceClose | string | false | false | Force liquidation information. Without this field, the force liquidation order information will not be displayed. |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | The trading pair does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"clientOrderId": "",
"avgPrice": 0,
"closePosition": false,
"closeProfit": 0,
"createdTime": 0,
"executedQty": 0,
"forceClose": false,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"sourceId": 0,
"state": "",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
}
]
},
"returnCode": 0
}
See Transaction Details Edit
/future/trade/v1/order/trade-list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | integer | false | Order ID | ||
| symbol | string | false | Trading pair | ||
| page | integer | false | 1 | Page | |
| size | integer | false | 10 | Quantity of a single page | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_page | Page number must be a positive integer |
| invalid_size | The maximum value of size is 100 |
| invalid_symbol | The trading pair does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"fee": 0,
"feeCoin": "",
"orderId": 0,
"execId": 0,
"price": 0,
"quantity": 0,
"symbol": "",
"timestamp": 0,
"takerMaker": "TAKER"
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
Query Partially Filled and Partially Canceled Orders Edit
/future/trade/v2/order/partial-canceled-orders
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| page | integer | true | 1 | Page number | |
| size | integer | true | 10 | Number of items per page | |
| startTime | integer | true | Start time (interval between start and end must be within 300000 milliseconds) | ||
| endTime | integer | true | End time | ||
| symbol | string | true | Trading pair |
Remark
This interface can only query data within the last five minutes.
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Invalid trading pair |
| invalid_time_in_force | Invalid time configuration |
| the_number_of_orders_has_reached_the_maximum | Too much data in the interval, limit exceeded |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"clientOrderId": "",
"avgPrice": 0,
"closePosition": false,
"closeProfit": 0,
"createdTime": 0,
"executedQty": 0,
"forceClose": false,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"sourceId": 0,
"state": "PARTIALLY_CANCELED",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0,
"canceledQty": 0
}
]
},
"returnCode": 0
}
See Orders (OrderList) Edit
/future/trade/v1/order/OrderList
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair |
Limit Flow Rules
100/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"clientOrderId": "",
"createdTime": 0,
"executedQty": 0,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
See Order History (Quant) Edit
/future/trade/v1/order/quant/list-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| id | long | false | Cursor ID for pagination, the last orderId from previous response | ||
| direction | string | false | NEXT | Pagination direction | PREV;NEXT |
| limit | integer | false | 10 | Number of records per page, max 2000 | |
| symbol | string | false | Trading pair | ||
| forceClose | boolean | false | false | Whether to query forced liquidation orders | |
| startTime | long | false | Start time (millisecond timestamp), earliest 90 days ago | ||
| endTime | long | false | End time (millisecond timestamp) | ||
| origType | integer | false | Conditional order type: 1=Limit TP, 2=Limit SL, 3=Market TP, 4=Market SL | ||
| orderSide | integer | false | Order side: 1=Buy, 2=Sell | ||
| states | list | false | Order states: 2=Partially Filled, 3=Filled, 4=Canceled, 6=Expired | ||
| orderOrigType | integer | false | Order type: 1=Limit, 2=Market, 3=Limit TP/SL, 4=Market TP/SL, 5=MMR Stop Loss | ||
| welfareAccount | boolean | false | false | Whether to query bonus account |
Quant account dedicated historical order query interface, supports cursor pagination, returns up to 2000 records.
Limit Flow Rules
200/s/apikey
Cursor Pagination Guide
- First request: Do not pass the
idparameter - Next page: Use the last record’s ID from the previous response as the
idparameter, withdirection=NEXT - Previous page: Use the first record’s ID from the current list as the
idparameter, withdirection=PREV - Check for more data: Use
hasNextandhasPrevfields
Error Codes
| Error Code | Description |
|---|---|
| not_quantification_account | Not a quant account, no permission to access this interface |
{
"returnCode": 0,
"msgInfo": "",
"error": {
"code": "",
"msg": ""
},
"result": {
"hasPrev": false,
"hasNext": true,
"items": [
{
"orderId": 123456789,
"clientOrderId": "",
"symbol": "btc_usdt",
"orderSide": "BUY",
"orderType": "LIMIT",
"positionSide": "LONG",
"price": "50000.00",
"origQty": "0.1",
"executedQty": "0.1",
"avgPrice": "50000.00",
"state": "FILLED",
"closePosition": false,
"closeProfit": "100.00",
"marginFrozen": "0",
"forceClose": false,
"sourceId": 0,
"timeInForce": "GTC",
"triggerProfitPrice": "0",
"triggerStopPrice": "0",
"createdTime": 1703520000000,
"updatedTime": 1703520100000
}
]
}
}
See Transaction Details (Quant) Edit
/future/trade/v1/order/quant/trade-list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| id | long | false | Cursor ID for pagination (the last execId from previous response) | ||
| direction | string | false | NEXT | Pagination direction | PREV;NEXT |
| limit | integer | false | 10 | Number of records per page, max 2000 | |
| orderId | long | false | Order ID | ||
| symbol | string | false | Trading pair | ||
| startTime | long | false | Start time (millisecond timestamp) | ||
| endTime | long | false | End time (millisecond timestamp) | ||
| welfareAccount | boolean | false | false | Whether to query bonus account |
Quant account dedicated transaction details query interface, supports cursor pagination, returns up to 2000 records.
Limit Flow Rules
200/s/apikey
Cursor Pagination Guide
- First request: Do not pass the
idparameter - Next page: Use the last record’s
execIdfrom the previous response as theidparameter, withdirection=NEXT - Previous page: Use the first record’s
execIdfrom the current list as theidparameter, withdirection=PREV - Check for more data: Use
hasNextandhasPrevfields
Error Codes
| Error Code | Description |
|---|---|
| not_quantification_account | Not a quant account, no permission to access this interface |
{
"returnCode": 0,
"msgInfo": "",
"error": {
"code": "",
"msg": ""
},
"result": {
"hasPrev": false,
"hasNext": true,
"items": [
{
"execId": 987654321,
"orderId": 123456789,
"symbol": "btc_usdt",
"price": "50000.00",
"quantity": "0.05",
"quoteQty": "2500.00",
"fee": "1.25",
"feeCoin": "USDT",
"takerMaker": "TAKER",
"timestamp": 1703520050000
}
]
}
}
Create Trigger Orders Edit
/future/trade/v1/entrust/create-plan
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| clientOrderId | string | false | Client order ID | ||
| symbol | string | true | Trading pair | ||
| orderSide | string | true | Order side | BUY;SELL | |
| entrustType | string | true | Order type: TAKE_PROFIT (Take Profit Limit); STOP (Stop Limit); TAKE_PROFIT_MARKET (Take Profit Market); STOP_MARKET (Stop Loss Market) | TAKE_PROFIT;STOP;TAKE_PROFIT_MARKET;STOP_MARKET | |
| origQty | number | true | Quantity (Cont) | ||
| price | number | false | Price | ||
| stopPrice | number | true | Trigger price | ||
| timeInForce | string | true | Valid way: GTC; IOC; FOK; GTX. Market orders only support IOC | GTC;IOC;FOK;GTX | |
| triggerPriceType | string | true | Trigger price type | INDEX_PRICE;MARK_PRICE;LATEST_PRICE | |
| positionSide | string | true | Position side | LONG;SHORT |
Content-Type = application/x-www-form-urlencoded && application/json
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| deposit_coupon_exists | Margin coupon already exists |
| exist_bonus_positon_not_create_reverse_position | Reverse position not allowed when a bonus position exists |
| invalid_params | Required parameter missing |
| invalid_price | Invalid price; take-profit/stop-loss limit price validation failed |
| market_plan_entrust_must_be_ioc_or_fok | Market TP/SL order must use IOC or FOK |
| invalid_stop_price | Invalid stop price |
| invalid_quantity_scale | Order quantity must be an integer |
| invalid_trigger_profit_price | Invalid take-profit trigger price |
| invalid_time_in_force | timeInForce validation failed for planned take-profit order |
| on_board_30_minutes_limit_order_price_limit | Limit order price restriction within first 30 minutes after listing |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Cancel Trigger Orders Edit
/future/trade/v1/entrust/cancel-plan
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| entrustId | string | true | Plan order ID |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_params | The provided parameter is empty or incorrect |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Cancel All Trigger Orders Edit
/future/trade/v1/entrust/cancel-all-plan
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair | e.g. btc_usdt |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
| fail | Internal error |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
See Trigger Orders Edit
/future/trade/v1/entrust/plan-list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pairs (queries all trading pairs if not passed) | ||
| page | integer | false | 1 | Page | |
| size | integer | false | 10 | Quantity of a single page | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| state | string | true | Order status | NOT_TRIGGERED;TRIGGERING;TRIGGERED;USER_REVOCATION;PLATFORM_REVOCATION;EXPIRED;UNFINISHED;HISTORY |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_state | Invalid state parameter |
| invalid_symbol | Trading pair does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"clientOrderId": "",
"closePosition": false,
"createdTime": 0,
"entrustId": 0,
"entrustType": "",
"marketOrderLevel": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"timeInForce": "",
"triggerPriceType": ""
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
See Trigger Orders by EntrustId Edit
/future/trade/v1/entrust/plan-detail
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| entrustId | integer | true | Order ID |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_entrust_Id | Invalid order ID |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"closePosition": false,
"createdTime": 0,
"entrustId": 0,
"entrustType": "",
"marketOrderLevel": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"timeInForce": "",
"triggerPriceType": ""
},
"returnCode": 0
}
See Trigger Orders History Edit
/future/trade/v1/entrust/plan-list-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair (if not provided, queries all pairs) | ||
| direction | string | false | NEXT | Query direction | PREV;NEXT |
| id | integer | false | Record ID | ||
| limit | integer | false | 10 | Limit number of records | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"clientOrderId": "",
"closePosition": false,
"createdTime": 0,
"entrustId": 0,
"entrustType": "",
"marketOrderLevel": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"timeInForce": "",
"triggerPriceType": ""
}
]
},
"returnCode": 0
}
Create Stop Limit Edit
/future/trade/v1/entrust/create-profit
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair | ||
| origQty | integer | true | Quantity (contracts) | ||
| triggerProfitPrice | integer | true | Take-profit trigger price | ||
| triggerStopPrice | integer | true | Stop-loss trigger price | ||
| expireTime | integer | true | Expiration time (timestamp) | ||
| positionSide | string | true | Position side | LONG;SHORT | |
| profitDelegateOrderType | string | true | Take-profit order type | LIMIT;MARKET | |
| profitDelegateTimeInForce | string | true | Take-profit order time in force | GTC;FOK;IOC;GTX | |
| profitDelegatePrice | number | false | Take-profit order price | ||
| stopDelegateOrderType | string | true | Stop-loss order type | LIMIT;MARKET | |
| stopDelegateTimeInForce | string | true | Stop-loss order time in force | GTC;FOK;IOC;GTX | |
| stopDelegatePrice | number | false | Stop-loss order price |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_time_in_force | Failed to set time-in-force for TP/SL |
| invalid_params | Invalid or missing parameters |
| invalid_quantity_scale | Quantity must be a positive integer |
| invalid_trigger_profit_price | Invalid take-profit trigger price |
| invalid_trigger_stop_price | Invalid stop-loss trigger price |
| quantity_can_not_less_than | Order quantity is below the minimum limit |
| invalid_price | Invalid price setting |
| more_than_available | Exceeds available quantity |
| trigger_profit_price_less_than_entry_price | Take-profit price must be higher than entry price (LONG) |
| trigger_profit_price_less_than_mark_price | Take-profit price must be higher than mark price (LONG) |
| trigger_profit_price_less_than_index_price | Take-profit price must be higher than index price (LONG) |
| trigger_profit_price_more_than_entry_price | Take-profit price must be lower than entry price (SHORT) |
| trigger_profit_price_more_than_mark_price | Take-profit price must be lower than mark price (SHORT) |
| trigger_profit_price_more_than_index_price | Take-profit price must be lower than index price (SHORT) |
| trigger_stop_price_less_than_entry_price | Stop-loss price must be higher than entry price (SHORT) |
| trigger_stop_price_less_than_mark_price | Stop-loss price must be higher than mark price (SHORT) |
| trigger_stop_price_less_than_index_price | Stop-loss price must be higher than index price (SHORT) |
| trigger_stop_price_more_than_entry_price | Stop-loss price must be lower than entry price (LONG) |
| trigger_stop_price_more_than_mark_price | Stop-loss price must be lower than mark price (LONG) |
| trigger_stop_price_more_than_index_price | Stop-loss price must be lower than index price (LONG) |
| user_can_not_trade | Account prohibited from trading |
| sub_account_not_trade | Sub-account not allowed to trade |
| user_can_not_open_position | Account restricted from opening positions |
| invalid_symbol | Trading pair does not exist |
| symbol_is_not_trading | Trading pair is not in trading state |
| symbol_is_not_open_position | Trading pair not open for position |
| symbol_not_support_openapi | The trading pair does not support placing orders through OpenAPI |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
Cancel Stop Limit Edit
/future/trade/v1/entrust/cancel-profit-stop
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| profitId | integer | true | Profit/Stop order ID |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_entrust | Invalid order ID |
| fail | Internal error |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
Cancel All Stop Limit Edit
/future/trade/v1/entrust/cancel-all-profit-stop
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair, e.g., btc_usdt |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
| fail | Internal error |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
See Stop Limit Edit
/future/trade/v1/entrust/profit-list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair (if not provided, query all pairs) | ||
| page | integer | false | 1 | Page number | |
| size | integer | false | 10 | Number per page | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| state | string | true | Order state | NOT_TRIGGERED;TRIGGERING;TRIGGERED;USER_REVOCATION;PLATFORM_REVOCATION;EXPIRED;UNFINISHED;HISTORY |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
| invalid_position_type | Invalid position type |
| invalid_position_side | Invalid position side |
| invalid_state | Invalid state type |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"createdTime": 0,
"entryPrice": 0,
"executedQty": 0,
"isolatedMargin": 0,
"origQty": 0,
"positionSide": "",
"positionSize": 0,
"profitId": 0,
"state": "",
"symbol": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0,
"profitDelegateOrderType": "LIMIT",
"profitDelegatePrice": 0,
"profitDelegateTimeInForce": "GTC",
"stopDelegateOrderType": "LIMIT",
"stopDelegatePrice": 0,
"stopDelegateTimeInForce": "GTC"
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
See Stop Limit by ProfitId Edit
/future/trade/v1/entrust/profit-detail
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| profitId | integer | true | Profit and Stop order ID |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_profit_id | Profit ID does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"createdTime": 0,
"entryPrice": 0,
"executedQty": 0,
"isolatedMargin": 0,
"origQty": 0,
"positionSide": "",
"positionSize": 0,
"profitId": 0,
"state": "",
"symbol": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
},
"returnCode": 0
}
Alter Stop Limit Edit
/future/trade/v1/entrust/update-profit-stop
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| profitId | integer | true | Profit and Stop order ID | ||
| triggerProfitPrice | number | false | Take-profit trigger price | ||
| triggerStopPrice | number | false | Stop-loss trigger price |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_entrust | Profit ID does not exist |
| user_can_not_trade | Account prohibited from trading |
| sub_account_not_trade | Sub-account cannot trade |
| user_can_not_open_position | Account restricted from opening positions |
| invalid_order_type | Invalid order type |
| invalid_trigger_profit_price | Invalid take-profit price |
| invalid_trigger_stop_price | Invalid stop-loss price |
| invalid_origQty | Invalid order quantity |
| invalid_quantity_scale | Order quantity must be an integer |
| invalid_time_in_force | Invalid time-in-force setting |
| trigger_profit_price_less_than_entry_price | Take-profit price must be higher than entry price (long) |
| trigger_profit_price_less_than_mark_price | Take-profit price must be higher than current mark price (long) |
| trigger_profit_price_less_than_index_price | Take-profit price must be higher than current index price (long) |
| trigger_profit_price_more_than_entry_price | Take-profit price must be lower than entry price (short) |
| trigger_profit_price_more_than_mark_price | Take-profit price must be lower than current mark price (short) |
| trigger_profit_price_more_than_index_price | Take-profit price must be lower than current index price (short) |
| trigger_stop_price_less_than_entry_price | Stop-loss price must be higher than entry price (short) |
| trigger_stop_price_less_than_mark_price | Stop-loss price must be higher than current mark price (short) |
| trigger_stop_price_less_than_index_price | Stop-loss price must be higher than current index price (short) |
| trigger_stop_price_more_than_entry_price | Stop-loss price must be lower than entry price (long) |
| trigger_stop_price_more_than_mark_price | Stop-loss price must be lower than current mark price (long) |
| trigger_stop_price_more_than_index_price | Stop-loss price must be lower than current index price (long) |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Create Track Edit
/future/trade/v1/entrust/create-track
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| callback | string | true | Callback type configuration | FIXED;PROPORTION | |
| callbackVal | number | true | Callback value (must be > 0) | >0 | |
| orderSide | string | true | Order side | BUY;SELL | |
| origQty | number | true | Original quantity (contracts) | ||
| positionSide | string | true | Position side | BOTH;LONG;SHORT | |
| positionType | string | true | Position type | CROSSED;ISOLATED | |
| symbol | string | true | Trading pair | ||
| triggerPriceType | string | true | Trigger price type | INDEX_PRICE;MARK_PRICE;LATEST_PRICE | |
| activationPrice | number | false | Activation price | ||
| clientMedia | string | false | Client media | ||
| clientMediaChannel | string | false | Client media channel | ||
| clientOrderId | string | false | Client order ID | ||
| expireTime | integer | false | Expiration time |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
| symbol_is_not_trading | Trading pair is not available for trading |
| symbol_not_support_openapi | The trading pair does not support placing orders via OpenAPI |
| deposit_coupon_exists | The coupon has been claimed or already bound |
| exist_bonus_positon_not_create_reverse_position | Reverse position cannot be created |
| invalid_params | Invalid or missing parameters |
| invalid_exceed_max_rate_limit | Callback ratio exceeds maximum limit |
| invalid_below_min_rate_limit | Callback ratio below minimum limit |
| invalid_exceed_max_price_limit | Callback ratio exceeds latest transaction price limit |
| invalid_exceed_min_price_limit | Callback ratio below latest transaction price limit |
| invalid_activation_price | Invalid activation price |
| invalid_quantity_scale | Quantity must be an integer |
| user_can_not_trade | Account prohibited from trading |
| sub_account_not_trade | Sub-account cannot trade |
| user_can_not_open_position | Account restricted from opening positions |
| symbol_is_not_open_position | The trading pair is not open for new positions |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Cancel Single Track Edit
/future/trade/v1/entrust/cancel-track
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| trackId | integer | true | Tracking order ID |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_track_entrust | Tracking order does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Get Single Track Detail Edit
/future/trade/v1/entrust/track-detail
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| trackId | integer | true | Tracking order ID |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_track_Id | Tracking order does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"activationPrice": 0,
"avgPrice": 0,
"callback": "",
"callbackVal": 0,
"configActivation": false,
"createdTime": 0,
"currentPrice": 0,
"desc": "",
"executedQty": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"trackId": 0,
"triggerPriceType": "",
"updatedTime": 0
},
"returnCode": 0
}
Get Track List (All Active) Edit
/future/trade/v1/entrust/track-list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| page | integer | false | 1 | Page number | |
| size | integer | false | 10 | Number of items per page | |
| endTime | integer | false | End time | ||
| startTime | integer | false | Start time | ||
| symbol | string | false | Trading pair |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"activationPrice": 0,
"avgPrice": 0,
"callback": "",
"callbackVal": 0,
"configActivation": false,
"createdTime": 0,
"currentPrice": 0,
"desc": "",
"executedQty": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"trackId": 0,
"triggerPriceType": "",
"updatedTime": 0
}
],
"page": 1,
"ps": 10,
"total": 20
},
"returnCode": 0
}
Cancel All Track Edit
/future/trade/v1/entrust/cancel-all-track
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
| fail | Internal error |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Get History Track List (Inactive) Edit
/future/trade/v1/entrust/track-list-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| direction | string | false | NEXT | Pagination direction | PREV;NEXT |
| limit | integer | false | 10 | Number of items per page | |
| id | integer | false | Record ID | ||
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| symbol | string | false | Trading pair |
Limit Flow Rules
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": true,
"hasPre": true,
"items": [
{
"activationPrice": 0,
"avgPrice": 0,
"callback": "",
"callbackVal": 0,
"configActivation": false,
"createdTime": 0,
"currentPrice": 0,
"desc": "",
"executedQty": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"trackId": 0,
"triggerPriceType": "",
"updatedTime": 0
}
]
},
"returnCode": 0
}
Query Historical Take-Profit & Stop-Loss Orders Edit
/future/trade/v1/entrust/profit-list-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| id | integer | false | 1 | Page number | |
| limit | integer | false | 10 | Page size | |
| startTime | integer | false | Start time (default: query data from 90 days ago) | ||
| endTime | integer | false | End time | ||
| symbol | string | false | Trading pair | ||
| direction | string | false | NEXT | Pagination direction | NEXT;PREVIOUS |
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_direction | Direction incorrect |
| invalid_limit | Invalid limit parameter |
| invalid_symbol | Invalid trading pair |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"profitId": "",
"symbol": "BTCUSDT",
"positionSide": "LONG",
"origQty": "0.020",
"leverage": 20,
"triggerPriceType": "MARK_PRICE",
"triggerProfitPrice": "68500.00",
"triggerStopPrice": "59500.00",
"entryPrice": "63250.80",
"positionSize": "0.020",
"isolatedMargin": "63.25",
"executedQty": "0.020",
"avgPrice": "68320.50",
"positionType": "ISOLATED",
"delegateQty": "0.020",
"delegatePrice": "68200.00",
"profitDelegateOrderType": "1",
"profitDelegateTimeInForce": "1",
"profitDelegatePrice": "68200.00",
"stopDelegateOrderType": "2",
"stopDelegateTimeInForce": "3",
"stopDelegatePrice": null,
"closeType": "ALL",
"state": "TRIGGERED",
"desc": "",
"triggerPriceSide": "PROFIT",
"createdTime": 1735689000000,
"updatedTime": 1735690123000,
"sourceType": "WEB",
"profitType": 0,
"mmrThreshold": null
}
]
},
"returnCode": 0
}
Query Reverse Plan Edit
/future/trade/v1/entrust/reverse-plan-list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| positionType | string | false | Position type | crossed;isolated | |
| positionSide | string | false | Position side | long;short | |
| closeType | string | false | Close type | fixed;all | |
| state | string | false | Order state | not_triggered;triggered;triggering;user_revocation;platform_revocation;expired | |
| symbol | string | false | Trading pair | ||
| page | integer | false | 1 | Page number | |
| size | integer | false | 10 | Page size |
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_position_type | Position type incorrect |
| invalid_position_side | Position side incorrect |
| invalid_profit_close_type | Position close type incorrect |
| invalid_state | State incorrect |
| invalid_symbol | Invalid trading pair |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"entrustId": "",
"symbol": "",
"entrustType": "",
"orderSide": "",
"positionSide": "",
"timeInForce": "",
"closePosition": false,
"price": 0,
"origQty": 0,
"stopPrice": "",
"triggerPriceType": "",
"executedQty": 0,
"avgPrice": "",
"state": "",
"createdTime": "",
"updatedTime": "",
"clientOrderId": "",
"reverseOpenExecutedQty": 0,
"reverseOpenAvgPrice": 0,
"desc": ""
}
]
},
"returnCode": 0
}
Query Historical Reverse Plan Edit
/future/trade/v1/entrust/reverse-plan-list-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| page | integer | false | 1 | Page number | |
| size | integer | false | 10 | Page size | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| symbol | string | false | Trading pair |
Note: This API can only query data within the last 5 minutes.
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_position_type | Position type incorrect |
| invalid_position_side | Position side incorrect |
| invalid_profit_close_type | Position close type incorrect |
| invalid_state | State incorrect |
| invalid_symbol | Invalid trading pair |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"entrustId": "",
"symbol": "",
"entrustType": "",
"orderSide": "",
"positionSide": "",
"timeInForce": "",
"closePosition": false,
"price": 0,
"origQty": 0,
"stopPrice": "",
"triggerPriceType": "",
"executedQty": 0,
"avgPrice": "",
"state": "",
"createdTime": "",
"updatedTime": "",
"clientOrderId": "",
"reverseOpenExecutedQty": 0,
"reverseOpenAvgPrice": 0,
"desc": ""
}
]
},
"returnCode": 0
}
Query Historical Filled Orders Edit
/future/trade/v1/order/trade-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| limit | integer | false | 10 | Quantity (Max 500) | |
| startTime | integer | false | Start time (default: query data from 90 days ago) | ||
| endTime | integer | false | End time | ||
| symbol | string | true | Trading pair |
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Invalid trading pair |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"symbol": "BTCUSDT",
"orderSide": "BUY",
"avgPrice": "67234.50",
"origQty": "0.012",
"executedQty": "0.012",
"updatedTime": 1735698765000
}
],
"returnCode": 0
}
Query All Trade Details (No pagination) Edit
/future/trade/v1/order/trade-list-all
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| orderId | integer | false | Order ID | ||
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| symbol | string | false | Trading pair |
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_limit | Invalid limit parameter setting |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"orderId": "1876543210987654321",
"execId": "2876543210987654322",
"symbol": "BTCUSDT",
"contractSize": 0.001,
"quantity": "0.015",
"price": "67234.80",
"fee": "10.08522",
"couponDeductFee": "3.00000",
"bonusDeductFee": "2.00000",
"feeCoin": "USDT",
"timestamp": 1735698765432,
"takerMaker": "TAKER",
"orderSide": "BUY",
"positionSide": "LONG"
}
],
"returnCode": 0
}
Query All Orders Edit
/future/trade/v1/order-entrust/list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| page | integer | false | 1 | Page number | |
| size | integer | false | 10 | Page size | |
| startTime | long | false | Start time | ||
| endTime | long | false | End time | ||
| symbol | string | false | Trading pair | ||
| type | string | false | ORDER | Type of entrust order: ORDER (limit/market) or ENTRUST (plan order) | |
| state | string | false | Order state | NEW;PARTIALLY_FILLED;FILLED;CANCELED;REJECTED;PLACED;UNFINISHED;HISTORY | |
| forceClose | bool | false | false | Whether forced liquidation |
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_size | Invalid size parameter |
| invalid_page | Invalid page parameter |
| invalid_symbol | Invalid trading pair |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"page": 1,
"ps": 10,
"total": 99,
"items": [
{
"id": "1876543210987654321",
"type": "ORDER",
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"orderSide": "BUY",
"positionSide": "LONG",
"timeInForce": "GTC",
"closePosition": false,
"price": "67200.00",
"origQty": "0.015",
"avgPrice": "67234.50",
"executedQty": "0.015",
"marginFrozen": "50.42",
"leverage": 25,
"state": "FILLED",
"createdTime": 1735698000000,
"updatedTime": 1735698765000,
"positionType": "ISOLATED"
}
]
},
"returnCode": 0
}
Get Active Position Edit
/future/trade/v1/position/list/active
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair | ||
| isDelivery | bool | false | false | Whether to query delivery contract |
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Invalid trading pair |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"symbol": "BTCUSDT",
"positionType": "ISOLATED",
"positionSide": "LONG",
"contractType": "PERPETUAL",
"positionSize": "0.032",
"closeOrderSize": "0.008",
"availableCloseSize": "0.024",
"entryPrice": "66543.21",
"openOrderSize": "0.010",
"isolatedMargin": "106.47",
"openOrderMarginFrozen": "33.27",
"realizedProfit": "87.65",
"autoMargin": false,
"leverage": 25,
"contractSize": "0.001",
"markPrice": "67234.80",
"updatedTime": "1735701234567",
"welfareExpirationTime": 1767225599000,
"mmrProfitId": null,
"mmrThreshold": null
}
],
"returnCode": 0
}
Get Leverage Info Edit
/future/trade/v1/position/leverage/list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair |
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"symbol": "BTCUSDT",
"accountId": "",
"positionType": "ISOLATED",
"positionSide": "LONG",
"contractType": "PERPETUAL",
"leverage": 25
}
]
},
"returnCode": 0
}
Get Position History Edit
/future/trade/v1/position/list-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| id | integer | false | 1 | Page number | |
| direction | string | false | NEXT | Pagination direction | NEXT;PREVIOUS |
| limit | integer | false | 10 | Page size | |
| symbol | string | false | Trading pair | ||
| startTime | long | false | Start time | ||
| endTime | long | false | End time | ||
| positionType | integer | false | Position mode (1 Cross, 2 Isolated; empty = all) | ||
| isFullClose | integer | false | Close type (0 Partial, 1 Full; empty = all) |
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_direction | Direction incorrect |
| invalid_limit | Limit parameter incorrect |
| invalid_symbol | Trading pair does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"id": "1987654321098765432",
"positionSide": "LONG",
"contractType": "PERPETUAL",
"symbol": "BTCUSDT",
"positionType": 2,
"closeProfit": "127.83",
"closePositionSize": "0.050",
"closeOpenPrice": "63250.80",
"closePrice": "65808.60",
"maxPositionSize": "0.080",
"openTime": 1735608000000,
"closeTime": 1735699200000,
"startLeverage": 25,
"endLeverage": 25,
"working": false,
"force": false,
"forceMarkPrice": null,
"totalFee": "18.92",
"totalFundFee": "3.41",
"welfareAccount": false
}
]
},
"returnCode": 0
}
Get Cross Margin Edit
/future/trade/v1/position/cross-margin/{symbol}
The symbol is passed as a path parameter in the URL, e.g., /future/trade/v1/position/cross-margin/eth_usdt
Rate Limit
200/s/apikey
Error Codes
| Error Code | Description |
|---|---|
| invalid_symbol | Trading pair does not exist |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": "result",
"returnCode": 0
}
Get Account Related Information Edit
/future/user/v1/account/info
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"accountId": 0, // Account ID
"allowOpenPosition": false, // Is it possible to open position
"allowTrade": false, // Is it possible to trade
"allowTransfer": false, // Is it possible to transfer
"openTime": "", // Opening time
"state": 0, // User status
"userId": 0 // User ID
},
"returnCode": 0
}
Get Contract Account Assets Edit
/future/user/v1/compat/balance/list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| queryAccountId | string | false | Account ID |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"accountId": 500000000000, // account id
"userId": 500000000000, // user id
"coin": "usdt", // Currency
"underlyingType": 2, // Coin standard, u standard
"walletBalance": "2078.57264793", // Currency balance
"openOrderMarginFrozen": "0", // Order frozen
"isolatedMargin": "0", // Margin freeze
"crossedMargin": "0", // Full margin freeze
"amount": "2078.57264793", // Net asset balance
"totalAmount": "2078.57264793", // Margin balance
"convertBtcAmount": "0.03638940", // walletBalance conversion BTC
"convertUsdtAmount": "2078.5726", // walletBalance conversion USDT
"profit": "0", // Profit and loss
"notProfit": "0", // Unrealized profit/loss
"bonus": "0", // Trial fee
"coupon": "0" // Deduction
}
],
"returnCode": 0
}
Get ListenKey Edit
/future/user/v1/user/listen-key
Limit Flow Rules
200/s/apikey
Note: Valid time is 8 hours
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Open Contract Edit
/future/user/v1/account/open
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
Get User's Single Currency Fund Information Edit
/future/user/v1/balance/detail
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| coin | string | true | Currency eg:btc |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"availableBalance": 0, //Available balance
"coin": "", //Currency
"isolatedMargin": 0, //Frozen isolated margin
"openOrderMarginFrozen": 0, //Frozen order
"crossedMargin": 0, //Crossed Margin
"bonus": 0, //Bonus
"coupon": 0, //Coupon
"walletBalance": 0 //Balance
},
"returnCode": 0
}
Get User's Funds Information Edit
/future/user/v1/balance/list
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"availableBalance": 0, // Available balance
"coin": "", // Currency
"isolatedMargin": 0, // Frozen isolated margin
"openOrderMarginFrozen": 0, // Frozen order margin
"crossedMargin": 0, // Crossed margin
"bonus": 0, // Bonus
"coupon": 0, // Coupon
"walletBalance": 0 // Wallet balance
}
],
"returnCode": 0
}
Get User's Account Flow Information Edit
/future/user/v1/balance/bills
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pairs (queries all if not passed) | ||
| direction | string | false | NEXT | Direction (PREV: Previous page; NEXT: Next page) | PREV;NEXT |
| id | integer | false | Record ID | ||
| limit | integer | false | 10 | Limit | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false, // Is there a next page
"hasPrev": false, // Is there a previous page
"items": [
{
"afterAmount": 0, // Balance after change
"amount": 0, // Quantity
"coin": "", // Currency
"createdTime": 0, // Time
"id": 0, // ID
"side": "", // ADD: transfer in; SUB: transfer out
"symbol": "", // Trading pair
"type": "" // EXCHANGE: transfer; CLOSE_POSITION: Offset PnL; TAKE_OVER: position takeover; QIANG_PING_MANAGER: Liquidation management fee; FUND: Fund fee; FEE: Fee; ADL: Auto-deleveraging; MERGE: Position merge
}
]
},
"returnCode": 0
}
Get Fund Fee Information Edit
/future/user/v1/balance/funding-rate-list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair (queries all if not passed) | ||
| direction | string | false | NEXT | Direction (PREV: Previous page; NEXT: Next page) | PREV;NEXT |
| id | integer | false | Record ID | ||
| limit | integer | false | 10 | Limit | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false, // Is there a next page
"hasPrev": false, // Is there a previous page
"items": [
{
"cast": 0, // Fund fee
"coin": "", // Currency
"createdTime": 0, // Time
"id": 0, // ID
"positionSide": "", // Direction
"symbol": "" // Trading pair
}
]
},
"returnCode": 0
}
Get active position information Edit
/future/user/v1/position
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pairs (queries position information for all trading pairs when not provided) |
Limit Flow Rules
200/s/apikey
{
"error": {
"args": [],
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"autoMargin": false, // Whether to automatically call margin
"availableCloseSize": 0, // Available quantity (Cont)
"breakPrice": 0, // Blowout price
"calMarkPrice": 0, // Calculated mark price
"closeOrderSize": 0, // Quantity of open order (Cont)
"contractType": "", // Contract Types: PERPETUAL, PREDICT
"entryPrice": 0, // Average opening price
"floatingPL": 0, // Unrealized profit or loss
"isolatedMargin": 0, // Warehouse-by-warehouse margin
"leverage": 0, // Leverage ratio
"openOrderMarginFrozen": 0, // Occupation of deposit for opening order
"openOrderSize": 0, // Opening warehouse orders occupied
"positionSide": "", // Position direction
"positionSize": 0, // Position quantity (Cont)
"positionType": "", // Position type: CROSSED; ISOLATED
"profitId": 0, // Take profit and stop loss id
"realizedProfit": 0, // Realized profit and loss
"symbol": "", // Trading pair
"triggerPriceType": "", // Trigger price type
"triggerProfitPrice": 0, // Take profit trigger price
"triggerStopPrice": 0, // Stop loss trigger price
"welfareAccount": true
}
],
"returnCode": 0
}
Get Position Information Edit
/future/user/v1/position/list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair (queries position information for all trading pairs when not provided) |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"autoMargin": false, // Whether to automatically call margin
"availableCloseSize": 0, // Available quantity (Cont)
"closeOrderSize": 0, // Pending order quantity (Cont)
"entryPrice": 0, // Open position average price
"isolatedMargin": 0, // Isolated Margin
"leverage": 0, // Leverage
"openOrderMarginFrozen": 0, // Occupied open position margin
"positionSide": "", // Position side
"positionSize": 0, // Position quantity (Cont)
"positionType": "", // Position type
"realizedProfit": 0, // Realized profit and loss
"symbol": "" // Trading pair
}
],
"returnCode": 0
}
Get User's Step Rate Edit
/future/user/v1/user/step-rate
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "success",
"result": {
"specialType": false, // Is special account
"vipProType": true, // Is professional rate
"stepRateProName": "VIP_PRO_1", // Professional rate name
"discountLevel": 2, // Discount level
"makerFee": "0.0015", // Maker fee rate
"takerFee": "0.0025", // Taker fee rate
"levelReturnDay": 30, // Current level retention days
"totalTradeVolume": "1250000.50", // Trading volume in the past 29 days + today
"uBasedTotalTradeVolume": "850000.75", // USDT-margined trading volume
"coinBasedTotalTradeVolume": "400000.25", // Coin-margined trading volume
"walletBalance": "50000.00", // Account equity (USDT)
"notProfit": "1250.50", // Position unrealized profit and loss
"nextLvTradeVolume": "1500000.00", // Next level trading volume
"lackTradeVolume": "250000.50", // Trading volume needed for next level
"nextLvWalletBalance": "75000.00", // Next level wallet balance
"lackWalletBalance": "25000.00", // Wallet balance needed for next level
"nextLvMakerFee": "0.0010", // Next level maker fee rate
"nextLvTakerFee": "0.0020" // Next level taker fee rate
},
"returnCode": 0
}
Adjust Leverage Edit
/future/user/v1/position/adjust-leverage
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt | ||
| positionSide | string | true | Position side | LONG;SHORT | |
| leverage | integer | true | Leverage |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Alter Margin Edit
/future/user/v1/position/margin
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt | ||
| margin | number | false | Quantity | ||
| positionSide | string | false | Position side | LONG;SHORT | |
| type | string | false | Adjust direction (ADD: add isolated margin, SUB: reduce isolated margin) | ADD;SUB |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Alter the automatical margin call Edit
/future/user/v1/position/auto-margin
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt | ||
| positionSide | string | true | Position side | LONG;SHORT | |
| autoMargin | boolean | true | Whether to automatically call margin | true;false |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Close All Edit
/future/user/v1/position/close-all
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
Get ADL Information Edit
/future/user/v1/position/adl
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair (if not provided, query positions for all trading pairs) |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"longQuantile": 0, //long position adl
"shortQuantile": 0, //Short position adl
"symbol": "" //Trading pair
}
],
"returnCode": 0
}
Collect Trading Pair Edit
/future/user/v1/user/collection/add
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
Cancel Trading Pair Collection Edit
/future/user/v1/user/collection/cancel
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
List of Collected Trading Pairs Edit
/future/user/v1/user/collection/list
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [],
"returnCode": 0
}
Change Position Type Edit
/future/user/v1/position/change-type
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | true | Trading pair eg:btc_usdt | ||
| positionSide | string | true | Position side | LONG;SHORT | |
| positionType | string | true | Position type | CROSSED;ISOLATED |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
Get Margin Call Information Edit
/future/user/v1/position/break-list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| symbol | string | false | Trading pair (if not passed, queries liquidation info of all trading pairs) |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"breakPrice": 0, //Margin call price. 0 means no margin call
"calMarkPrice": 0, //Mark price
"contractType": "", //Futures type: PERPETUAL;PREDICT
"entryPrice": 0, //Open position average price
"isolatedMargin": 0, //Isolated Margin
"leverage": 0, //Leverage
"positionSide": "", //Position side:LONG;SHORT
"positionSize": 0, //Position quantity (Cont)
"positionType": "", //Position type:CROSSED;ISOLATED
"symbol": "" //Symbol
}
],
"returnCode": 0
}
Get Auto Deleverage History Edit
/future/user/v1/auto-deleverage/history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| id | integer | false | 1 | Page number | |
| direction | string | false | NEXT | Direction | NEXT;PREVIOUS |
| limit | integer | false | 10 | Page size | |
| startTime | integer | false | Start time (Default queries the last 90 days) | ||
| endTime | integer | false | End time | ||
| symbol | string | false | Trading pair |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"id": "2876543210987654321", // ADL record ID
"symbol": "BTCUSDT", // trading pair
"positionSide": "LONG", // LONG / SHORT
"quantity": "0.028", // ADL reduced quantity (contracts)
"price": "67234.50", // ADL execution price
"realizedProfit": "-87.60", // realized PnL from ADL
"createdTime": 1735698765432, // ADL timestamp (ms)
"welfareAccount": false, // welfare account indicator
"uid": 10086, // user UID
"accountId": 900123456789 // account ID
}
]
},
"returnCode": 0
}
Get Single Coin Balance Edit
/future/user/v1/compat/balance/{coin}
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| coin | string | true | Currency (path parameter) eg:usdt |
Limit Flow Rules
200/s/apikey
{
"rc": 0,
"mc": "",
"ma": "",
"result": {
"accountId": 900123456789,
"userId": 10086,
"coin": "USDT",
"underlyingType": 2,
"walletBalance": "15234.87654321",
"openOrderMarginFrozen": "800.00000000",
"isolatedMargin": "2150.50000000",
"crossedMargin": "4300.00000000",
"amount": "8434.37654321",
"totalAmount": "12734.87654321",
"convertBtcAmount": "0.22681500",
"convertUsdtAmount": "15234.88",
"profit": "1250.45",
"notProfit": "-500.00",
"bonus": "1000.00000000",
"coupon": "300.00000000",
"depositCoupon": "5000.00000000",
"marginBalance": "13234.87654321",
"openOrderFeeFrozen": "15.88"
}
}
Get Taker Over List Edit
/future/user/v1/taker-over/list
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| id | integer | false | 1 | Page number | |
| direction | string | false | NEXT | Direction | NEXT;PREVIOUS |
| limit | integer | false | 10 | Page size | |
| startTime | integer | false | Start time | ||
| endTime | integer | false | End time | ||
| symbol | string | false | Trading pair |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"requestId": 9876543210987654321,
"tenantId": 10001,
"accountId": 900123456789,
"userId": 55667788,
"userGroupId": 3001,
"symbolId": 1,
"symbolGroupId": 10,
"positionType": 2,
"positionSide": 1,
"riskAccountId": 900123456789,
"riskUserId": 55667788,
"riskUserGroupId": 3001,
"success": true,
"positionSize": "0.05200000",
"entryPrice": "6325080000",
"balance": "1523487654321",
"symbol": "BTCUSDT",
"markPrice": "6712345000000",
"marginRate": "01250000",
"createdTime": 1735701234567
}
]
},
"returnCode": 0
}
Get Profit List History Edit
/future/trade/v1/entrust/profit-list-history
Parameters
| Parameter | Type | mandatory | Default | Description | Ranges |
|---|---|---|---|---|---|
| id | integer | false | 1 | Page number | |
| limit | integer | false | 10 | Page size | |
| startTime | integer | false | Start time (Default query 90 days ago) | ||
| endTime | integer | false | End time | ||
| symbol | string | false | Trading pair | ||
| direction | string | false | NEXT | Direction | NEXT;PREVIOUS |
Limit Flow Rules
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"profitId": "" // Entrust ID (Long to string)
}
]
},
"returnCode": 0
}
General WSS Information Edit
Base URL: wss://fstream.wexex.io/ws/market (Public channels; no listenKey required)
Request Headers
Sec-Websocket-Extensions: permessage-deflate
Subscription Steps
- Establish a WebSocket connection.
- Subscribe to a public channel event by sending:
{"method":"SUBSCRIBE","params":["{topic}@{symbol}"],"id":"{id}"}
Push Message Format
{"topic":"topic","event":"{topic}@{symbol}","data":{}}
Heartbeat: Each client must periodically send a text ping. Server replies pong. If no ping within 30 seconds, the connection is closed.
Error Codes
| Error Code | Description |
|---|---|
| 400 | Bad request payload. Please check it. |
{
"method": "SUBSCRIBE",
"params": [
"{topic1}@{arg1},{arg2}",
"{topic2}@{arg}"
],
"id": "id_field_could_call_whatever_you_want"
}
{
"id": "{id}",
"code": 0,
"msg": ""
}
Orderbook Management Edit
How to maintain a local order book correctly
- Connect to
wss://fstream.wexex.io/ws/market, subscribe todepth_update@btc_usdt. - Buffer events received from the stream.
- Fetch a depth snapshot:
https://fapi.wexex.io/future/market/v1/public/depth?symbol=btc_usdt&level=500. - Discard any event where
u <= lastUpdateIdin the snapshot. - The first processed event should satisfy
fu <= lastUpdateId + 1andu >= lastUpdateId + 1. - While listening, each new event’s
fushould equal the previous event’su + 1. - The data in each event represents the absolute quantity at each price level.
- If a quantity is
0, remove that price level. - Receiving deletion events for a local price level that does not exist may occur and is normal.
Notes: Due to the limited number of price levels in the depth snapshot, levels with no changes after the initial snapshot will not appear in the incremental depth stream. For most use cases, a 500-level depth limit is sufficient.
Trade Record Edit
Request format: trade@{symbol}
Example: trade@btc_usdt
Push rate: real-time
{
"method": "SUBSCRIBE",
"params": ["trade@btc_usdt"],
"id": "test"
}
{
"topic": "trade",
"event": "trade@btc_usdt",
"data": {
"s": "btc_usdt",
"p": "50000",
"a": "0.1",
"m": "BID",
"t": 123124124
}
}
K-line Edit
Request format: kline@{symbol},{interval}
Intervals: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
Example: kline@btc_usdt,5m
Push rate: 1000ms
{
"method": "SUBSCRIBE",
"params": ["kline@btc_usdt,5m"],
"id": "test"
}
{
"topic": "kline",
"event": "kline@btc_usdt,5m",
"data": {
"s": "btc_index",
"o": "49000",
"c": "50000",
"h": "0.1",
"l": "0.1",
"a": "0.1",
"v": "0.1",
"ch": "0.21",
"t": 123124124
}
}
Agg Ticker Edit
Request format: agg_ticker@{symbol}
Example: agg_ticker@btc_usdt
Push rate: 1000ms
{
"method": "SUBSCRIBE",
"params": ["agg_ticker@btc_usdt"],
"id": "test"
}
{
"topic": "agg_ticker",
"event": "agg_ticker@btc_usdt",
"data": {
"s": "btc_index",
"o": "49000",
"c": "50000",
"h": "0.1",
"l": "0.1",
"a": "0.1",
"v": "0.1",
"ch": "0.21",
"i": "0.21",
"m": "0.21",
"bp": "0.21",
"ap": "0.21",
"t": 123124124
}
}
Index Price Edit
Request format: index_price@{symbol}
Example: index_price@btc_usdt
Push rate: 1000ms
{
"method": "SUBSCRIBE",
"params": ["index_price@btc_usdt"],
"id": "test"
}
{
"topic": "index_price",
"event": "index_price@btc_usdt",
"data": {
"s": "btc_usdt",
"p": "50000",
"t": 123124124
}
}
Mark Price Edit
Request format: mark_price@{symbol}
Example: mark_price@btc_usdt
Push rate: 1000ms
{
"method": "SUBSCRIBE",
"params": ["mark_price@btc_usdt"],
"id": "test"
}
{
"topic": "mark_price",
"event": "mark_price@btc_usdt",
"data": {
"s": "btc_usdt",
"p": "50000",
"t": 123124124
}
}
Incremental Depth Edit
Request format: depth_update@{symbol},{interval}
Interval options: 100, 250, 500, 1000 (default: 100ms)
Example: depth_update@btc_usdt,100ms
{
"method": "SUBSCRIBE",
"params": ["depth_update@btc_usdt,100ms"],
"id": "test"
}
{
"topic": "depth_update",
"event": "depth_update@btc_usdt",
"data": {
"s": "btc_usdt",
"pu": 120,
"fu": 121,
"u": 123,
"a": [
["34000", "1.2"],
["34001", "2.3"]
],
"b": [
["32000", "0.2"],
["31000", "0.5"]
],
"t": 123456789
}
}
Limited Depth Edit
Request format: depth@{symbol},{levels},{interval}
Levels: 5, 10, 20, 50
Interval options: 100, 250, 500, 1000 (default: 1000ms)
Example: depth@btc_usdt,50,1000ms
{
"method": "SUBSCRIBE",
"params": ["depth@btc_usdt,50,1000ms"],
"id": "test"
}
{
"topic": "depth",
"event": "depth@btc_usdt,20",
"data": {
"id": "1234",
"s": "btc_index",
"a": [
["50000", "0.1"],
["50001", "0.2"]
],
"b": [
["49999", "0.1"],
["48888", "0.2"]
],
"t": 123456789
}
}
Fund Rate Edit
Request format: fund_rate@{symbol}
Example: fund_rate@btc_usdt
Push rate: 60s
{
"method": "SUBSCRIBE",
"params": ["fund_rate@btc_usdt"],
"id": "test"
}
{
"topic": "fund_rate",
"event": "fund_rate@btc_usdt",
"data": {
"s": "btc_usdt",
"r": "0.01",
"t": 123124124
}
}
General WSS Information Edit
WebSocket Base URL: wss://fstream.wexex.io/ws/user (User private channel)
Request Headers
When initiating the WebSocket upgrade request, enable per-message compression:
Sec-Websocket-Extensions: permessage-deflate
Subscription Steps
- Call the API to obtain a ListenKey:
GET https://fapi.wexex.io/future/user/v1/user/listen-key - After WebSocket connection is established, subscribe to user events:
Available Topics: order, trade, balance, position, notify
Heartbeat: Each client must periodically send a text ping message. Server replies with pong. If no ping is received within 30 seconds, the server closes the connection.
Error Codes
| Error Code | Description |
|---|---|
| {topic}@invalid_listenkey | ListenKey expired or invalid. Please request again. |
| Invalid Parameter | Invalid parameters. Please check the JSON string. |
{
"id": "{id}",
"code": 0,
"msg": "success"
}
Balance Change Edit
Topic: balance
Subscribe to balance change events for the user account.
{
"topic": "balance",
"event": "balance@123456",
"data": {
"coin": "usdt",
"underlyingType": 1,
"walletBalance": "123",
"openOrderMarginFrozen": "123",
"isolatedMargin": "213",
"crossedMargin": "0"
}
}
Change Position Edit
Topic: position
Subscribe to position change events for the user account.
{
"topic": "position",
"event": "position@123456",
"data": {
"symbol": "btc_usdt",
"contractType": "PERPUTUAL",
"positionType": "ISOLATED",
"positionSide": "LONG",
"positionSize": "123",
"closeOrderSize": "100",
"availableCloseSize": "23",
"realizedProfit": "123",
"entryPrice": "213",
"isolatedMargin": "213",
"openOrderMarginFrozen": "123",
"underlyingType": "",
"leverage": 20
}
}
Transactions Edit
Topic: trade
Subscribe to user trade/transaction events.
{
"topic": "trade",
"event": "trade@123456",
"data": {
"orderId": "12312312",
"clientOrderId": "123456",
"price": "34244",
"quantity": "123",
"marginUnfrozen": "123",
"timestamp": 1731231231,
"symbol": "btc_usdt",
"orderSide": "BUY",
"positionSide": "LONG",
"isMaker": true,
"fee": 0.0002
}
}
User Order Edit
Topic: order
Subscribe to user order events. Pushed when order state changes.
{
"topic": "order",
"event": "order@123456",
"data": {
"symbol": "btc_usdt",
"orderId": "1234",
"origQty": "34244",
"avgPrice": "123",
"price": "1111",
"executedQty": "34244",
"orderSide": "BUY",
"timeInForce": "IOC",
"positionSide": "LONG",
"marginFrozen": "123",
"sourceType": "default",
"type": "ORDER",
"state": "FILLED",
"createdTime": 1731231231,
"leverage": 20,
"positionType": "ISOLATED",
"orderType": "MARKET"
}
}
Message (Notifications) Edit
Topic: notify
Subscribe to system notification events (liquidation warnings, ADL, etc.).
notifyType values: WARN (warning, about to be liquidated), PARTIAL (partial liquidation), LIQUIDATION (forced liquidation), ADL (auto-deleveraging)
{
"topic": "notify",
"event": "notify",
"data": {
"symbol": "btc_usdt",
"positionType": "ISOLATED",
"positionSide": "LONG",
"positionSize": "123",
"notifyType": "WARN"
}
}
接口基础信息 Edit
基础地址
- USDT-M:
https://fapi.wexex.io(适用于 U 本位合约) - Coin-M:
https://dapi.wexex.io(适用于币本位合约)
网络建议
由于高延迟和稳定性差的原因,不建议通过代理访问 WEX API。
请求方式
- GET 请求: 参数放在 QueryString 中。
- POST 请求: 参数可以放在 RequestBody 或 QueryString 中。
当参数放在 QueryString 中时,必须在 HTTP Header 中添加:Content-Type: application/x-www-form-urlencoded
当参数放在 RequestBody 中时,必须在 HTTP Header 中添加:Content-Type: application/json
接口分类
WEX API 接口分为 公共接口 和 用户接口。
公共接口 - 无需身份认证。参数直接放入 QueryString 中。通常使用 GET 方法。
用户接口 - 需要在 Header 中传入认证参数。除了 QueryString 或 RequestBody 参数外,至少需要以下四个 Header:
| Header | 说明 |
|---|---|
validate-appkey |
用户公钥 |
validate-timestamp |
当前时间戳(毫秒) |
validate-signature |
请求签名 |
Content-Type |
请求类型 |
不需要签名的接口将在文档中额外说明。
认证说明
- 如何获取 APPKEY: 请参阅”申请 API Key”章节。
- 如何获取签名: 请参阅”获取签名”章节。
限流规则
- 资产类接口: 每秒最多 3 次请求。
- 其他接口: 单个用户每秒最多 10 次请求,单个 IP 每分钟最多 1000 次。
超过限制后账户将被锁定 10 分钟。
签名说明 Edit
签名参数说明
由于 WEX 为第三方平台提供开放接口,必须确保数据安全——例如防止数据篡改、避免过时数据、阻止重复提交以及控制请求频率。其中,验证数据是否被篡改 是最关键的。
签名参数
- validate-appkey — 为申请 API Key 后获取的公钥
- validate-timestamp — 为请求时间的毫秒级时间戳(Unix 时间戳),请求的有效性基于此值和
validate-recvwindow计算 - validate-signature — 部分接口请求数据须签名,签名规则见”获取签名”章节
- validate-recvwindow — 该次请求的有效期由 recvwindow 确定。默认为 5 秒,最大 60 秒。如果时间戳比服务器时间早 5000ms 以上,请求无效。如果客户端时间戳比服务器提前 1 秒以上,请求也会被拒绝。RecvWindow 不建议超过 5 秒。
- validate-algorithms — 签名使用基于 HSC 的协议计算。默认:HmacSHA256。支持:HmacMD5、HmacSHA1、HmacSHA224、HmacSHA256、HmacSHA384、HmacSHA512
请求头签名相关参数列表
| 名称 | 必填 | 示例 | 描述 |
|---|---|---|---|
| validate-appkey | TRUE | dbefbc809e3e83c283a984c3a1459732ea7db1360ca80c5c2c8867408d28cc83 | 公钥 |
| validate-timestamp | TRUE | 1641446237201 | Unix 时间戳(毫秒) |
| validate-signature | TRUE | 0a7d0b5e802eb5e52ac0cfcd6311b0faba6e2503a9a8d1e2364b38617877574d | 生成的签名 |
| validate-recvwindow | FALSE | 5000(毫秒) | 有效性时间窗口 |
| validate-algorithms | FALSE | HmacSHA256 | 默认 HmacSHA256 |
| api-version | FALSE | 1 | 保留字段,API 版本号 |
| validate-signversion | FALSE | 1 | 保留字段,签名版本 |
获取签名 Edit
获取签名
注:${?} 、$? 表示对变量 ? 的引用。
要生成签名 signature,需要利用申请 API Key 获取的 SECRET KEY 对 unencrypted_string 进行加密。
规则说明
-
若 HTTP 请求参数放在 QueryString 中: 则
unencrypted_string = ${fixed_header}#${end_point}#${query_string}当query_string有多个键值对时,需按键名 字典序排序 并以&连接,例如:keya=value&keyb=value&keyc=value -
若 HTTP 请求参数放在 RequestBody 中: 则
unencrypted_string = ${fixed_header}#${end_point}#${request_body}
fixed_header 规则
fixed_header = "validate-appkey=${your_appkey}&validate-timestamp=${current_timestamp}"
unencrypted_string 的每个部分由 # 符号连接。
举例说明
当前时间戳为 ***** ,你的 APPKEY 为 ++++++
fixed_header="validate-appkey=++++++&validate-timestamp=*****"
end_point="/future/user/v1/balance/detail"
query_string="coin=btc"
则:unencrypted_string="validate-appkey=++++++&validate-timestamp=*****#/future/user/v1/balance/detail#coin=btc"
生成签名
获取 unencrypted_string 后,可用加密算法与 SECRETKEY 将 unencrypted_string 获取签名 SIGNATURE。
获取该签名后,将 SIGNATURE 填入 HTTP 请求头中的 validate-signature 字段。
如何申请 API Key Edit
部分接口需要用户的 API Key。申请 API Key 后会获取一对密钥,用于传入 HTTP 请求头的 APPKEY 和用于获取签名的 SECRETKEY。请在 WEX 网站或 App 的用户中心创建 API Key。
错误码 Edit
| HTTP 返回码 | 响应类型 | 说明 |
|---|---|---|
| 200 | OK | 成功调用接口(接口功能调用不一定成功) |
| 400 | BAD_REQUEST | 请求 URL 包含黑名单关键词,或缺少 validate-appkey / validate-timestamp 请求头 |
| 403 | FORBIDDEN | Host 不符合规则、租户未启用、时间窗口超限、请求 IP 不在白名单内、签名验证失败、AppKey 无权限 |
| 405 | METHOD_NOT_ALLOWED | Host 头为 null |
| 429 | TOO_MANY_REQUESTS | 触发限流规则 |
| 500 | INTERNAL_SERVER_ERROR | 客户端 IP 为空、获取不到域名或租户域名信息 |
| 502 | BAD_GATEWAY | 未知异常 |
| 503 | SERVICE_UNAVAILABLE | 下游服务不存在或不可用 |
更新日志 Edit
新增接口清单(2025-12-05)
本次更新共新增 14 个接口,涵盖 Biz-order 与 Biz-user 两大模块。
Biz-order:
| 序号 | 接口名称 | 请求类型 | 路径 |
|---|---|---|---|
| 1 | 查询计划反手 | GET | /future/trade/v1/entrust/reverse-plan-list |
| 2 | 查询历史计划反手 | GET | /future/trade/v1/entrust/reverse-plan-list-history |
| 3 | 查询历史止盈止损委托 | GET | /future/trade/v1/entrust/profit-list-history |
| 4 | 查询有成交的历史订单 | GET | /future/trade/v1/order/trade-history |
| 5 | 查询不分页的成交明细 | GET | /future/trade/v1/order/trade-list-all |
| 6 | 查询全部委托 | GET | /future/trade/v1/order-entrust/list |
| 7 | 获取当前持仓信息 | GET | /future/trade/v1/position/list/active |
| 8 | 获取杠杆信息 | GET | /future/trade/v1/position/leverage/list |
| 9 | 查询历史仓位 | GET | /future/trade/v1/position/list-history |
| 10 | 查询全仓维持保证金 | GET | /future/trade/v1/position/cross-margin/{symbol} |
Biz-user:
| 序号 | 接口名称 | 请求类型 | 路径 |
|---|---|---|---|
| 11 | 查询自动减仓历史 | GET | /future/user/v1/auto-deleverage/history |
| 12 | 查询单币种资产 | GET | /future/user/v1/compat/balance/{coin} |
| 13 | 查询接管记录 | GET | /future/user/v1/taker-over/list |
| 14 | 查询历史止盈止损委托 | GET | /future/trade/v1/entrust/profit-list-history |
2025-11-05
优化文档结构,补充了请求示例(curl)。保留原有参数与响应说明,无业务逻辑变更。
2025-11-04
结构调整 - 修改了大部分子项的名称,统一命名风格。删除订阅参数页面。将部分子项移动到通用 WebSocket 信息。
2025-11-03
信息架构 - 删除子模块:频率限制规则、API 库、返回格式。新增子模块:更新日志。子模块重命名:错误码 → 通用错误码。
获取客户端IP Edit
/future/public/client
此方法不需要签名。
{
"returnCode": 0,
"msgInfo": "success",
"error": null,
"result": {
"ip": "192.168.1.1"
}
}
获取交易对币种 Edit
/future/market/v1/public/symbol/coins
此方法不需要签名。
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [],
"returnCode": 0
}
获取单个交易对的配置信息 Edit
/future/market/v1/public/symbol/detail
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt |
此方法不需要签名。
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"baseCoin": "", // 基础资产
"baseCoinDisplayPrecision": 0, // 显示的基础币种精度
"baseCoinPrecision": 0, // 基础币种精度
"cnDesc": "", // 合约中文描述
"cnName": "", // 合约中文名称
"cnRemark": "", // 合约中文备注
"contractSize": 0, // 合约乘数(面值)
"contractType": "", // 合约类型,永续、交割
"deliveryCompletion": false, // 是否完成交割
"deliveryDate": 0, // 交割时间
"deliveryPrice": 0, // 交割价格
"depthPrecisionMerge": 0, // 盘口精度合并
"enDesc": "", // 合约英文描述
"enName": "", // 合约英文名称
"enRemark": "", // 合约备注(英文)
"initLeverage": 0, // 初始杠杆
"initPositionType": "", // 初始仓位类型
"isDisplay": false, // 是否显示
"isOpenApi": false, // 是否支持OpenApi
"labels": [], // 标签
"liquidationFee": 0, // 强制平仓费用
"makerFee": 0, // Maker费率
"marketTakeBound": 0, // 市价单最大价格偏差
"maxEntrusts": 0, // 最大活跃订单数
"maxNotional": 0, // 最大名义价值
"maxOpenOrders": 0, // 最大未成交订单数
"maxPrice": 0, // 最高价格
"minNotional": 0, // 最小名义价值
"minPrice": 0, // 最低价格
"minQty": 0, // 最小数量
"minStepPrice": 0, // 最小价格变动单位
"multiplierDown": 0, // 卖单限价下限百分比
"multiplierUp": 0, // 买单限价上限百分比
"onboardDate": 0, // 上市时间
"pair": "", // 目标交易对
"plates": [],
"predictEventParam": "", // 事件相关参数
"predictEventSort": "", // 事件相关排序
"predictEventType": "", // 预测事件类型
"pricePrecision": 0, // 价格精度
"productType": "", // 合约类型
"quantityPrecision": 0, // 数量精度
"quoteCoin": "", // 报价币种
"quoteCoinDisplayPrecision": 0,
"quoteCoinPrecision": 0,
"state": 0,
"supportEntrustType": "",
"supportOrderType": "",
"supportPositionType": "",
"supportTimeInForce": "",
"symbol": "",
"symbolGroupId": 0,
"takerFee": 0,
"tradeSwitch": false,
"underlyingType": ""
},
"returnCode": 0
}
获取已上市且可交易合约的配置信息 Edit
/future/market/v3/public/symbol/list
此方法不需要签名。
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"baseCoin": "", // 基础资产
"baseCoinDisplayPrecision": 0, // 显示的基础币种精度
"cnDesc": "", // 合约描述
"cnName": "", // 合约名称
"cnRemark": "", // 合约备注
"contractSize": 0, // 合约乘数(面值)
"contractType": "", // 合约类型,永续、交割
"deliveryCompletion": false,
"deliveryDate": 0,
"deliveryPrice": 0,
"depthPrecisionMerge": 0,
"enDesc": "",
"enName": "",
"enRemark": "",
"initLeverage": 0,
"initPositionType": "",
"isDisplay": false,
"isOpenApi": false,
"labels": [],
"liquidationFee": 0,
"makerFee": 0,
"marketTakeBound": 0,
"maxEntrusts": 0,
"maxNotional": 0,
"maxOpenOrders": 0,
"maxPrice": 0,
"minNotional": 0,
"minPrice": 0,
"minQty": 0,
"minStepPrice": 0,
"multiplierDown": 0,
"multiplierUp": 0,
"onboardDate": 0,
"pair": "",
"plates": [],
"predictEventParam": "",
"predictEventSort": "",
"predictEventType": "",
"pricePrecision": 0,
"productType": "",
"quantityPrecision": 0, // 已弃用
"quoteCoin": "",
"quoteCoinDisplayPrecision": 0,
"quoteCoinPrecision": 0,
"baseCoinPrecision": 0,
"state": 0,
"supportEntrustType": "",
"supportOrderType": "",
"supportPositionType": "",
"supportTimeInForce": "",
"offTime": "", // 合约计划下架时间
"symbol": "",
"symbolGroupId": 0,
"takerFee": 0,
"tradeSwitch": false,
"underlyingType": ""
}
],
"returnCode": 0
}
查看单个交易对的杠杆分层 Edit
/future/market/v1/public/leverage/bracket/detail
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:eth_usdt |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"leverageBrackets": [
{
"bracket": 0, // 层级
"maintMarginRate": 0, // 维持保证金率
"maxLeverage": 0, // 最大杠杆
"maxNominalValue": 0, // 最大名义价值
"maxStartMarginRate": 0, // 最大初始保证金率
"minLeverage": 0, // 最小杠杆
"startMarginRate": 0, // 初始保证金率
"symbol": "" // 交易对
}
],
"symbol": ""
},
"returnCode": 0
}
获取指定交易对的行情信息 Edit
/future/market/v1/public/q/ticker
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:eth_usdt |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"a": "", // 24小时成交额
"c": "", // 最新价
"h": "", // 24小时最高价
"l": "", // 24小时最低价
"o": "", // 24小时前第一笔成交价
"r": "", // 24小时价格涨跌幅
"s": "", // 交易对
"t": 0, // 时间
"v": "" // 24小时成交量
},
"returnCode": 0
}
获取所有交易对的行情信息 Edit
/future/market/v1/public/q/tickers
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"a": "", // 24小时成交额
"c": "", // 最新价
"h": "", // 24小时最高价
"l": "", // 24小时最低价
"o": "", // 24小时前第一笔成交价
"r": "", // 24小时价格涨跌幅
"s": "", // 交易对
"t": 0, // 时间
"v": "" // 24小时成交量
}
],
"returnCode": 0
}
获取交易对最新成交信息 Edit
/future/market/v1/public/q/deal
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt | ||
| num | integer | false | 50 | 数量 |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"a": 0, // 成交量
"m": "", // 订单方向
"p": 0, // 价格
"s": "", // 交易对
"t": 0 // 时间
}
],
"returnCode": 0
}
获取交易对深度数据 Edit
/future/market/v1/public/q/depth
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt | ||
| level | integer | true | 档位(最小:1,最大:50) | 1~50 |
限流规则
10次/秒/IP
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"a": [], // 卖单
"b": [], // 买单
"s": "", // 交易对
"t": 0, // 时间
"u": 0 // 更新ID
},
"returnCode": 0
}
获取单个交易对的指数价格 Edit
/future/market/v1/public/q/symbol-index-price
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"p": 0, // 价格
"s": "", // 交易对
"t": 0 // 时间
},
"returnCode": 0
}
获取所有交易对的指数价格 Edit
/future/market/v1/public/q/index-price
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"p": 0, // 价格
"s": "", // 交易对
"t": 0 // 时间
}
],
"returnCode": 0
}
获取单个交易对的标记价格 Edit
/future/market/v1/public/q/symbol-mark-price
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"p": 0, // 价格
"s": "", // 交易对
"t": 0 // 时间
},
"returnCode": 0
}
获取所有交易对的标记价格 Edit
/future/market/v1/public/q/mark-price
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"p": 0, // 价格
"s": "", // 交易对
"t": 0 // 时间
}
],
"returnCode": 0
}
获取交易对K线信息 Edit
/future/market/v1/public/q/kline
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:eth_usdt | ||
| interval | string | true | 时间间隔 | 1m;5m;15m;30m;1h;4h;1d;1w | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| limit | integer | false | 限制数量 | 1~1500 |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"a": 0, // 成交量
"c": 0, // 收盘价
"h": 0, // 最高价
"l": 0, // 最低价
"o": 0, // 开盘价
"s": "", // 交易对
"t": 0, // 时间
"v": 0 // 成交额
}
],
"returnCode": 0
}
获取指定交易对的聚合行情信息 Edit
/future/market/v1/public/q/agg-ticker
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:eth_usdt |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"a": "", // 24小时成交额
"ap": "", // 卖一价
"bp": "", // 买一价
"c": "", // 最新价
"h": "", // 24小时最高价
"i": "", // 指数价格
"l": "", // 24小时最低价
"m": "", // 标记价格
"o": "", // 24小时前第一笔成交价
"r": "", // 24小时价格涨跌幅
"s": "", // 交易对
"t": 0, // 时间
"v": "" // 24小时成交量
},
"returnCode": 0
}
获取所有交易对的聚合行情信息 Edit
/future/market/v1/public/q/agg-tickers
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"a": "", // 24小时成交额
"ap": "", // 卖一价
"bp": "", // 买一价
"c": "", // 最新价
"h": "", // 24小时最高价
"i": "", // 指数价格
"l": "", // 24小时最低价
"m": "", // 标记价格
"o": "", // 24小时前第一笔成交价
"r": "", // 24小时价格涨跌幅
"s": "", // 交易对
"t": 0, // 时间
"v": "" // 24小时成交量
}
],
"returnCode": 0
}
获取资金费率信息 Edit
/future/market/v1/public/q/funding-rate
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:eth_usdt |
限流规则
1次/秒/IP
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"hasNext": false, // 是否有下一页
"hasPrev": false, // 是否有上一页
"items": [
{
"collectionInternal": 0, // 结算周期(小时)
"createdTime": 0, // 时间
"fundingRate": 0, // 最新资金费率
"id": 0, // id
"symbol": "" // 交易对
}
]
},
"returnCode": 0
}
获取资金费率记录 Edit
/future/market/v1/public/q/funding-rate-record
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 | ||
| direction | string | false | NEXT | 方向(PREV:上一页;NEXT:下一页) | PREV;NEXT |
| id | integer | false | id | ||
| limit | integer | false | 10 | 限制条数 |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"hasNext": false, // 是否有下一页
"hasPrev": false, // 是否有上一页
"items": [
{
"collectionInternal": 0, // 收费周期(秒)
"createdTime": 0, // 时间
"fundingRate": 0, // 最新资金费率
"id": 0, // id
"symbol": "" // 交易对
}
]
},
"returnCode": 0
}
获取指定交易对的买卖盘行情信息 Edit
/future/market/v1/public/q/ticker/book
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:eth_usdt |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"ap": "", // 卖一价
"aq": "", // 卖一量
"bp": "", // 买一价
"bq": "", // 买一量
"s": "", // 交易对
"t": 0 // 时间
},
"returnCode": 0
}
获取所有交易对的买卖盘行情信息 Edit
/future/market/v1/public/q/ticker/books
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"ap": "", // 卖一价
"aq": "", // 卖一量
"bp": "", // 买一价
"bq": "", // 买一量
"s": "", // 交易对
"t": 0 // 时间
}
],
"returnCode": 0
}
获取交易对风险基金余额 Edit
/future/market/v1/public/contract/risk-balance
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:eth_usdt | ||
| direction | string | false | NEXT | 方向(PREV:上一页;NEXT:下一页) | PREV;NEXT |
| id | integer | false | id | ||
| limit | integer | false | 10 | 限制数量 |
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"hasNext": false, // 是否有下一页
"hasPrev": false, // 是否有上一页
"items": [
{
"amount": 0, // 余额
"coin": "", // 币种
"createdTime": 0, // 时间
"id": 0 // id
}
]
},
"returnCode": 0
}
获取交易对的持仓量 Edit
/future/market/v1/public/contract/open-interest
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:eth_usdt |
限流规则
1次/秒/IP
此方法不需要签名。
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"symbol": "", // 交易对
"openInterest": "", // 持仓量
"openInterestUsd": 0, // 持仓价值
"time": "" // 时间
},
"returnCode": 0
}
创建订单 Edit
/future/trade/v1/order/create
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| clientOrderId | string | false | 客户订单 ID | ||
| symbol | string | true | 交易对 | ||
| orderSide | string | true | 订单方向 | BUY;SELL | |
| orderType | string | true | 订单类型 | LIMIT;MARKET | |
| origQty | number | true | 数量(张) | ||
| price | number | false | 价格 | ||
| timeInForce | string | false | GTC | 有效方式 | GTC;IOC;FOK;GTX |
| triggerProfitPrice | number | false | 止盈价格 | ||
| triggerStopPrice | number | false | 止损价格 | ||
| positionSide | string | true | 仓位方向 | LONG;SHORT |
OrigQty 计算公式
origQty = Truncate((Balance * Percent * Leverage) / (Mark_price * Contract_size))
- Truncate:取整数部分
- Balance:
(walletBalance - openOrderMarginFrozen),API:/future/user/v1/compat/balance/list - Percent:用户输入,例如:
0.2 - Leverage:杠杆倍数,例如:
20 - Mark_price:市场标记价格,例如:
88888(btc_usdt) - Contract_size:合约面值,API:
/future/market/v1/public/symbol/detail
举例:truncate(10000 * 0.2 * 20 / 88888 / 0.0001) = 4500
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| contract_not_open | 合约未开户 |
| exist_bonus_positon_not_create_reverse_position | 无法创建反向仓位 |
| account_error | 账户无体验金权限 |
| symbol_is_not_open_position | 交易对未开市 |
| invalid_params | 参数填写错误 |
| invalid_quantity_scale | origQty 必须是整数 |
| coupon_unavailable | 优惠券不可用 |
| welfare_coupon_not_exist | 优惠券不存在 |
| coupon_exceed_max_leverage | 优惠券超过最大杠杆 |
| exceed_max_leverage | 超过最大杠杆 |
| gateway_decommission_ip_country | 很遗憾,我们无法向受限制国家/地区的用户提供服务 |
| gateway_decommission_kyc_country | 很遗憾,我们无法向受限制国家/地区的用户提供服务 |
| GATEWAY_0003 | 当前用户触发风控,您的操作已被暂时禁止 |
| GATEWAY_0006 | 由于您触发风控规则,账户被锁定 |
| GATEWAY_0007 | 由于您触发风控规则,账户被锁定 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
更新订单 Edit
/future/trade/v1/order/update
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | number | true | 订单 ID | ||
| price | number | true | 目标价格 | ||
| origQty | number | true | 目标数量(张) | ||
| triggerProfitPrice | number | false | 止盈目标价格 | ||
| triggerStopPrice | number | false | 止损价格 | ||
| triggerPriceType | string | false | LATEST_PRICE | 触发价格类型 | INDEX_PRICE; MARK_PRICE; LATEST_PRICE |
| profitDelegateOrderType | string | false | 止盈订单类型 | LIMIT; MARKET | |
| profitDelegateTimeInForce | string | false | 止盈订单有效方式 | GTC; IOC; FOK; GTX | |
| profitDelegatePrice | number | false | 止盈订单价格 | ||
| stopDelegateOrderType | string | false | 止损订单类型 | LIMIT; MARKET | |
| stopDelegateTimeInForce | string | false | 止损订单有效方式 | GTC; IOC; FOK; GTX | |
| stopDelegatePrice | number | false | 止损订单价格 | ||
| followUpOrder | boolean | false | 如果为 true,表示追单 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_order | Order id 不存在 |
| invalid_params | 参数设置有误 |
| invalid_quantity | origQty必须为整数 |
| invalid_price | price设置不合法 |
| invalid_trigger_profit_price | 止盈价格设置不合法 |
| invalid_trigger_stop_price | 止损价格设置不合法 |
| trigger_profit_price_less_than_order_delegate_price | 触发止盈价格不可小于订单委托价格(多) |
| trigger_profit_price_more_than_order_delegate_price | 触发止盈价格不可大于订单委托价格(空) |
| trigger_stop_price_more_than_order_delegate_price | 触发止损价格不可大于订单委托价格(多) |
| trigger_stop_price_less_than_order_delegate_price | 触发止损价格不可小于订单委托价格(空) |
| invalid_time_in_force | 无效的订单有效期 |
| on_board_30_minutes_limit_order_price_limit | 上板后30分钟内限价订单价格限制 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
批量下单 Edit
/future/trade/v2/order/create-batch
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| list | string | true | 订单数据列表集合 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| gateway_decommission_ip_country | 很遗憾,我们无法向受限制国家/地区的用户提供服务 |
| gateway_decommission_kyc_country | 很遗憾,我们无法向受限制国家/地区的用户提供服务 |
| GATEWAY_0003 | 当前用户触发风控,您的操作已被暂时禁止 |
| GATEWAY_0006 | 由于您触发风控规则,账户被锁定 |
| GATEWAY_0007 | 由于您触发风控规则,账户被锁定 |
| invalid_symbol | 交易对不存在 |
| symbol_is_not_trading | 交易对当前不可交易 |
| openapi_not_supported | 该交易对当前不支持API操作 |
| symbol_is_not_open_position | 交易对当前不可持仓 |
| invalid_params | 参数设置有误 |
| invalid_quantity | origQty必须为整数 |
| quantity_can_not_less_than * | origQty必须大于 * |
| user_can_not_trade | 账户当前禁止交易 |
| sub_account_not_trade | 子账户当前不可交易 |
| user_can_not_open_position | 账户当前无法开仓 |
| invalid_time_in_force | 时间设置不合法 |
| invalid_price | 价格设置不合法 |
| invalid_trigger_profit_price | 不合法的止盈价格 |
| invalid_trigger_stop_price | 不合法的止损价格 |
| trigger_profit_price_more_than_sell_one_price | 止盈触发价格需大于卖一价(多) |
| trigger_profit_price_less_than_buy_one_price | 止盈触发价格需小于买一价(空) |
| trigger_stop_price_more_than_sell_one_price | 止损触发价格需小于卖一价(多) |
| trigger_stop_price_less_than_buy_one_price | 止损触发价格需大于买一价(空) |
| trigger_profit_price_less_than_order_delegate_price | 触发止盈价格不可小于订单委托价格(多) |
| trigger_profit_price_more_than_order_delegate_price | 触发止盈价格不可大于订单委托价格(空) |
| trigger_stop_price_more_than_order_delegate_price | 触发止损价格不可大于订单委托价格(多) |
| trigger_stop_price_less_than_order_delegate_price | 触发止损价格不可小于订单委托价格(空) |
| on_board_30_minutes_limit_order_price_limit | 上板后30分钟内限价订单价格限制 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": "",
"returnCode": 0
}
批量下单(新) Edit
/future/trade/v2/order/atomic-create-batch
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| (JSON Array Body) | array | true | 请求体为 JSON 数组,每个元素代表一笔独立订单 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| gateway_decommission_ip_country | 很遗憾,我们无法向受限制国家/地区的用户提供服务 |
| gateway_decommission_kyc_country | 很遗憾,我们无法向受限制国家/地区的用户提供服务 |
| GATEWAY_0003 | 当前用户触发风控,您的操作已被暂时禁止 |
| GATEWAY_0006 | 由于您触发风控规则,账户被锁定 |
| GATEWAY_0007 | 由于您触发风控规则,账户被锁定 |
| invalid_symbol | 交易对不存在 |
| symbol_is_not_trading | 交易对当前不可交易 |
| openapi_not_supported | 该交易对当前不支持API操作 |
| symbol_is_not_open_position | 交易对当前不可持仓 |
| invalid_params | 参数设置有误 |
| invalid_quantity | origQty必须为整数 |
| quantity_can_not_less_than * | origQty必须大于 * |
| user_can_not_trade | 账户当前禁止交易 |
| sub_account_not_trade | 子账户当前不可交易 |
| user_can_not_open_position | 账户当前无法开仓 |
| invalid_time_in_force | 时间设置不合法 |
| invalid_price | 价格设置不合法 |
| invalid_trigger_profit_price | 不合法的止盈价格 |
| invalid_trigger_stop_price | 不合法的止损价格 |
| trigger_profit_price_more_than_sell_one_price | 止盈触发价格需大于卖一价(多) |
| trigger_profit_price_less_than_buy_one_price | 止盈触发价格需小于买一价(空) |
| trigger_stop_price_more_than_sell_one_price | 止损触发价格需小于卖一价(多) |
| trigger_stop_price_less_than_buy_one_price | 止损触发价格需大于买一价(空) |
| trigger_profit_price_less_than_order_delegate_price | 触发止盈价格不可小于订单委托价格(多) |
| trigger_profit_price_more_than_order_delegate_price | 触发止盈价格不可大于订单委托价格(空) |
| trigger_stop_price_more_than_order_delegate_price | 触发止损价格不可大于订单委托价格(多) |
| trigger_stop_price_less_than_order_delegate_price | 触发止损价格不可小于订单委托价格(空) |
| on_board_30_minutes_limit_order_price_limit | 上板后30分钟内限价订单价格限制 |
| order_create_size_exceed | 单次批量订单数超过上限,最大上限20订单 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": "",
"returnCode": 0
}
根据 ID 查看订单 Edit
/future/trade/v1/order/detail
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | integer | true | 订单 ID |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| null | 未找到该订单 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"avgPrice": 0,
"closePosition": false,
"closeProfit": 0,
"createdTime": 0,
"executedQty": 0,
"forceClose": false,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"sourceId": 0,
"state": "",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
},
"returnCode": 0
}
查看订单 Edit
/future/trade/v1/order/list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| clientOrderId | string | false | 客户订单 ID | ||
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 单页数量 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| state | string | false | NEW | 订单状态: NEW(新订单,未成交); PARTIALLY_FILLED(部分成交); FILLED(全部成交); CANCELED(已撤销); REJECTED(订单失败); EXPIRED(已过期); UNFINISHED(未完成); HISTORY(历史) | PREV; NEXT |
| symbol | string | false | 交易对 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid state | state填写错误 |
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"clientOrderId": "",
"avgPrice": 0,
"closePosition": false,
"closeProfit": 0,
"createdTime": 0,
"executedQty": 0,
"forceClose": false,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"sourceId": 0,
"state": "",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
撤销订单 Edit
/future/trade/v1/order/cancel
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | integer | true | 订单 ID |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_params | 参数错误 订单不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": "",
"returnCode": 0
}
批量撤销订单 Edit
/future/trade/v1/order/cancel-batch
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderIds | string | true | 订单 ID(逗号分隔) | ||
| clientOrderIds | string | false | 客户端订单 ID(逗号分隔) |
限流规则
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
撤销所有订单 Edit
/future/trade/v1/order/cancel-all
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对(传入空字符串则撤销所有交易对的订单) |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
| fail | 内部异常 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
获取当前委托订单列表 Edit
/future/trade/v1/order/list-open-order
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对名称(例如:eth_usdt, btc_usdt) |
限流规则
10次/秒/apikey
{
"orderId": "538511221008857280",
"clientOrderId": "myOrder123",
"symbol": "eth_usdt",
"contractSize": 0.01,
"orderType": "LIMIT",
"orderSide": "BUY",
"positionSide": "LONG",
"positionType": "ISOLATED",
"timeInForce": "GTC",
"price": "4009.94",
"origQty": "12",
"avgPrice": "0",
"executedQty": "0",
"marginFrozen": "80.48751569",
"remark": null,
"sourceId": null,
"sourceType": "DEFAULT",
"leverage": 6,
"openPrice": null,
"state": "NEW",
"createdTime": 1758093080143,
"updatedTime": 1758093080371,
"welfareAccount": false,
"triggerPriceType": null,
"triggerProfitPrice": null,
"profitDelegateOrderType": null,
"profitDelegateTimeInForce": null,
"profitDelegatePrice": null,
"triggerStopPrice": null,
"stopDelegateOrderType": null,
"stopDelegateTimeInForce": null,
"stopDelegatePrice": null,
"markPrice": "4543.73",
"desc": null
}
查看历史订单 Edit
/future/trade/v1/order/list-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对(不传则查询所有交易对) | ||
| direction | string | false | NEXT | 方向 | PREV;NEXT |
| id | integer | false | id | ||
| limit | integer | false | 10 | 限制数量 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| forceClose | string | false | false | 强平信息,不加该字段则不显示强平订单信息 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"clientOrderId": "",
"avgPrice": 0,
"closePosition": false,
"closeProfit": 0,
"createdTime": 0,
"executedQty": 0,
"forceClose": false,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"sourceId": 0,
"state": "",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
}
]
},
"returnCode": 0
}
查看成交明细 Edit
/future/trade/v1/order/trade-list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | integer | false | 订单 ID | ||
| symbol | string | false | 交易对 | ||
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 单页数量 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_page | 页面需为正整数 |
| invalid_size | size 最大值为 100 |
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"fee": 0,
"feeCoin": "",
"orderId": 0,
"execId": 0,
"price": 0,
"quantity": 0,
"symbol": "",
"timestamp": 0,
"takerMaker": "TAKER"
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
查询部分成交部分撤销订单 Edit
/future/trade/v2/order/partial-canceled-orders
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| page | integer | true | 1 | 页码 | |
| size | integer | true | 10 | 单页数量 | |
| startTime | integer | true | 开始时间(起止毫秒时间戳间隔要在300000毫秒内) | ||
| endTime | integer | true | 结束时间 | ||
| symbol | string | true | 交易对 |
备注
该接口限制只能查询五分钟内的数据。
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不合法 |
| invalid_time_in_force | 时间设定有误 |
| the_number_of_orders_has_reached_the_maximum | 区间数据过多,超限 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"clientOrderId": "",
"avgPrice": 0,
"closePosition": false,
"closeProfit": 0,
"createdTime": 0,
"executedQty": 0,
"forceClose": false,
"marginFrozen": 0,
"orderId": 0,
"orderSide": "",
"orderType": "",
"origQty": 0,
"positionSide": "",
"price": 0,
"sourceId": 0,
"state": "PARTIALLY_CANCELED",
"symbol": "",
"timeInForce": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0,
"canceledQty": 0
}
]
},
"returnCode": 0
}
查看历史订单(量化) Edit
/future/trade/v1/order/quant/list-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| id | long | false | 游标ID,用于翻页,上一次返回的最后一个orderId | ||
| direction | string | false | NEXT | 翻页方向 | PREV;NEXT |
| limit | integer | false | 10 | 每页数量,最大2000 | |
| symbol | string | false | 交易对 | ||
| forceClose | boolean | false | false | 是否强平订单 | |
| startTime | long | false | 开始时间(毫秒时间戳),最早90天前 | ||
| endTime | long | false | 结束时间(毫秒时间戳) | ||
| origType | integer | false | 条件委托类型:1=限价止盈、2=限价止损、3=市价止盈、4=市价止损 | ||
| orderSide | integer | false | 下单方向:1=买、2=卖 | ||
| states | list | false | 订单状态:2=部分成交、3=全部成交、4=用户撤销、6=已过期 | ||
| orderOrigType | integer | false | 历史订单类型:1=限价委托、2=市价委托、3=限价止盈止损、4=市价止盈止损、5=MMR止损 | ||
| welfareAccount | boolean | false | false | 是否查询体验金账户 |
量化账号专用历史订单查询接口,支持游标分页,最大返回2000条记录。
限流规则
200/s/apikey
游标分页使用说明
- 首次请求:不传
id参数 - 下一页:使用上一次返回列表中最后一条记录的 ID 作为
id参数,direction=NEXT - 上一页:使用当前列表第一条记录的 ID 作为
id参数,direction=PREV - 判断是否有更多数据:通过
hasNext和hasPrev字段判断
错误码
| 错误码 | 描述 |
|---|---|
| not_quantification_account | 非量化账号,无权访问此接口 |
{
"returnCode": 0,
"msgInfo": "",
"error": {
"code": "",
"msg": ""
},
"result": {
"hasPrev": false,
"hasNext": true,
"items": [
{
"orderId": 123456789,
"clientOrderId": "",
"symbol": "btc_usdt",
"orderSide": "BUY",
"orderType": "LIMIT",
"positionSide": "LONG",
"price": "50000.00",
"origQty": "0.1",
"executedQty": "0.1",
"avgPrice": "50000.00",
"state": "FILLED",
"closePosition": false,
"closeProfit": "100.00",
"marginFrozen": "0",
"forceClose": false,
"sourceId": 0,
"timeInForce": "GTC",
"triggerProfitPrice": "0",
"triggerStopPrice": "0",
"createdTime": 1703520000000,
"updatedTime": 1703520100000
}
]
}
}
查看成交明细(量化) Edit
/future/trade/v1/order/quant/trade-list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| id | long | false | 游标ID,用于翻页(上一次返回的最后一条Trade的execId) | ||
| direction | string | false | NEXT | 翻页方向 | PREV;NEXT |
| limit | integer | false | 10 | 每页数量,最大2000 | |
| orderId | long | false | 订单ID | ||
| symbol | string | false | 交易对 | ||
| startTime | long | false | 开始时间(毫秒时间戳) | ||
| endTime | long | false | 结束时间(毫秒时间戳) | ||
| welfareAccount | boolean | false | false | 是否查询体验金账户 |
量化账号专用成交明细查询接口,支持游标分页,最大返回2000条记录。
限流规则
200/s/apikey
游标分页使用说明
- 首次请求:不传
id参数 - 下一页:使用上一次返回列表中最后一条记录的
execId作为id参数,direction=NEXT - 上一页:使用当前列表第一条记录的
execId作为id参数,direction=PREV - 判断是否有更多数据:通过
hasNext和hasPrev字段判断
错误码
| 错误码 | 描述 |
|---|---|
| not_quantification_account | 非量化账号,无权访问此接口 |
{
"returnCode": 0,
"msgInfo": "",
"error": {
"code": "",
"msg": ""
},
"result": {
"hasPrev": false,
"hasNext": true,
"items": [
{
"execId": 987654321,
"orderId": 123456789,
"symbol": "btc_usdt",
"price": "50000.00",
"quantity": "0.05",
"quoteQty": "2500.00",
"fee": "1.25",
"feeCoin": "USDT",
"takerMaker": "TAKER",
"timestamp": 1703520050000
}
]
}
}
创建触发订单 Edit
/future/trade/v1/entrust/create-plan
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| clientOrderId | string | false | 客户端订单ID | ||
| symbol | string | true | 交易对 | ||
| orderSide | string | true | 订单方向 | BUY;SELL | |
| entrustType | string | true | 委托类型:TAKE_PROFIT(止盈限价单);STOP(止损限价单);TAKE_PROFIT_MARKET(止盈市价单);STOP_MARKET(止损市价单) | TAKE_PROFIT;STOP;TAKE_PROFIT_MARKET;STOP_MARKET | |
| origQty | number | true | 数量(张) | ||
| price | number | false | 价格 | ||
| stopPrice | number | true | 触发价格 | ||
| timeInForce | string | true | 有效方式:GTC;IOC;FOK;GTX。市价单仅支持IOC | GTC;IOC;FOK;GTX | |
| triggerPriceType | string | true | 触发价格类型 | INDEX_PRICE;MARK_PRICE;LATEST_PRICE | |
| positionSide | string | true | 持仓方向 | LONG;SHORT |
Content-Type = application/x-www-form-urlencoded && application/json
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| deposit_coupon_exists | 保证金优惠券已存在 |
| exist_bonus_positon_not_create_reverse_position | 不允许创建反向仓位(存在赠金仓位) |
| invalid_params | 有必填参数未填写 |
| invalid_price | 某个价格参数填写有误;计划止盈/止损限价校验失败 |
| market_plan_entrust_must_be_ioc_or_fok | 市价止盈/止损委托必须为 IOC 或 FOK |
| invalid_stop_price | 止损价格有误 |
| invalid_quantity_scale | 下单数量必须是整数 |
| invalid_trigger_profit_price | 触发止盈价格有误 |
| invalid_time_in_force | 计划委托止盈的 timeInForce 校验失败 |
| on_board_30_minutes_limit_order_price_limit | 上板后 30 分钟内限价单价格限制 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
取消触发订单 Edit
/future/trade/v1/entrust/cancel-plan
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| entrustId | string | true | 计划委托单 ID |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_params | 提交的参数有误或为空 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
取消所有触发订单 Edit
/future/trade/v1/entrust/cancel-all-plan
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 | 例如 btc_usdt |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
| fail | 内部错误 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
查看触发订单 Edit
/future/trade/v1/entrust/plan-list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对(不传则查询所有交易对) | ||
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 每页数量 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| state | string | true | 订单状态 | NOT_TRIGGERED;TRIGGERING;TRIGGERED;USER_REVOCATION;PLATFORM_REVOCATION;EXPIRED;UNFINISHED;HISTORY |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_state | state 有误 |
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"clientOrderId": "",
"closePosition": false,
"createdTime": 0,
"entrustId": 0,
"entrustType": "",
"marketOrderLevel": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"timeInForce": "",
"triggerPriceType": ""
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
根据EntrustId查看触发订单 Edit
/future/trade/v1/entrust/plan-detail
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| entrustId | integer | true | 订单ID |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_entrust_Id | 订单ID有误 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"closePosition": false,
"createdTime": 0,
"entrustId": 0,
"entrustType": "",
"marketOrderLevel": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"timeInForce": "",
"triggerPriceType": ""
},
"returnCode": 0
}
查看触发订单历史 Edit
/future/trade/v1/entrust/plan-list-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对(不传则查询所有交易对) | ||
| direction | string | false | NEXT | 查询方向 | PREV;NEXT |
| id | integer | false | ID | ||
| limit | integer | false | 10 | 数量限制 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 |
限流规则
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"clientOrderId": "",
"closePosition": false,
"createdTime": 0,
"entrustId": 0,
"entrustType": "",
"marketOrderLevel": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"timeInForce": "",
"triggerPriceType": ""
}
]
},
"returnCode": 0
}
创建止盈止损 Edit
/future/trade/v1/entrust/create-profit
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 | ||
| origQty | integer | true | 数量(张) | ||
| triggerProfitPrice | integer | true | 止盈触发价格 | ||
| triggerStopPrice | integer | true | 止损触发价格 | ||
| expireTime | integer | true | 过期时间(timestamp) | ||
| positionSide | string | true | 持仓方向 | LONG;SHORT | |
| profitDelegateOrderType | string | true | 止盈委托订单类型 | LIMIT;MARKET | |
| profitDelegateTimeInForce | string | true | 止盈委托订单有效期 | GTC;FOK;IOC;GTX | |
| profitDelegatePrice | number | false | 止盈委托价格 | ||
| stopDelegateOrderType | string | true | 止损委托订单类型 | LIMIT;MARKET | |
| stopDelegateTimeInForce | string | true | 止损委托订单有效期 | GTC;FOK;IOC;GTX | |
| stopDelegatePrice | number | false | 止损委托价格 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_time_in_force | 止盈止损时间设置失败 |
| invalid_params | 参数设置有误或置空 |
| invalid_quantity_scale | 数量须为正整数 |
| invalid_trigger_profit_price | 止盈触发价格有误 |
| invalid_trigger_stop_price | 止损触发价格有误 |
| quantity_can_not_less_than | 下单数量小于最小限制 |
| invalid_price | 价格设置有误 |
| more_than_available | 超过了可提供的数量 |
| trigger_profit_price_less_than_entry_price | 止盈价格必须高于开仓价(多) |
| trigger_profit_price_less_than_mark_price | 止盈价格必须高于当前标记价(多) |
| trigger_profit_price_less_than_index_price | 止盈价格必须高于当前指数价(多) |
| trigger_profit_price_more_than_entry_price | 止盈价格必须低于开仓价(空) |
| trigger_profit_price_more_than_mark_price | 止盈价格必须低于当前标记价(空) |
| trigger_profit_price_more_than_index_price | 止盈价格必须低于当前指数价(空) |
| trigger_stop_price_less_than_entry_price | 止损价格必须高于开仓价(空) |
| trigger_stop_price_less_than_mark_price | 止损价格必须高于当前标记价(空) |
| trigger_stop_price_less_than_index_price | 止损价格必须高于当前指数价(空) |
| trigger_stop_price_more_than_entry_price | 止损价格必须低于开仓价(多) |
| trigger_stop_price_more_than_mark_price | 止损价格必须低于当前标记价(多) |
| trigger_stop_price_more_than_index_price | 止损价格必须低于当前指数价(多) |
| user_can_not_trade | 账户禁止交易 |
| sub_account_not_trade | 子账户禁止交易 |
| user_can_not_open_position | 账户限制开仓 |
| invalid_symbol | 不存在该交易对 |
| symbol_is_not_trading | 交易对未在交易状态 |
| symbol_is_not_open_position | 交易对未在开启状态 |
| symbol_not_support_openapi | 该交易对当前不支持通过 OpenAPI 下单 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
取消止盈止损 Edit
/future/trade/v1/entrust/cancel-profit-stop
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| profitId | integer | true | 止盈止损订单ID |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_entrust | 订单ID有误 |
| fail | 内部异常 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
取消所有止盈止损 Edit
/future/trade/v1/entrust/cancel-all-profit-stop
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对,例如 btc_usdt |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
| fail | 内部异常 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": true,
"returnCode": 0
}
查看止盈止损 Edit
/future/trade/v1/entrust/profit-list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对(不传则查询所有交易对) | ||
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 每页数量 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| state | string | true | 订单状态 | NOT_TRIGGERED;TRIGGERING;TRIGGERED;USER_REVOCATION;PLATFORM_REVOCATION;EXPIRED;UNFINISHED;HISTORY |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
| invalid_position_type | 持仓类型不正确 |
| invalid_position_side | 仓位方向不正确 |
| invalid_state | state类型不正确 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"createdTime": 0,
"entryPrice": 0,
"executedQty": 0,
"isolatedMargin": 0,
"origQty": 0,
"positionSide": "",
"positionSize": 0,
"profitId": 0,
"state": "",
"symbol": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0,
"profitDelegateOrderType": "LIMIT",
"profitDelegatePrice": 0,
"profitDelegateTimeInForce": "GTC",
"stopDelegateOrderType": "LIMIT",
"stopDelegatePrice": 0,
"stopDelegateTimeInForce": "GTC"
}
],
"page": 0,
"ps": 0,
"total": 0
},
"returnCode": 0
}
根据ProfitId查看止盈止损 Edit
/future/trade/v1/entrust/profit-detail
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| profitId | integer | true | 止盈止损订单ID |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_profit_id | Profit ID 不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"createdTime": 0,
"entryPrice": 0,
"executedQty": 0,
"isolatedMargin": 0,
"origQty": 0,
"positionSide": "",
"positionSize": 0,
"profitId": 0,
"state": "",
"symbol": "",
"triggerProfitPrice": 0,
"triggerStopPrice": 0
},
"returnCode": 0
}
修改止盈止损 Edit
/future/trade/v1/entrust/update-profit-stop
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| profitId | integer | true | 止盈止损订单ID | ||
| triggerProfitPrice | number | false | 止盈触发价格 | ||
| triggerStopPrice | number | false | 止损触发价格 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_entrust | Profit ID 不存在 |
| user_can_not_trade | 账户禁止交易 |
| sub_account_not_trade | 子账户不可交易 |
| user_can_not_open_position | 账户禁止开仓 |
| invalid_order_type | 无效订单类型 |
| invalid_trigger_profit_price | 止盈价格不合法 |
| invalid_trigger_stop_price | 止损价格不合法 |
| invalid_origQty | 下单数量不合法 |
| invalid_quantity_scale | 下单数量必须为整数 |
| invalid_time_in_force | 时间设置不合法 |
| trigger_profit_price_less_than_entry_price | 止盈价格必须高于开仓价(多) |
| trigger_profit_price_less_than_mark_price | 止盈价格必须高于当前标记价(多) |
| trigger_profit_price_less_than_index_price | 止盈价格必须高于当前指数价(多) |
| trigger_profit_price_more_than_entry_price | 止盈价格必须低于开仓价(空) |
| trigger_profit_price_more_than_mark_price | 止盈价格必须低于当前标记价(空) |
| trigger_profit_price_more_than_index_price | 止盈价格必须低于当前指数价(空) |
| trigger_stop_price_less_than_entry_price | 止损价格必须高于开仓价(空) |
| trigger_stop_price_less_than_mark_price | 止损价格必须高于当前标记价(空) |
| trigger_stop_price_less_than_index_price | 止损价格必须高于当前指数价(空) |
| trigger_stop_price_more_than_entry_price | 止损价格必须低于开仓价(多) |
| trigger_stop_price_more_than_mark_price | 止损价格必须低于当前标记价(多) |
| trigger_stop_price_more_than_index_price | 止损价格必须低于当前指数价(多) |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
创建跟踪单 Edit
/future/trade/v1/entrust/create-track
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| callback | string | true | 回调幅度配置 | FIXED;PROPORTION | |
| callbackVal | number | true | 回调值(大于0) | >0 | |
| orderSide | string | true | 订单方向 | BUY;SELL | |
| origQty | number | true | 原始数量(张) | ||
| positionSide | string | true | 持仓方向 | BOTH;LONG;SHORT | |
| positionType | string | true | 持仓类型 | CROSSED;ISOLATED | |
| symbol | string | true | 交易对 | ||
| triggerPriceType | string | true | 触发价格类型 | INDEX_PRICE;MARK_PRICE;LATEST_PRICE | |
| activationPrice | number | false | 激活价格 | ||
| clientMedia | string | false | 客户端媒介 | ||
| clientMediaChannel | string | false | 客户端媒介渠道 | ||
| clientOrderId | string | false | 客户端订单ID | ||
| expireTime | integer | false | 过期时间 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
| symbol_is_not_trading | 交易对当前无法交易 |
| symbol_not_support_openapi | 该交易对当前不支持通过 OpenAPI 下单 |
| deposit_coupon_exists | 该抵扣券已领取或已绑定 |
| exist_bonus_positon_not_create_reverse_position | 不可创建反向仓位 |
| invalid_params | 参数设置有误或置空了 |
| invalid_exceed_max_rate_limit | 回调幅度设置不能超过最大值 |
| invalid_below_min_rate_limit | 回调幅度设置不能低于最小值 |
| invalid_exceed_max_price_limit | 回调幅度设置不能超过最新成交价 |
| invalid_exceed_min_price_limit | 回调率设置不能低于最新成交价 |
| invalid_activation_price | 触发价格不合法 |
| invalid_quantity_scale | 数量必须为整数 |
| user_can_not_trade | 账户禁止交易 |
| sub_account_not_trade | 子账户不可交易 |
| user_can_not_open_position | 账户禁止开仓 |
| symbol_is_not_open_position | 当前交易对已暂停开新仓 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
取消单个跟踪单 Edit
/future/trade/v1/entrust/cancel-track
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| trackId | integer | true | 跟踪单ID |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_track_entrust | 跟踪单不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
获取单个跟踪单详情 Edit
/future/trade/v1/entrust/track-detail
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| trackId | integer | true | 跟踪单ID |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_track_Id | 跟踪单不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"activationPrice": 0,
"avgPrice": 0,
"callback": "",
"callbackVal": 0,
"configActivation": false,
"createdTime": 0,
"currentPrice": 0,
"desc": "",
"executedQty": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"trackId": 0,
"triggerPriceType": "",
"updatedTime": 0
},
"returnCode": 0
}
获取跟踪单列表(所有活跃) Edit
/future/trade/v1/entrust/track-list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 每页数量 | |
| endTime | integer | false | 结束时间 | ||
| startTime | integer | false | 开始时间 | ||
| symbol | string | false | 交易对 |
限流规则
200/s/apikey
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"items": [
{
"activationPrice": 0,
"avgPrice": 0,
"callback": "",
"callbackVal": 0,
"configActivation": false,
"createdTime": 0,
"currentPrice": 0,
"desc": "",
"executedQty": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"trackId": 0,
"triggerPriceType": "",
"updatedTime": 0
}
],
"page": 1,
"ps": 10,
"total": 20
},
"returnCode": 0
}
取消所有跟踪单 Edit
/future/trade/v1/entrust/cancel-all-track
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
| fail | 内部异常 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {},
"returnCode": 0
}
获取历史跟踪单列表(非活跃) Edit
/future/trade/v1/entrust/track-list-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| direction | string | false | NEXT | 翻页方向 | PREV;NEXT |
| limit | integer | false | 10 | 数量限制 | |
| id | integer | false | 记录ID | ||
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| symbol | string | false | 交易对 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": true,
"hasPre": true,
"items": [
{
"activationPrice": 0,
"avgPrice": 0,
"callback": "",
"callbackVal": 0,
"configActivation": false,
"createdTime": 0,
"currentPrice": 0,
"desc": "",
"executedQty": 0,
"orderSide": "",
"ordinary": true,
"origQty": 0,
"positionSide": "",
"price": 0,
"state": "",
"stopPrice": 0,
"symbol": "",
"trackId": 0,
"triggerPriceType": "",
"updatedTime": 0
}
]
},
"returnCode": 0
}
查询历史止盈止损委托 Edit
/future/trade/v1/entrust/profit-list-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| id | integer | false | 1 | 页码 | |
| limit | integer | false | 10 | 单页数量 | |
| startTime | integer | false | 开始时间(默认查询90天前) | ||
| endTime | integer | false | 结束时间 | ||
| symbol | string | false | 交易对 | ||
| direction | string | false | NEXT | 翻页方向 | NEXT;PREVIOUS |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_direction | direction 不正确 |
| invalid_limit | limit参数设置不正确 |
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"profitId": "",
"symbol": "BTCUSDT",
"positionSide": "LONG",
"origQty": "0.020",
"leverage": 20,
"triggerPriceType": "MARK_PRICE",
"triggerProfitPrice": "68500.00",
"triggerStopPrice": "59500.00",
"entryPrice": "63250.80",
"positionSize": "0.020",
"isolatedMargin": "63.25",
"executedQty": "0.020",
"avgPrice": "68320.50",
"positionType": "ISOLATED",
"state": "TRIGGERED",
"createdTime": 1735689000000,
"updatedTime": 1735690123000,
"sourceType": "WEB",
"profitType": 0,
"mmrThreshold": null
}
]
},
"returnCode": 0
}
查询计划反手 Edit
/future/trade/v1/entrust/reverse-plan-list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| positionType | string | false | 仓位类型 | crossed;isolated | |
| positionSide | string | false | 仓位方向 | long;short | |
| closeType | string | false | 结束类型 | fixed;all | |
| state | string | false | 状态 | not_triggered;triggered;triggering;user_revocation;platform_revocation;expired | |
| symbol | string | false | 交易对 | ||
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 单页数量 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_position_type | Position type不正确 |
| invalid_position_side | Position side不正确 |
| invalid_profit_close_type | Position close type不正确 |
| invalid_state | State 不正确 |
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"entrustId": "",
"symbol": "",
"entrustType": "",
"orderSide": "",
"positionSide": "",
"timeInForce": "",
"closePosition": false,
"price": 0,
"origQty": 0,
"stopPrice": "",
"triggerPriceType": "",
"executedQty": 0,
"avgPrice": "",
"state": "",
"createdTime": "",
"updatedTime": "",
"clientOrderId": "",
"reverseOpenExecutedQty": 0,
"reverseOpenAvgPrice": 0,
"desc": ""
}
]
},
"returnCode": 0
}
查询历史计划反手 Edit
/future/trade/v1/entrust/reverse-plan-list-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 单页数量 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| symbol | string | false | 交易对 |
注意: 该接口限制只能查询五分钟内的数据。
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_position_type | Position type不正确 |
| invalid_position_side | Position side不正确 |
| invalid_profit_close_type | Position close type不正确 |
| invalid_state | State 不正确 |
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"entrustId": "",
"symbol": "",
"entrustType": "",
"orderSide": "",
"positionSide": "",
"timeInForce": "",
"closePosition": false,
"price": 0,
"origQty": 0,
"stopPrice": "",
"triggerPriceType": "",
"executedQty": 0,
"avgPrice": "",
"state": "",
"createdTime": "",
"updatedTime": "",
"clientOrderId": "",
"reverseOpenExecutedQty": 0,
"reverseOpenAvgPrice": 0,
"desc": ""
}
]
},
"returnCode": 0
}
查询有成交的历史订单 Edit
/future/trade/v1/order/trade-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| limit | integer | false | 10 | 数量(最大为500) | |
| startTime | integer | false | 开始时间(默认查询90天前) | ||
| endTime | integer | false | 结束时间 | ||
| symbol | string | true | 交易对 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"symbol": "BTCUSDT",
"orderSide": "BUY",
"avgPrice": "67234.50",
"origQty": "0.012",
"executedQty": "0.012",
"updatedTime": 1735698765000
}
],
"returnCode": 0
}
查询不分页的成交明细 Edit
/future/trade/v1/order/trade-list-all
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| orderId | integer | false | 订单id | ||
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| symbol | string | false | 交易对 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_limit | limit参数设置不正确 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"orderId": "1876543210987654321",
"execId": "2876543210987654322",
"symbol": "BTCUSDT",
"contractSize": 0.001,
"quantity": "0.015",
"price": "67234.80",
"fee": "10.08522",
"couponDeductFee": "3.00000",
"bonusDeductFee": "2.00000",
"feeCoin": "USDT",
"timestamp": 1735698765432,
"takerMaker": "TAKER",
"orderSide": "BUY",
"positionSide": "LONG"
}
],
"returnCode": 0
}
查询全部委托 Edit
/future/trade/v1/order-entrust/list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 单页数量 | |
| startTime | long | false | 开始时间 | ||
| endTime | long | false | 结束时间 | ||
| symbol | string | false | 交易对 | ||
| type | string | false | ORDER | 委托类型:ORDER(限价/市价委托)或 ENTRUST(计划委托) | |
| state | string | false | 订单状态 | NEW;PARTIALLY_FILLED;FILLED;CANCELED;REJECTED;PLACED;UNFINISHED;HISTORY | |
| forceClose | bool | false | false | 是否强平 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_size | size不正确 |
| invalid_page | page参数设置不正确 |
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"page": 1,
"ps": 10,
"total": 99,
"items": [
{
"id": "1876543210987654321",
"type": "ORDER",
"symbol": "BTCUSDT",
"orderType": "LIMIT",
"orderSide": "BUY",
"positionSide": "LONG",
"timeInForce": "GTC",
"closePosition": false,
"price": "67200.00",
"origQty": "0.015",
"avgPrice": "67234.50",
"executedQty": "0.015",
"marginFrozen": "50.42",
"leverage": 25,
"state": "FILLED",
"createdTime": 1735698000000,
"updatedTime": 1735698765000,
"positionType": "ISOLATED"
}
]
},
"returnCode": 0
}
获取当前持仓信息 Edit
/future/trade/v1/position/list/active
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对 | ||
| isDelivery | bool | false | false | 是否查询交割 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": [
{
"symbol": "BTCUSDT",
"positionType": "ISOLATED",
"positionSide": "LONG",
"contractType": "PERPETUAL",
"positionSize": "0.032",
"closeOrderSize": "0.008",
"availableCloseSize": "0.024",
"entryPrice": "66543.21",
"openOrderSize": "0.010",
"isolatedMargin": "106.47",
"openOrderMarginFrozen": "33.27",
"realizedProfit": "87.65",
"autoMargin": false,
"leverage": 25,
"contractSize": "0.001",
"markPrice": "67234.80",
"updatedTime": "1735701234567",
"welfareExpirationTime": 1767225599000,
"mmrProfitId": null,
"mmrThreshold": null
}
],
"returnCode": 0
}
获取杠杆信息 Edit
/future/trade/v1/position/leverage/list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"symbol": "BTCUSDT",
"accountId": "",
"positionType": "ISOLATED",
"positionSide": "LONG",
"contractType": "PERPETUAL",
"leverage": 25
}
]
},
"returnCode": 0
}
查询历史仓位 Edit
/future/trade/v1/position/list-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| id | integer | false | 1 | 页码 | |
| direction | string | false | NEXT | 翻页方向 | NEXT;PREVIOUS |
| limit | integer | false | 10 | 单页数量 | |
| symbol | string | false | 交易对 | ||
| startTime | long | false | 开始时间 | ||
| endTime | long | false | 结束时间 | ||
| positionType | integer | false | 仓位模式(1全仓、2逐仓;不传查询全部) | ||
| isFullClose | integer | false | 平仓方式(0部分平仓、1全部平仓;不传全部) |
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_direction | direction 不正确 |
| invalid_limit | limit参数设置不正确 |
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"id": "1987654321098765432",
"positionSide": "LONG",
"contractType": "PERPETUAL",
"symbol": "BTCUSDT",
"positionType": 2,
"closeProfit": "127.83",
"closePositionSize": "0.050",
"closeOpenPrice": "63250.80",
"closePrice": "65808.60",
"maxPositionSize": "0.080",
"openTime": 1735608000000,
"closeTime": 1735699200000,
"startLeverage": 25,
"endLeverage": 25,
"working": false,
"force": false,
"forceMarkPrice": null,
"totalFee": "18.92",
"totalFundFee": "3.41",
"welfareAccount": false
}
]
},
"returnCode": 0
}
查询全仓维持保证金 Edit
/future/trade/v1/position/cross-margin/{symbol}
symbol 通过 URL 路径参数传递,例如:/future/trade/v1/position/cross-margin/eth_usdt
限流规则
200/s/apikey
错误码
| 错误码 | 描述 |
|---|---|
| invalid_symbol | 交易对不存在 |
{
"error": {
"code": "",
"msg": ""
},
"msgInfo": "",
"result": "result",
"returnCode": 0
}
获取账户相关信息 Edit
/future/user/v1/account/info
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"accountId": 0, // 账户ID
"allowOpenPosition": false, // 是否允许开仓
"allowTrade": false, // 是否允许交易
"allowTransfer": false, // 是否允许划转
"openTime": "", // 开户时间
"state": 0, // 用户状态
"userId": 0 // 用户ID
},
"returnCode": 0
}
获取合约账户资产 Edit
/future/user/v1/compat/balance/list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| queryAccountId | string | false | 账户 ID |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"accountId": 500000000000, // 账户ID
"userId": 500000000000, // 用户ID
"coin": "usdt", // 币种
"underlyingType": 2, // 币种标准,U本位
"walletBalance": "2078.57264793", // 钱包余额
"openOrderMarginFrozen": "0", // 委托单冻结
"isolatedMargin": "0", // 逐仓保证金
"crossedMargin": "0", // 全仓保证金
"amount": "2078.57264793", // 净资产余额
"totalAmount": "2078.57264793",// 保证金余额
"convertBtcAmount": "0.03638940", // 钱包余额折算BTC
"convertUsdtAmount": "2078.5726", // 钱包余额折算USDT
"profit": "0", // 已实现盈亏
"notProfit": "0", // 未实现盈亏
"bonus": "0", // 奖励金
"coupon": "0" // 抵扣券
}
],
"returnCode": 0
}
获取 ListenKey Edit
/future/user/v1/user/listen-key
限流规则
200次/秒/apikey
说明: 有效期为 8 小时
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {},
"returnCode": 0
}
开通合约 Edit
/future/user/v1/account/open
限流规则
200/s/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": true,
"returnCode": 0
}
获取用户单币种资金信息 Edit
/future/user/v1/balance/detail
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| coin | string | true | 币种 eg:btc |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"availableBalance": 0, // 可用余额
"coin": "", // 币种
"isolatedMargin": 0, // 冻结逐仓保证金
"openOrderMarginFrozen": 0, // 冻结委托保证金
"crossedMargin": 0, // 全仓保证金
"bonus": 0, // 奖励金
"coupon": 0, // 抵扣券
"walletBalance": 0 // 钱包余额
},
"returnCode": 0
}
获取用户资金信息 Edit
/future/user/v1/balance/list
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"availableBalance": 0, // 可用余额
"coin": "", // 币种
"isolatedMargin": 0, // 冻结逐仓保证金
"openOrderMarginFrozen": 0, // 冻结委托保证金
"crossedMargin": 0, // 全仓保证金
"bonus": 0, // 奖励金
"coupon": 0, // 抵扣券
"walletBalance": 0 // 钱包余额
}
],
"returnCode": 0
}
获取用户资金流水信息 Edit
/future/user/v1/balance/bills
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对(不传则查询全部) | ||
| direction | string | false | NEXT | 查询方向(PREV: 上一页;NEXT: 下一页) | PREV;NEXT |
| id | integer | false | 记录ID | ||
| limit | integer | false | 10 | 每页条数 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"hasNext": false, // 是否有下一页
"hasPrev": false, // 是否有上一页
"items": [
{
"afterAmount": 0, // 变动后的余额
"amount": 0, // 变动数量
"coin": "", // 币种
"createdTime": 0, // 时间戳
"id": 0, // 记录ID
"side": "", // ADD: 转入;SUB: 转出
"symbol": "", // 交易对
"type": "" // EXCHANGE: 转账;CLOSE_POSITION: 平仓盈亏;TAKE_OVER: 仓位接管;FUND: 资金费率;FEE: 手续费;ADL: 自动减仓;MERGE: 仓位合并
}
]
},
"returnCode": 0
}
获取资金费率信息 Edit
/future/user/v1/balance/funding-rate-list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对(不传则查询所有交易对) | ||
| direction | string | false | NEXT | 分页方向(PREV:上一页;NEXT:下一页) | PREV;NEXT |
| id | integer | false | 记录 ID | ||
| limit | integer | false | 10 | 每页条数 | |
| startTime | integer | false | 起始时间 | ||
| endTime | integer | false | 结束时间 |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"hasNext": false, // 是否有下一页
"hasPrev": false, // 是否有上一页
"items": [
{
"cast": 0, // 资金费用
"coin": "", // 币种
"createdTime": 0, // 时间
"id": 0, // 记录ID
"positionSide": "", // 持仓方向
"symbol": "" // 交易对
}
]
},
"returnCode": 0
}
获取活跃持仓信息 Edit
/future/user/v1/position
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对(不传时查询所有交易对的持仓信息) |
限流规则
200次/秒/apikey
{
"error": { "args": [], "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"autoMargin": false, // 是否自动追加保证金
"availableCloseSize": 0, // 可平仓数量(张)
"breakPrice": 0, // 强平价格
"calMarkPrice": 0, // 计算标记价格
"closeOrderSize": 0, // 已挂单数量(张)
"contractType": "", // 合约类型:PERPETUAL、PREDICT
"entryPrice": 0, // 开仓均价
"floatingPL": 0, // 未实现盈亏
"isolatedMargin": 0, // 仓位保证金(逐仓)
"leverage": 0, // 杠杆倍数
"openOrderMarginFrozen": 0, // 开仓委托冻结保证金
"openOrderSize": 0, // 开仓委托占用数量
"positionSide": "", // 仓位方向
"positionSize": 0, // 仓位数量(张)
"positionType": "", // 仓位类型:CROSSED;ISOLATED
"profitId": 0, // 止盈止损ID
"realizedProfit": 0, // 已实现盈亏
"symbol": "", // 交易对
"triggerPriceType": "", // 触发价格类型
"triggerProfitPrice": 0, // 止盈触发价
"triggerStopPrice": 0, // 止损触发价
"welfareAccount": true // 是否为福利账户
}
],
"returnCode": 0
}
获取持仓信息 Edit
/future/user/v1/position/list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对(不传时查询所有交易对的持仓信息) |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"autoMargin": false, // 是否自动追加保证金
"availableCloseSize": 0, // 可平仓数量(张)
"closeOrderSize": 0, // 挂单数量(张)
"entryPrice": 0, // 开仓均价
"isolatedMargin": 0, // 逐仓保证金
"leverage": 0, // 杠杆倍数
"openOrderMarginFrozen": 0, // 占用开仓保证金
"positionSide": "", // 持仓方向
"positionSize": 0, // 持仓数量(张)
"positionType": "", // 仓位类型
"realizedProfit": 0, // 已实现盈亏
"symbol": "" // 交易对
}
],
"returnCode": 0
}
获取用户阶梯费率 Edit
/future/user/v1/user/step-rate
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "success",
"result": {
"specialType": false, // 是否为特殊账户
"vipProType": true, // 是否为专业费率
"stepRateProName": "VIP_PRO_1", // 专业费率等级名称
"discountLevel": 2, // 折扣等级
"makerFee": "0.0015", // 挂单手续费率
"takerFee": "0.0025", // 吃单手续费率
"levelReturnDay": 30, // 当前等级保留天数
"totalTradeVolume": "1250000.50", // 近29天+当天交易量
"uBasedTotalTradeVolume": "850000.75", // USDT本位合约交易量
"coinBasedTotalTradeVolume": "400000.25",// 币本位合约交易量
"walletBalance": "50000.00", // 账户权益
"notProfit": "1250.50", // 持仓未实现盈亏
"nextLvTradeVolume": "1500000.00", // 下一等级所需交易量
"lackTradeVolume": "250000.50", // 距离下一等级所需的交易量
"nextLvWalletBalance": "75000.00", // 下一等级所需账户权益
"lackWalletBalance": "25000.00", // 距离下一等级所需的账户权益
"nextLvMakerFee": "0.0010", // 下一等级挂单手续费率
"nextLvTakerFee": "0.0020" // 下一等级吃单手续费率
},
"returnCode": 0
}
调整杠杆 Edit
/future/user/v1/position/adjust-leverage
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt | ||
| positionSide | string | true | 持仓方向 | LONG;SHORT | |
| leverage | integer | true | 杠杆倍数 |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {},
"returnCode": 0
}
调整保证金 Edit
/future/user/v1/position/margin
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt | ||
| margin | number | false | 数量 | ||
| positionSide | string | false | 持仓方向 | LONG;SHORT | |
| type | string | false | 调整方向(ADD: 增加逐仓保证金, SUB: 减少逐仓保证金) | ADD;SUB |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {},
"returnCode": 0
}
修改自动追加保证金 Edit
/future/user/v1/position/auto-margin
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt | ||
| positionSide | string | true | 持仓方向 | LONG;SHORT | |
| autoMargin | boolean | true | 是否自动追加保证金 | true;false |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {},
"returnCode": 0
}
全部平仓 Edit
/future/user/v1/position/close-all
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": true,
"returnCode": 0
}
获取ADL信息 Edit
/future/user/v1/position/adl
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对(不传时查询所有交易对的持仓信息) |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"longQuantile": 0, // 多头仓位ADL档位
"shortQuantile": 0, // 空头仓位ADL档位
"symbol": "" // 交易对
}
],
"returnCode": 0
}
收藏交易对 Edit
/future/user/v1/user/collection/add
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": true,
"returnCode": 0
}
取消交易对收藏 Edit
/future/user/v1/user/collection/cancel
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": true,
"returnCode": 0
}
获取已收藏交易对列表 Edit
/future/user/v1/user/collection/list
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [],
"returnCode": 0
}
修改持仓模式 Edit
/future/user/v1/position/change-type
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | true | 交易对 eg:btc_usdt | ||
| positionSide | string | true | 持仓方向 | LONG;SHORT | |
| positionType | string | true | 仓位模式 | CROSSED;ISOLATED |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {},
"returnCode": 0
}
获取爆仓预警信息 Edit
/future/user/v1/position/break-list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| symbol | string | false | 交易对(不传时查询所有交易对的爆仓预警信息) |
限流规则
200次/秒/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": [
{
"breakPrice": 0, // 爆仓价格,0代表不爆仓
"calMarkPrice": 0, // 标记价格
"contractType": "", // 合约类型:PERPETUAL 永续合约;PREDICT 预测合约
"entryPrice": 0, // 开仓均价
"isolatedMargin": 0, // 逐仓保证金
"leverage": 0, // 杠杆倍数
"positionSide": "", // 持仓方向:LONG 多头;SHORT 空头
"positionSize": 0, // 持仓数量(张)
"positionType": "", // 仓位类型:CROSSED 全仓;ISOLATED 逐仓
"symbol": "" // 交易对
}
],
"returnCode": 0
}
查询自动减仓历史 Edit
/future/user/v1/auto-deleverage/history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| id | integer | false | 1 | 页码 | |
| direction | string | false | NEXT | 方向 | NEXT;PREVIOUS |
| limit | integer | false | 10 | 单页数量 | |
| startTime | integer | false | 开始时间(默认查询90天前) | ||
| endTime | integer | false | 结束时间 | ||
| symbol | string | false | 交易对 |
限流规则
200/s/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"id": "2876543210987654321", // ADL记录ID
"symbol": "BTCUSDT", // 交易对
"positionSide": "LONG", // LONG 多头 / SHORT 空头
"quantity": "0.028", // 被ADL强制减仓的数量(张)
"price": "67234.50", // ADL执行时的成交价格
"realizedProfit": "-87.60", // 本次ADL产生的已实现盈亏
"createdTime": 1735698765432, // ADL发生时间戳(毫秒)
"welfareAccount": false, // 是否为体验金账户
"uid": 10086, // 用户UID
"accountId": 900123456789 // 账户ID
}
]
},
"returnCode": 0
}
查询单币种资产 Edit
/future/user/v1/compat/balance/{coin}
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| coin | string | true | 币种(路径参数)eg:usdt |
限流规则
200/s/apikey
{
"rc": 0,
"mc": "",
"ma": "",
"result": {
"accountId": 900123456789,
"userId": 10086,
"coin": "USDT",
"underlyingType": 2,
"walletBalance": "15234.87654321",
"openOrderMarginFrozen": "800.00000000",
"isolatedMargin": "2150.50000000",
"crossedMargin": "4300.00000000",
"amount": "8434.37654321",
"totalAmount": "12734.87654321",
"convertBtcAmount": "0.22681500",
"convertUsdtAmount": "15234.88",
"profit": "1250.45",
"notProfit": "-500.00",
"bonus": "1000.00000000",
"coupon": "300.00000000",
"depositCoupon": "5000.00000000",
"marginBalance": "13234.87654321",
"openOrderFeeFrozen": "15.88"
}
}
查询接管记录 Edit
/future/user/v1/taker-over/list
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| id | integer | false | 1 | 页码 | |
| direction | string | false | NEXT | 方向 | NEXT;PREVIOUS |
| limit | integer | false | 10 | 单页数量 | |
| startTime | integer | false | 开始时间 | ||
| endTime | integer | false | 结束时间 | ||
| symbol | string | false | 交易对 |
限流规则
200/s/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"requestId": 9876543210987654321,
"tenantId": 10001,
"accountId": 900123456789,
"userId": 55667788,
"userGroupId": 3001,
"symbolId": 1,
"symbolGroupId": 10,
"positionType": 2,
"positionSide": 1,
"riskAccountId": 900123456789,
"riskUserId": 55667788,
"riskUserGroupId": 3001,
"success": true,
"positionSize": "0.05200000",
"entryPrice": "6325080000",
"balance": "1523487654321",
"symbol": "BTCUSDT",
"markPrice": "6712345000000",
"marginRate": "01250000",
"createdTime": 1735701234567
}
]
},
"returnCode": 0
}
查询历史止盈止损委托 Edit
/future/trade/v1/entrust/profit-list-history
Parameters
| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
|---|---|---|---|---|---|
| id | integer | false | 1 | 页码 | |
| limit | integer | false | 10 | 单页数量 | |
| startTime | integer | false | 开始时间(默认查询90天前) | ||
| endTime | integer | false | 结束时间 | ||
| symbol | string | false | 交易对 | ||
| direction | string | false | NEXT | 方向 | NEXT;PREVIOUS |
限流规则
200/s/apikey
{
"error": { "code": "", "msg": "" },
"msgInfo": "",
"result": {
"hasNext": false,
"hasPrev": false,
"items": [
{
"profitId": "" // 委托id(Long转string)
}
]
},
"returnCode": 0
}
WebSocket 基本信息 Edit
WebSocket 基础地址: wss://fstream.wexex.io/ws/market(公共频道,无需 listenKey)
请求头
Sec-Websocket-Extensions: permessage-deflate
订阅步骤
- 建立 WebSocket 连接。
- 订阅公共频道的 WebSocket 事件时,发送:
{"method":"SUBSCRIBE","params":["{topic}@{你关注的交易对}"],"id":"{id}"}
推送消息格式
{"topic":"topic","event":"{topic}@{symbol}","data":{}}
心跳检测: 每个客户端连接必须定期发送文本 ping 消息。服务器将回复文本 pong。如果服务器在 30 秒 内未收到 ping,将主动断开连接。
错误码
| 错误码 | 描述 |
|---|---|
| 400 | 请求消息有误,请检查 |
{
"method": "SUBSCRIBE",
"params": [
"{topic1}@{arg1},{arg2}",
"{topic2}@{arg}"
],
"id": "id_field_could_call_whatever_you_want"
}
{
"id": "{id}",
"code": 0,
"msg": ""
}
订单簿管理 Edit
如何正确管理本地订单簿
- 建立连接:
wss://fstream.wexex.io/ws/market,订阅depth_update@btc_usdt。 - 缓存从数据流接收到的事件。
- 获取深度快照:
https://fapi.wexex.io/future/market/v1/public/depth?symbol=btc_usdt&level=500。 - 丢弃快照中
u <= lastUpdateId的任何事件。 - 第一个处理的事件应满足
fu <= lastUpdateId + 1且u >= lastUpdateId + 1。 - 在监听数据流时,每个新事件的
fu应等于前一个事件的u + 1。 - 每个事件中的数据是价格档位的绝对数量。
- 如果数量为
0,删除该价格档位。 - 接收到删除本地订单簿中不存在的价格档位的事件可能发生且是正常的。
注意事项: 由于深度快照对价格档位数量有限制,初始快照之外且没有数量变化的价格档位不会在增量深度流中更新。对于大多数使用场景,500 档深度限制足以理解市场并有效交易。
交易对市场成交记录 Edit
请求格式: trade@{symbol}
示例: trade@btc_usdt
推送频率: 实时
{
"method": "SUBSCRIBE",
"params": ["trade@btc_usdt"],
"id": "test"
}
{
"topic": "trade",
"event": "trade@btc_usdt",
"data": {
"s": "btc_usdt",
"p": "50000",
"a": "0.1",
"m": "BID",
"t": 123124124
}
}
K线 Edit
请求格式: kline@{symbol},{interval}
时间间隔: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
示例: kline@btc_usdt,5m
推送频率: 1000ms
{
"method": "SUBSCRIBE",
"params": ["kline@btc_usdt,5m"],
"id": "test"
}
{
"topic": "kline",
"event": "kline@btc_usdt,5m",
"data": {
"s": "btc_index",
"o": "49000",
"c": "50000",
"h": "0.1",
"l": "0.1",
"a": "0.1",
"v": "0.1",
"ch": "0.21",
"t": 123124124
}
}
聚合行情 Edit
请求格式: agg_ticker@{symbol}
示例: agg_ticker@btc_usdt
推送频率: 1000ms
{
"method": "SUBSCRIBE",
"params": ["agg_ticker@btc_usdt"],
"id": "test"
}
{
"topic": "agg_ticker",
"event": "agg_ticker@btc_usdt",
"data": {
"s": "btc_index",
"o": "49000",
"c": "50000",
"h": "0.1",
"l": "0.1",
"a": "0.1",
"v": "0.1",
"ch": "0.21",
"i": "0.21",
"m": "0.21",
"bp": "0.21",
"ap": "0.21",
"t": 123124124
}
}
指数价格 Edit
请求格式: index_price@{symbol}
示例: index_price@btc_usdt
推送频率: 1000ms
{
"method": "SUBSCRIBE",
"params": ["index_price@btc_usdt"],
"id": "test"
}
{
"topic": "index_price",
"event": "index_price@btc_usdt",
"data": {
"s": "btc_usdt",
"p": "50000",
"t": 123124124
}
}
标记价格 Edit
请求格式: mark_price@{symbol}
示例: mark_price@btc_usdt
推送频率: 1000ms
{
"method": "SUBSCRIBE",
"params": ["mark_price@btc_usdt"],
"id": "test"
}
{
"topic": "mark_price",
"event": "mark_price@btc_usdt",
"data": {
"s": "btc_usdt",
"p": "50000",
"t": 123124124
}
}
增量深度 Edit
请求格式: depth_update@{symbol},{interval}
时间间隔选项: 100, 250, 500, 1000(默认频率: 100ms)
示例: depth_update@btc_usdt,100ms
{
"method": "SUBSCRIBE",
"params": ["depth_update@btc_usdt,100ms"],
"id": "test"
}
{
"topic": "depth_update",
"event": "depth_update@btc_usdt",
"data": {
"s": "btc_usdt",
"pu": 120,
"fu": 121,
"u": 123,
"a": [
["34000", "1.2"],
["34001", "2.3"]
],
"b": [
["32000", "0.2"],
["31000", "0.5"]
],
"t": 123456789
}
}
有限深度 Edit
请求格式: depth@{symbol},{levels},{interval}
档位选项: 5, 10, 20, 50
时间间隔选项: 100, 250, 500, 1000(默认频率: 1000ms)
示例: depth@btc_usdt,50,1000ms
{
"method": "SUBSCRIBE",
"params": ["depth@btc_usdt,50,1000ms"],
"id": "test"
}
{
"topic": "depth",
"event": "depth@btc_usdt,20",
"data": {
"id": "1234",
"s": "btc_index",
"a": [
["50000", "0.1"],
["50001", "0.2"]
],
"b": [
["49999", "0.1"],
["48888", "0.2"]
],
"t": 123456789
}
}
资金费率 Edit
请求格式: fund_rate@{symbol}
示例: fund_rate@btc_usdt
推送频率: 60s
{
"method": "SUBSCRIBE",
"params": ["fund_rate@btc_usdt"],
"id": "test"
}
{
"topic": "fund_rate",
"event": "fund_rate@btc_usdt",
"data": {
"s": "btc_usdt",
"r": "0.01",
"t": 123124124
}
}
通用 WSS 信息 Edit
WebSocket 基础地址: wss://fstream.wexex.io/ws/user(用户私人频道)
请求头
发送建立 WebSocket 连接的 HTTP 请求时,建议添加压缩扩展协议的请求头:
Sec-Websocket-Extensions: permessage-deflate
订阅步骤
- 调用接口获取 ListenKey:
GET https://fapi.wexex.io/future/user/v1/user/listen-key - 建立 WebSocket 后,订阅用户相关事件时发送订阅 JSON
可用 Topic: order, trade, balance, position, notify
心跳检测: 每个客户端连接必须定期发送文本 ping 消息。服务器将回复文本 pong。如果服务器在 30 秒 内未收到 ping,将主动断开连接。
错误码
| 错误码 | 描述 |
|---|---|
| {topic}@invalid_listenkey | ListenKey 过期或无效,请重新申请 |
| Invalid Parameter | 参数错误,请检查 JSON 字符串 |
{
"id": "{id}",
"code": 0,
"msg": "success"
}
余额变化 Edit
Topic: balance
订阅用户账户余额变化事件。
{
"topic": "balance",
"event": "balance@123456",
"data": {
"coin": "usdt",
"underlyingType": 1,
"walletBalance": "123",
"openOrderMarginFrozen": "123",
"isolatedMargin": "213",
"crossedMargin": "0"
}
}
仓位变化 Edit
Topic: position
订阅用户仓位变化事件。
{
"topic": "position",
"event": "position@123456",
"data": {
"symbol": "btc_usdt",
"contractType": "PERPUTUAL",
"positionType": "ISOLATED",
"positionSide": "LONG",
"positionSize": "123",
"closeOrderSize": "100",
"availableCloseSize": "23",
"realizedProfit": "123",
"entryPrice": "213",
"isolatedMargin": "213",
"openOrderMarginFrozen": "123",
"underlyingType": "",
"leverage": 20
}
}
成交记录 Edit
Topic: trade
订阅用户成交记录事件。
{
"topic": "trade",
"event": "trade@123456",
"data": {
"orderId": "12312312",
"clientOrderId": "123456",
"price": "34244",
"quantity": "123",
"marginUnfrozen": "123",
"timestamp": 1731231231,
"symbol": "btc_usdt",
"orderSide": "BUY",
"positionSide": "LONG",
"isMaker": true,
"fee": 0.0002
}
}
用户订单 Edit
Topic: order
订阅用户订单事件。订单状态变化时推送。
{
"topic": "order",
"event": "order@123456",
"data": {
"symbol": "btc_usdt",
"orderId": "1234",
"origQty": "34244",
"avgPrice": "123",
"price": "1111",
"executedQty": "34244",
"orderSide": "BUY",
"timeInForce": "IOC",
"positionSide": "LONG",
"marginFrozen": "123",
"sourceType": "default",
"type": "ORDER",
"state": "FILLED",
"createdTime": 1731231231,
"leverage": 20,
"positionType": "ISOLATED",
"orderType": "MARKET"
}
}
用户订阅消息 Edit
Topic: notify
订阅系统通知事件(强平警告、ADL 等)。
notifyType 值: WARN(警告,即将被强制平仓)、PARTIAL(部分强制平仓)、LIQUIDATION(强制平仓)、ADL(自动减仓)
{
"topic": "notify",
"event": "notify",
"data": {
"symbol": "btc_usdt",
"positionType": "ISOLATED",
"positionSide": "LONG",
"positionSize": "123",
"notifyType": "WARN"
}
}