Astro Perp API
1.0 Basic Info
1.1 General Rules
All Interface response are in JSON format;
All times and timestamps are UNIX/api/third/info/kline times in milliseconds.
For GET requests, append parameters to the URL.
POST requests should be in either application/json or application/x-www-form-urlencoded format, as individually marked for each interface.
For interfaces that require signature verification, please add APIKEY and signature in the request header.
NOTEοΌSome interfaces require verification of the API key and the signature of the request data, indicated in the interface documentation by the Signature Verification Required field. If marked [Yes], the following request headers need to be added]
Required request headers:
APIKEY -- The API key used to call the API (also referred to as app_key in the following)
signature -- The signature made with the app_secret corresponding to the API key for the request parameters.1.2 Access Prerequisites
Access RouteοΌ
Mainnet:
REST: https://api.astros.ag
WebSocket: wss://api.astros.ag/api/market/ws
1.3 Apply APIKEY
The API is divided into three categories: public queries, private queries, and private operations. For the private category interfaces, authentication with API key is required. The platform will randomly generate an app_key and app_secret and provide them to through secure channels.
app_keyοΌ The parameter name in the request is APIKEYοΌ
app_secret: The private key for the request signature. User need to securely store this key and use it to sign the request body.
****1.3.1 Preliminaries
Before you start, please make sure you have done the following:
**Have a Sui wallet:**You will need a SUI Wallet and its private key. Supported private key formats:
Format
Example
Bech32
suiprivkey1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Base64
AKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Registered platform account: Please make sure that your wallet address is registered with Astros (registration is completed by connecting to the wallet for the first time and signing in).
β οΈ Make sure there are no ongoing positions: Please make sure that you have no active/open/closed positions at the time of API Key creation. Meanwhile, please do not perform trading operations on the web page after creating the API Key, as this may result in unanticipated exceptions.
Installation of development environment (optional). If you want to invoke it through code, please install the corresponding dependencies:
Language
Dependency installation command
Node.js
npm install @mysten/suiPython: org.bouncycastle:bcprov-jdk18on:1.77
pip3 install pynacl requestsMaven: org.bouncycastle.bcprov-jdk18on:77
Maven:
org.bouncycastle:bcprov-jdk18on:1.77
1.3.2 Quick Start
Step 1:Generate a Signature
Node.js is an example, for other languages, please refer to the signature code examples.
Step2: Invoke the interface
Take the curl command as an example
Step3: Save the API Secret
β οΈapiSecret will be shown only once, please save it now!
β οΈ Please note that after you create your API, your API KEY will enter a manual review process (this typically takes 1-2 business days). Only after the review process is approved will you be able to trade using your API KEY.
1.3.3 Interface Details
1.3.3.1 Create API Key
Interface Information
Request Parameters
Parameter
Type
Required
Description
address
String
β
SUI Wallet Address
label
String
β
Label name (4-64 characters)
ipWhitelist
String
β
IP whitelist (multiple separated by commas)
timestamp
Long
β
Millisecond timestamp (valid for 60 seconds)
String
String
β
SUI Wallet Signature (Base64)
Original Signature
Request Example
Sample Response
1.3.3.2 View API Key
Interface Information
Request Parameters
Parameter
Type
Required
Description
address
String
β
SUI Wallet Address
Long β timestamp
Long
Long β
Millisecond timestamp (valid for 60 seconds)
signature
String
String β
SUI Wallet Signature (Base64)
Original Signature
Request Example
Sample Response
1.3.3.3 Delete API Key
Interface Information
Request Parameters
Parameter
Types of Parameters
Required
Parameter Description
address
String
β
SUI Wallet Address
apiKey
String
β
API Key to be deleted
timestamp
Long
β
Millisecond timestamp (valid for 60 seconds)
signature
String
String β
SUI wallet signature (Base64)
Original Signature
Request Example
Sample Response
1.3.4 Sample Signature Code
1.3.4.1 Node.js
1.3.4.2 Python
1.3.4.3 Java
1.3.5 Error Code And Cautions
1.3.5.1 Error Code
Error Code
Description of the error code
SIGNATURE_VERIFICATION_FAILURE
Signature verification failed
TIMESTAMP_HAS_EXPIRED
Timestamp has expired (more than 60 seconds).
USER_NOT_EXIST
User does not exist (login and registration required)
API_KEY_COUNT_LIMIT_EXCEEDED
Limit 1 API Key per user
API_KEY_NOT_EXISTS
API Key does not exist
ILLEGAL_PARAMETER
Illegal parameter
1.3.5.2 Cautions
After creating an API Key on β οΈ, please do not perform transaction operations on the Web page, or unintended exceptions may occur!
Currently, there is a limit of 1 API Key per account.
The API Secret is only displayed once at the time of creation and cannot be retrieved. Please delete the current API Key and re-create it.
If you are prompted with USER_NOT_EXIST, please go to https://astros.ag Link your wallet and sign in. before registering with APIKey.After you create your API, your API KEY will enter a manual review process (this typically takes 1-2 business days). Only after the review process is approved will you be able to trade using your API KEY.
1.4 Signature Request
We use the HmacSHA256 signature algorithm with the app_secret as the key to sign the string to be signed. The signature result is encoded in hexadecimal format in all lowercase letters.
Java code γHmacSHA256 signature algorithmγ
β οΈ Special Note: All signatures here are in string format.
Strings to be signed
The string to be signed does not include the data of the signature field;
The data to be signed should be sorted in ascending order by parameter name;
If there are spaces in the parameters, the spaces will also be included in the signature;
For JSON request bodies, convert to a JSON format string for signing;
For URL parameter requests, directly convert to a string for signing
1.5 Response Status
HTTP status code: Use standard HTTP response codes.
200
OK
201
Created
401
Unauthorized
403
Forbidden
404
Not Found
Response body status code: (All codes except 200 indicate errors, and corresponding error descriptions will be returned.)
200
success
400
error
2 REST API
2.0 A Complete Example of a REST Request:
1,Get the URL and set up IP whitelisting, as well as the API endpoint path:
2, Get api keys
app_key
xx
app_secret
xx
3.1,Set request parameters
3.2 Sort the Parameters
3.3 Sign the sorted parameter string format
3.4 Assemble the complete request
4 Return results
2.1 Order Operation γPrivate Operationγ
2.1.1 Create order
method url:/api/third/hot/order/create
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
query
true
string
clientOrderId
query
true
string
price
query
true
string
lever
query
true
integer(int32)
isLong
query
true
boolean
isMarket
query
true
boolean
positionType
3 one-way isloate4 one-way cross
query
true
integer(int32)
quantity
query
true
string
matchType
1 GTC οΌ2 IOC οΌ3 FOK οΌ4 POST_ONLY οΌ
query
true
integer(int32)
timestamp
query
true
string
response param:
cOrderId
string
orderId
integer(int64)
pairName
string
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2002
Required parameter:{param0}
2102
Insufficient balance:{param0}
2122
No hot assets have been frozen
2123
The amount to be frozen must be greater than 0
2124
Failed to process hot account
2201
Insufficient balance available
2301
Quantity cannot be less than {param0}
2302
Quantity cannot be greater than {param0}
2303
Lever cannot be less than {param0}
2304
Lever cannot be greater than {param0}
2305
The quantity of one-way positions cannot be greater than {param0}
2306
Total quantity of this contract positions cannot be greater than {param0}
2307
Contract stops trading
2310
The position margin mode is invalid, please try again.
2312
Decimal places out of limit
2316
10 minutes before delivery:Stop Open/Undo
2317
Order too small
2318
The hot account not support reverse position order!
2325
Position type not supported,Supported types are{param0}
2329
The server is updating, please wait a momentβ¦
2330
No settlement coin found
2331
Market predict price was not obtained
2.1.2 Batch create orders
method url: /api/third/hot/order/batchCreate
request type:POST
data typeοΌapplication/json
need sign:true
detail:
request example:
request param:
orders
order list οΌlimit 20οΌ
true
array
order
clientOrderId
true
string
isLong
true
boolean
isMarket
true
boolean
lever
true
integer
matchType
1 GTC οΌ2 IOC οΌ3 FOK οΌ4 POST_ONLY οΌ
true
integer
pairName
true
string
positionType
3 one-way isloate4 one-way cross
true
integer
price
false
string
quantity
true
string
timestamp
true
string
Accept-Language
zh-CNγen-USγ
header
false
string
APIKEY
header
true
string
signature
header
true
string
response paramγlistγ:
cOrderId
string
orderId
integer(int64)
pairName
string
example:
1,Set request parameters, json body[No spaces.]:
2 Sign the json string, result:
3 Assemble the complete request
4 Return results
Error Code:
2001
Illegal parameter:{param0}
2002
Required parameter:{param0}
2102
Insufficient balance:{param0}
2122
No hot assets have been frozen
2123
The amount to be frozen must be greater than 0
2124
Failed to process hot account
2201
Insufficient balance available
2301
Quantity cannot be less than {param0}
2302
Quantity cannot be greater than {param0}
2303
Lever cannot be less than {param0}
2304
Lever cannot be greater than {param0}
2305
The quantity of one-way positions cannot be greater than {param0}
2306
Total quantity of this contract positions cannot be greater than {param0}
2307
Contract stops trading
2310
The position margin mode is invalid, please try again.
2312
Decimal places out of limit
2316
10 minutes before delivery:Stop Open/Undo
2317
Order too small
2318
The hot account not support reverse position order!
2325
Position type not supported,Supported types are{0}
2329
The server is updating, please wait a momentβ¦
2330
No settlement coin found
2331
Market predict price was not obtained
2.1.3 Cancel order
method url:/api/third/order/cancelEntrust
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
entrustId
query
true
integer(int64)
timestamp
query
true
string
response param:
data
is success
boolean
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2103
Order expired
2125
The order has been revoked
2126
The order has been completely filled
2319
Failed to cancel order:{param0}
2329
The server is updating, please wait a momentβ¦
2.1.4 Cancel order by client order id
method url:/api/third/order/cancelEntrustByCli
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
clientOrderId
query
true
string
timestamp
query
true
string
response param:
data
is success
boolean
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2103
Order expired
2125
The order has been revoked
2126
The order has been completely filled
2319
Failed to cancel order:{param0}
2329
The server is updating, please wait a momentβ¦
2.1.5 Batch Cancel orders
method url:/api/third/order/batchCancelEntrust
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail: cancel one by one till fail then break
request param:
entrustIds
query
true
array
integer
timestamp
query
true
string
response param:
data
is success
boolean
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2103
Order expired
2125
The order has been revoked
2126
The order has been completely filled
2319
Failed to cancel order:{param0}
2329
The server is updating, please wait a momentβ¦
2.1.6 Batch Cancel orders with result
method url:/api/third/order/batchCancelWithRes
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail: cancel one by one , skip fail and continue cancel
request param:
entrustIds
query
true
array
integer
timestamp
query
true
string
response param:(list)
orderId
integer(int64)
clientOrderId
string
pairName
string
isLong
boolean
resultCode
the result code of cancel operation:1 canceled: cancel success from book;2 canceled: already canceled from book;3 canceled: already canceled and settled;4 traded: already fully traded;5 fail: cancel fail;
integer
resultMsg
the detail msg for resultCode
string
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.1.7 Cancel all orders by supported conditions
method url:/api/third/order/cancelAll
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
for all pairs when not specified
query
false
string
isLong
1. for all directions when not specified2. if specified, pairName is required.
query
false
boolean
timestamp
query
true
string
response param:(list)
orderId
integer(int64)
clientOrderId
string
pairName
string
isLong
boolean
resultCode
the result code of cancel operation:1 canceled: cancel success from book;2 canceled: already canceled from book;3 canceled: already canceled and settled;4 traded: already fully traded;5 fail: cancel fail;
integer
resultMsg
the detail msg for resultCode
string
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2002
Required parameter:{param0}
2.1.8 Batch create orders and return the results of each order
method url: /api/third/hot/order/batchCreateWithRes
request type:POST
data typeοΌapplication/json
need sign:true
detail:
request example:
request param:
orders
order list οΌlimit 20οΌ
true
array
order
clientOrderId
true
string
isLong
true
boolean
isMarket
true
boolean
lever
true
integer
matchType
1 GTC οΌ2 IOC οΌ3 FOK οΌ4 POST_ONLY οΌ
true
integer
pairName
true
string
positionType
3 one-way isloate4 one-way cross
true
integer
price
false
string
quantity
true
string
timestamp
true
string
Accept-Language
zh-CNγen-USγ
header
false
string
APIKEY
header
true
string
signature
header
true
string
response paramγlistγ:
cOrderId
string
orderId
integer(int64)
pairName
string
resultCode
integer
resultMsg
string
example:
1,Set request parameters, json body[No spaces.]:
2 Sign the json string, result:
3 Assemble the complete request
4 Return results
Error Code:
2001
Illegal parameter:{param0}
2002
Required parameter:{param0}
2102
Insufficient balance:{param0}
2122
No hot assets have been frozen
2123
The amount to be frozen must be greater than 0
2124
Failed to process hot account
2201
Insufficient balance available
2301
Quantity cannot be less than {param0}
2302
Quantity cannot be greater than {param0}
2303
Lever cannot be less than {param0}
2304
Lever cannot be greater than {param0}
2305
The quantity of one-way positions cannot be greater than {param0}
2306
Total quantity of this contract positions cannot be greater than {param0}
2307
Contract stops trading
2310
The position margin mode is invalid, please try again.
2312
Decimal places out of limit
2316
10 minutes before delivery:Stop Open/Undo
2317
Order too small
2318
The hot account not support reverse position order!
2325
Position type not supported,Supported types are{0}
2329
The server is updating, please wait a momentβ¦
2330
No settlement coin found
2331
Market predict price was not obtained
2.2 Position Operation γprivate operationγ
2.2.1 Add/reduce margin
method url:/api/third/order/callMarginAmount
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
positionId
query
true
integer(int64)
call
add-true;reduce-false
query
true
boolean
marginAmount
query
true
string
timestamp
query
true
string
response param:
data
boolean
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
1001
system error:{param0}
2001
Illegal parameter:{param0}
2002
Required parameter:{param0}
2008
Frequent requests:{param0}
2102
Insufficient balance:{param0}
2104
Position expired
2105
Insufficient position margin
2122
No hot assets have been frozen
2123
The amount to be frozen must be greater than 0
2124
Failed to process hot account
2201
Insufficient balance available
2315
Margin calls are not allowed in this mode
2.2.2 Close position order
method url:/api/third/hot/order/closeOrder
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
contractPositionId
query
true
integer(int64)
price
query
true
string
isMarket
query
true
boolean
quantity
query
true
string
timestamp
query
true
string
clientOrderId
query
false
string
response param:
data
is success
boolean
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2002
Required parameter:{param0}
2104
Position expired
2111
Hot position insufficient available quantity
2122
No hot assets have been frozen
2307
Contract stops trading
2312
Decimal places out of limit
2318
The hot account not support reverse position order!
2329
The server is updating, please wait a momentβ¦
2.2.3 Close postion order by the direction
method url:/api/third/hot/order/closeOrderByDirection
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
query
true
string
price
query
true
string
isMarket
query
true
boolean
quantity
query
true
string
isLong
Ture/false
query
true
boolean
timestamp
query
true
string
matchType
1 GTC οΌ2 IOC οΌ3 FOK οΌ4 POST_ONLY οΌ
query
false
integer(int32)
response param:
data
is success
boolean
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2002
Required parameter:{param0}
2104
Position expired
2111
Hot position insufficient available quantity
2122
No hot assets have been frozen
2307
Contract stops trading
2312
Decimal places out of limit
2318
The hot account not support reverse position order!
2329
The server is updating, please wait a momentβ¦
2.3 Accounting, order, position and tradingγprivate queryγ
2.3.1[Account] Query account balance
method url:/api/third/hot/order/balance
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
symbol
query
true
string
timestamp
query
true
string
response param:
availableAmount
number
coinId
integer(int64)
frozenAmount
number
symbol
string
userId
integer(int64)
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2002
Required parameter:{param0}
2122
No hot assets have been frozen
4001
Invalid address
2.3.2 [order] Query current order list
method url:/api/third/order/selectContractCurrentEntrustList
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
query
true
string
pageNo
query
false
integer(int64)
pageSize
limit 100
query
false
integer(int64)
timestamp
query
true
string
beginTimestamp
query
false
integer(int64)
endTimestamp
query
false
integer(int64)
response param:(list)
amount
number
contractPairId
integer(int64)
contractPositionId
integer(int64)
createTime
string(date-time)
createTimeStamp
integer(int64)
dealAmount
number
dealQuantity
number
depositAmount
margin amount
number
id
integer(int64)
isClose
true/false
boolean
isLong
true/false
boolean
isMarket
true/false
boolean
lever
integer(int32)
matchType
1 GTC οΌ2 IOC οΌ3 FOK οΌ4 POST_ONLY οΌ
integer(int32)
price
number
quantity
number
symbol
string
triggerPrice
number
triggerType
0_noneοΌ1_current priceοΌ2_mark priceοΌ
integer(int32)
isDual
boolean
faceMultiplier
Face value multiplier: the exchange rate of the dual currency currency, the exchange price/transaction price; unmodifiable
number
accountCoinId
integer(int64)
accountCoinSymbol
string
isDelivery
boolean
deliveryTime
string(date-time)
deliveryTimeStamp
integer(int64)
activatePrice
number
callbackRate
number
clientOrderId
string
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.3 [order] Query order
method url:/api/third/order/queryOrder
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail: query current or completed order by id
request param:
entrustId
query
true
integer(int64)
timestamp
query
true
string
response param:
amount
number
contractPairId
integer(int64)
contractPositionId
integer(int64)
createTime
string(date-time)
createTimeStamp
integer(int64)
dealAmount
number
dealQuantity
number
depositAmount
margin amount
number
id
integer(int64)
isClose
true/false
boolean
isLong
true/false
boolean
isMarket
true/false
boolean
lever
integer(int32)
matchType
1 GTC οΌ2 IOC οΌ3 FOK οΌ4 POST_ONLY οΌ
integer(int32)
price
number
quantity
number
symbol
string
triggerPrice
number
triggerType
0_noneοΌ1_current priceοΌ2_mark priceοΌ
integer(int32)
isDual
boolean
faceMultiplier
Face value multiplier: the exchange rate of the dual currency currency, the exchange price/transaction price; unmodifiable
number
accountCoinId
integer(int64)
accountCoinSymbol
string
isDelivery
boolean
deliveryTime
string(date-time)
deliveryTimeStamp
integer(int64)
activatePrice
number
callbackRate
number
clientOrderId
string
status
0 new; 1active; 2 filled; 3 canceled; 4 expired; 5 or 6 cancelingοΌ
integer(int32)
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
code
msg
2.3.4 [Trade] Query match result
method url:/api/third/order/selectContractMatchPairList
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
query
true
string
pageNo
query
false
integer(int64)
pageSize
query
false
integer(int64)
timestamp
query
true
string
matchId
Transaction ID (only orders prior to this matchId are returned, the most recent order is returned by default)
query
false
Long
response param:(list)
amount
number
averagePrice
number
contractPairId
integer(int64)
contractPositionId
integer(int64)
createTime
yyyy-MM-dd HH:mm:ss
string
createTimeStamp
integer(int64)
entrustId
integer(int64)
id
integer(int64)
isClose
true/false
boolean
isLong
true/false
boolean
isMarket
true/false
boolean
isTaker
true _taker; false _maker;
boolean
lever
integer(int32)
positionFee
number
profitLoss
number
quantity
number
symbol
string
tradeFee
number
accountCoinSymbol
string
accountSettleDecimal
integer(int32)
isDelivery
boolean
deliveryTime
string(date-time)
deliveryTimeStamp
integer(int64)
address
string
openingPrice
number
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.5 [position] Query position list
method url:/api/third/hot/order/selectContractPositionList
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
If empty, return all trading pair information
query
false
string
pageNo
query
false
integer(int64)
pageSize
limit 100
query
false
integer(int64)
timestamp
query
true
string
response param:(list)
amount
number
closingQuantity
number
contractPairId
integer(int64)
createTime
string(date-time)
createTimeStamp
integer(int64)
entrustId
integer(int64)
id
integer(int64)
isLong
true/false
boolean
lever
integer(int32)
lossPrice
number
lossType
0_noneοΌ1_current priceοΌ2_mark priceοΌ
integer(int32)
marginAmount
number
marginCallAmount
number
openingPrice
number
positionType
3 one-way isloate4 one-way cross
integer(int32)
profitPrice
number
profitType
0_noneοΌ1_current priceοΌ2_mark priceοΌ
integer(int32)
quantity
number
realizedPnl
number
remainingCloseQuantity
number
restrictPrice
number
status
1 Holding position; 2 Capital fee settlement;
integer(int32)
symbol
string
tariffAmount
number
unrealizedPnl
number
isDual
boolean
faceMultiplier
number
accountCoinId
integer(int64)
accountCoinSymbol
string
accountSettleDecimal
integer(int32)
tradeCoinDecimal
integer(int32)
lights
the auto reduce mark
integer(int32)
isDelivery
boolean
deliveryTime
string(date-time)
deliveryTimeStamp
integer(int64)
settleShowDecimal
integer(int32)
tradeCoinIcon
string
settleCoinIcon
string
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.6 [Trade] Get Trade History
method url:/api/third/v1/trade/fillHistory
request type:GET
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
query
true
string
timestamp
query
true
string
orderId
Order ID
query
false
Long
beginTime
Start timestampUnix timestamp in milliseconds format, e.g. 1725786165000(The maximum time span supported is a week. The default end time is a week if no value is set for the end time. )
query
false
Long
endTime
End timestampUnix timestamp in milliseconds format, e.g. 1725886180000
query
false
Long
idLe
Pagination of data to return records earlier than the requested tradeId
query
false
Long
idGe
Pagination of data to return records newer than the requested tradeId
query
false
Long
isAsc
Sort. The default is false(Desc)
query
false
boolean
limit
Number of results per request. The maximum is 100; The default is 100
query
false
integer
response param:(list)
tradeId
Trade ID
Long
symbol
Trading Pair name e.g. ETH-USD
String
clOrdId
Client Order ID as assigned by the client
Long
isMarket
true/false
Boolean
isClose
true/false
Boolean
isLong
true/false
Boolean
isTaker
true/false
Boolean
fillPrice
Filled price
String
fillQty
Filled quantity
String
fillAmt
Filled amount
String
feeCurrency
Trading fee currency
String
feeRate
Fee rate
String
fillFee
The amount of trading fee
String
fillPnl
Filled profit and loss
String
tradeTime
Trade time, Unix timestamp format in milliseconds, e.g. 1725786173000.
Long
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.7 [Earning] Get Earning Trade History
method url:/api/third/v1/rebates/maker/earnings/trade
request type:GET
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
query
true
string
timestamp
query
true
string
beginTime
Start timestampUnix timestamp in milliseconds format, e.g. 1725786165000(The maximum time span supported is a week. The default end time is a week if no value is set for the end time. )
query
false
Long
endTime
End timestampUnix timestamp in milliseconds format, e.g. 1725886180000
query
false
Long
idLe
Pagination of data to return records earlier than the requested tradeId
query
false
Long
limit
Number of results per request. The maximum is 100; The default is 100
query
false
integer
response param:(list)
tradeId
Trade ID
Long
contractPairId
Trading Pair ID
Long
symbol
Trading Pair name e.g. ETH-USD
String
tradeQty
Trading Quatity
String
takerFee
Taker trade Fee
String
rebateRatio
Rebate rate
String
rebateAmt
Rebate amount
String
tradeTime
Trade time
String
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.8 [Earning] Get Earning Info
method url:/api/third/v1/rebates/maker/earnings
request type:GET
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
timestamp
query
true
string
idLe
Pagination of data to return records earlier than the requested id
query
false
Long
limit
Number of results per request. The maximum is 100; The default is 100
query
false
integer
response param:(list)
id
Rebate record ID
Long
rebateTime
Rebate award send time
String
rebateCoinName
Rebate award coin
String
rebateAmt
Rebate Amout
String
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.9 [order] Query Order History
method url:/api/third/v1/orders/histories
request type:GET
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
timestamp
query
true
string
symbol
Contract Pair name
query
true
long
orderId
Order ID
query
false
integer
clientOrderId
Client Order ID
query
false
string
beginTime
The start time of the time range
query
false
date
endTime
The end time of the time range
query
false
date
idLe
The start id of the id range
query
false
long
idGe
The end id of the id range
query
false
long
sortByAsc
Whether to sort in positive order by id. The default is false
query
false
boolean
limit
Number of results per request. The maximum is 100; The default is 50
query
false
integer
response param:(list)
id
Rebate record ID
Long
rebateTime
Rebate award send time
String
rebateCoinName
Rebate award coin
String
rebateAmt
Rebate Amout
String
param_name
param note
type
schema
id
Entrust record ID
Long
positionType
Position type: 1-Isolated; 2-Hedge (dual); 3-One-way
Integer
userId
User ID
Long
contractPairId
Contract pair ID
Long
isMarket
true: Market order; false: Limit order
Boolean
isClose
true: Close position; false: Open position
Boolean
isLong
true: Long; false: Short
Boolean
price
Order price
String
quantity
Order quantity
String
amount
Order amount
String
lever
Leverage
Integer
depositAmount
Margin amount
String
dealQuantity
Executed quantity
String
dealAmount
Executed amount
String
cancelQuantity
Canceled quantity
String
contractPositionId
Position ID (only available when closing)
Long
openingPrice
Opening price
String
activatePrice
Activation price
String
callbackRate
Callback rate (%)
String
matchType
Order type: 1-GTC; 2-IOC; 3-FOK
Integer
triggerType
Trigger type: 0-None; 1-Last price; 2-Mark price
Integer
triggerPrice
Trigger price (last/mark price)
String
triggeredPrice
Actual trigger price (last/mark price)
String
strategyEntrustId
Strategy entrust record ID
Long
status
Status: 2-Filled; 3-Canceled; 4-Expired
Integer
createTime
Creation time
Date
updateTime
Last update time
Date
takerTradeFeeRate
Taker fee rate (%)
String
makerTradeFeeRate
Maker fee rate (%)
String
clientOrderId
Client order ID
String
clientFrom
Order source: 1-Web; 2-API; 3-Liquidation; 4-Strategy
Integer
sourceChain
Source chain (brand exchange)
String
sourceClient
Source client
String
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.10 [Trade] Get User Leverage
method url:/api/third/v1/trade/getUserLever
request type:GET
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
timestamp
query
true
string
contractPairId
Contract Pair ID
query
true
Long
response param:(object)
contractPairId
Contract Pair ID
Long
positionType
Position type: 1. Individual individual position; 2. Sequential two-way positions; 3. One-way warehouse (warehouse by-warehouse); 4 Full warehouse one-way warehouse (Full warehouse)
Integer
lever
Leverage
Integer
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.11 [account] Query Trade Config list
method url:/api/third/hot/order/tradeConfigList
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
timestamp
query
true
string
response param:(list)
contractPairId
Contract Pair ID
Long
takerFeeRate
taker trade fee
string
makerFeeRate
maker trade fee
Integer
quantityMin
min trade Quantity
string
quantityMax
max trade Quantity
string
amountMin
min trade amount
string
amountMax
max trade amount
string
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.3.12 [order] Query Tariff history
method url:/api/third/hot/order/selectContractTariffList
request type:POST
content typeοΌapplication/x-www-form-urlencoded
need sign:true
detail:
request param:
pairName
If empty, return all trading pair information
query
false
string
pageNo
query
false
integer(int64)
pageSize
limit 100
query
false
integer(int64)
timestamp
query
true
string
response param:(list)
error
Boolean
Is error / Success status
code
Integer
Response code (e.g., 200 for success)
msg
String
Response message
data
Object
Response data
data.pageNo
Long
Current page number
data.pageSize
Long
Page size
data.total
Long
Total records
data.records
Array
Funding rate record list
data.records[].id
Long
Funding rate record ID
data.records[].symbol
String
Trading pair symbol (e.g., BTCUSDT)
data.records[].fundingTime
String
Funding time (Format: yyyy-MM-dd HH:mm:ss)
data.records[].fundingTimeStamp
Long
Funding timestamp (ms)
data.records[].isLong
Boolean
Is long (true: Long; false: Short)
data.records[].openingPrice
BigDecimal
Opening price
data.records[].quantity
BigDecimal
Position quantity / Size
data.records[].settledRate
BigDecimal
Funding rate. If positive, long pays; if negative, long receives.
data.records[].tariffAmount
BigDecimal
Funding fee. Positive for reward; negative for deduction.
data.records[].isDelivery
Boolean
Is delivery contract (true: Yes; false: No)
data.records[].deliveryTime
Date
Delivery time (for delivery contracts only)
data.records[].deliveryTimeStamp
Long
Delivery timestamp (for delivery contracts only)
data.records[].oraclePrice
BigDecimal
Oracle price
data.records[].settleCoinName
String
Settlement currency name
sid
String
Session ID
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
5 Return results
Error Code:
2001
Illegal parameter:{param0}
2.4 Public Query
2.4.1 Query system time
method url:/api/third/info/time
request type:GET
request param:
param_name
param note
type
required
data type
schema
response param:
data
integer(int64)
integer(int64)
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
code
msg
2.4.2 Query current index price
method url:/api/third/info/indexPrice
request type:GET
request param:
pairName
query
true
string
response param:
data
index price
number
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
1004
Data is invalid: {param0}
2.4.3 Query the current mark price
method url:/api/third/info/markPrice
request type:GET
request param:
pairName
query
true
string
response param:
data
mark price
number
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
1004
Data is invalid: {param0}
2.4.4 Query last trade
method url:/api/third/info/trades
request type:GET
request param:
pairName
query
true
string
limit
default 50
query
false
integer(int32)
response param:(Array)
amount
number
contractMatchPairId
integer(int64)
contractPairId
integer(int64)
isLong
boolean
price
number
quantity
number
time
string
timestamp
integer(int64)
pair
string
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
2001
Illegal parameter: {param0}
2.4.5 Get pair list
method url:/api/third/info/pairs
request type:GET
request param:
param_name
param note
type
required
data type
schema
response param:(list)
id
integer(int64)
makerTradeFeeRate
%
number
settleCoinId
integer(int64)
settleCoinName
string
settleDecimal
integer(int32)
symbol
string
takerTradeFeeRate
%
number
tradeCoinId
integer(int64)
tradeCoinName
string
tradeDecimal
integer(int32)
swapCoinId
integer(int64)
swapCoinName
string
isDual
boolean
faceMultiplier
number
isDelivery
boolean
not support
deliveryTime
integer(int64)
not support
deliveryMarketPrice
number
not support
deliveryStatus
integer(int32)
not support
pair
string
minCount
number
maxCount
number
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
code
msg
2.4.6 query the orderbook depth
method url:/api/third/info/depth
request type:GET
request param:
pairName
query
true
string
limit
default 20 , max 50
query
false
integer(int32)
response param:
asks
array
bids
array
asksοΌ
price
string
quantity
string
bidsοΌ
price
string
quantity
string
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
2001
Illegal parameter:{param0}
2.4.7 Kline
method url:/api/third/info/kline
request type:GET
detail: Get K-line data (in reverse chronological order, from back to front)
request param:
pairName
query
true
string
period
"4HOUR""3MIN""8HOUR""12HOUR""1MONTH""15MIN""1MIN""5MIN""6HOUR""1WEEK""1DAY""3DAY""1HOUR""30MIN""2HOURβ
query
true
string
endTime
query
false
integer(int64)
limit
default 20οΌmax 100
query
false
integer(int32)
response param:(Array)
period
string
time
integer(int64)
contractPairId
integer(int64)
open
number
close
number
low
number
hight
number
count
integer(int32)
quantity
number
amount
number
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
2001
Illegal parameter:{param0}
2.4.8 Get Historical Funding Rates
method url:/api/third/v1/market/funding/history
request type:GET
request param:
pairName
e.g. ETH-USD
query
true
string
beginTime
Start timestampUnix timestamp in milliseconds format, e.g. 1726041982000(The maximum time span supported is a week. The default end time is a week if no value is set for the end time. )
query
false
Long
endTime
End timestampUnix timestamp in milliseconds format, e.g. 1726473982000
query
false
Long
idLe
Requests the content on the page before this ID (older data)
query
false
Long
limit
Number of results per request. The maximum is 100; The default is 100
query
false
Long
response param:
list
array
Object
>id
number
>symbol
Trading pair name
String
>fundingRate
Funding rate
String
>fundingRateTime
Settlement time
String
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
1004
Data is invalid: {param0}
2.4.9 Get Current Funding Rate
method url:/api/third/v1/market/funding/current
request type:GET
request param:
pairName
e.g. ETH-USD
query
true
string
response param:
>symbol
Trading pair name
String
>fundingRate
Funding rate
String
nextSettlementTime
next settlement timestamp
Long
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
1004
Data is invalid: {param0}
2.4.10 query 24hr ticker
method url:/api/third/info/ticker/24hr
request type:GET
request param:
pairName
e.g. ETH-USD
query
true
string
response param:
period
string
time
integer(int64)
contractPairId
integer(int64)
open
number
close
number
low
number
hight
number
count
integer(int32)
quantity
number
amount
number
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
2.4.11 get open interest
method url:/api/third/info/oi
request type:GET
request param:
pairName
e.g. ETH-USD
query
true
string
response param:
>symbol
Trading pair name
String
>amount
open interest volume
float
>count
open interest count
integer
contractPairId
pair id
integer
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
2.5 Trade Operation γprivate operationγ
2.5.1 Set User Lever
method url:/api/third/v1/trade/setUserLever
request type:POST
request param:
contractPairId
Contract Pair ID
operate
true
Long
positionType
Position type: 1. Individual individual position; 2. Sequential two-way positions; 3. One-way warehouse (warehouse by-warehouse); 4 Full warehouse one-way warehouse (Full warehouse)
operate
true
Integer
lever
Leverage
operate
true
Integer
response param:
true
example:
1,Set request parameters, query params:
2 Assemble the complete request
3 Return results
Error Code:
1004
Data is invalid: {param0}
3 WebSocket Subscription
All WebSocket subscription interfaces require app_key signature authentication.
3.1 Events of Subscription
api_entrust
api_entrust_res
api_position
api_position_res
api_kline
api_kline_res
api_depth
api_depth_res
api_trade
api_trade_res
api_account
api_account_res
api_spot_deals
api_spot_deals_res
api_deal_user
api_deal_user_res
3.2 Subscription
3.2.1 Basic parameters for subscription requests
Basic parameters for subscription requests, with the same parameters for each subscription event.
Request paramοΌ
method
String
β
SUBSCRIBE/UNSUBSCRIBE
event
String
β
apiKey
String
β
timestamp
Long
β
signature
String
β
Response paramοΌ
Basic parameters for subscription request responses.
success
Boolean
β
true,false
msg
String
β
response message
method
String
β
SUBSCRIBE/UNSUBSCRIBE
event
String
β
3.2.2 Subscription Signature Example
Taking the accounting interface as an example:
1 Get current timestamp: βtimestampβ: 1657157345159
2 Sign the string format of the timestamp
app_key
xx
app_secret
xx
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
3.3 Subscription Detailed Interface and Push Data
3.3.1 account
Request append param
symbol
String
β
sample
Receive data:
data
Object
accoint info
event
String
api_account
success
Boolean
true,false
Data object:
availableAmount
String
frozenAmount
String
logId
Long
Flow ID: determines the version. If the logId is small, the history balance is displayed
operateAmount
String
symbol
String
coinId
Long
Example:
1 Get current timestamp(ms):
2 Sign the string format of the timestamp, result:
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
4γ Returns after a successful subscription
5γ Server websocket push data.
3.3.2 order data
Request append param
pair
String
β
sample
Receive data:
data
Object
Entrust order info
event
String
api_entrust
success
Boolean
true,false
Data object:
currentEntrustId
Long
order id
changeType
String
ENTRUSTοΌ NEWοΌTRADEοΌ CANCELED
dealQuantity
String
direction
String
LONG/SHORT
lever
Integer
price
String
quantity
String
symbol
String
nowDealQuantity
String
isClose
Boolean
true/false
contractPairId
Long
dealAmount
String
matchType
Integer
1 GTC οΌ2 IOCοΌ3 FOK οΌ4 POST_ONLY οΌ
clientOrderId
String
isMarket
Boolean
true/false
feeCoin
String
fee currency (when the changeType is TRADE)
feeAmt
String
fee amount (when the changeType is TRADE)
isTaker
Boolean
true/false (when the changeType is TRADE)
Example:
1 Get current timestamp(ms):
2 Sign the string format of the timestamp, result:
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
4γ Returns after a successful subscription
5γ Server websocket push data.
3.3.3 position data
Request append param
pair
String
β
sample
Receive data:
data
Object
position info
event
String
api_position
success
Boolean
true,false
data object:
changeType
String
NEW/ INCREASE/ CLOSE/LIQUIDATE/ REDUCE;
currentQuantity
String
direction
String
LONG/SHORT
operateQuantity
String
positionId
Long
ID
symbol
String
canClosedQuantity
String
contractPairId
Long
positionType
Integer
3 one-way isloate4 one-way cross
openingPrice
String
marginAmount
String
Initial margin amount
marginCallAmount
String
Example:
1 Get current timestamp(ms):
2 Sign the string format of the timestamp, result:
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
4γ Returns after a successful subscription
5γ Server websocket push data.
3.3.4 kline data
Request append param
pair
String
β
period
String
β
1MIN,3MIN,5MIN,15MIN,30MIN,1HOUR,4HOUR,8HOUR,12HOUR,1DAY
sample
Receive data:
data
Object
kline info
event
String
api_kline
success
Boolean
true,false
data object:
amount
BigDecimal
deal amount
close
BigDecimal
colse price
count
Integer
deal count numbers
hight
BigDecimal
high price
low
BigDecimal
Low price
open
BigDecimal
Open price
period
String
quantity
BigDecimal
Deal qutities
time
Long
Milliseconds: Owning time of the K-line post (start time)
contractPairId
Long
pair ID
Example:
1 Get current timestamp(ms):
2 Sign the string format of the timestamp, result:
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
4γ Returns after a successful subscription
5γ Server websocket push data.
3.3.5 order book
Request append param
pair
String
β
sample
Receive data:
data
Object
order book info
event
String
api_depth
success
Boolean
true,false
data object:
asks
List
bids
List
asks:
price
String
quantity
String
bids:
price
String
quantity
String
Example:
1 Get current timestamp(ms):
2 Sign the string format of the timestamp, result:
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
4γ Returns after a successful subscription
5γ Server websocket push data.
3.3.6 trade data
Request append param
pair
String
β
period
String
β
1MIN,3MIN,5MIN,15MIN,30MIN,1HOUR,4HOUR,8HOUR,12HOUR,1DAY
sample
Receive data:
data
Object[] Arrray list
trade info
event
String
api_trade
success
Boolean
true,false
data object:
contractMatchPairId
long
ID
pair
String
price
BigDecimal
quantity
BigDecimal
amount
BigDecimal
isLong
Boolean
true/false
time
String
timestamp
Long
contractPairId
Long
pair ID
Example:
1 Get current timestamp(ms):
2 Sign the string format of the timestamp, result:
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
4γ Returns after a successful subscription
5γ Server websocket push data.
3.3.7 trade current
Request append param
pair
String
β
sample
Receive data:
data
Object[] Arrray list
event
String
api_spot_deals
success
Boolean
true,false
data object:
contractMatchPairId
long
id
pair
String
price
BigDecimal
quantity
BigDecimal
amount
BigDecimal
isLong
Boolean
true/false
time
String
timestamp
Long
contractPairId
Long
Example:
1 Get current timestamp(ms):
2 Sign the string format of the timestamp, result:
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
4γ Returns after a successful subscription
5γ Server websocket push data.
3.3.8 user trade immediately
Request append param
pair
String
β
sample
Receive data:
data
Object
event
String
api_deal_user
success
Boolean
true,false
data: list
currentEntrustId
long
Order ID
clientOrderId
Long
Client Order ID as assigned by the client
userId
String
isClose
Boolean
true/false
symbol
String
contractPairId
Long
direction
String
dealQuantity
String
dealAmount
String
matchType
Integer
1 GTC οΌ2 IOCοΌ3 FOK οΌ4 POST_ONLY οΌ
matchId
Long
dealPrice
String
dealTime
String
isTaker
Boolean
true taker; false maker;
feeCoin
String
fee currency
feeAmt
String
fee amount
Example:
1 Get current timestamp(ms):
2 Sign the string format of the timestamp, result:
3γ Assembling parameters, including basic parameters for subscription and custom additional parameters for the interface.
4γ Returns after a successful subscription
5γ Server websocket push data.
selectContractPositionList
selectContractPositionList
/api/third/info/pairs
example:
1,Set request parameters, query params:
2 Sort the Parameters
3 Sign the sorted parameter string format, result:
4 Assemble the complete request
Last updated