Perpetual Contract Trading
API for perpetual contract trading by regular users
Preparation for Integration
Trading Pairs
A trading pair consists of a base currency and a quote currency. For example, in the trading pair btc_usdt, btc is the base currency, and usdt is the quote currency.
Applying for an API Key
To apply for an API Key, visit the Hibt official website via mobile. Navigate to the personal settings page, locate API management, and submit your application. Upon successful creation, ensure you securely save the following information:
Access Key: The access key for API requests.
Secret Key: The secret key used for signature authentication and encryption (visible only during the application process).
Password: Required for managing APIs.
API Authentication
Public endpoints provide access to basic information and market data. These endpoints can be accessed without authentication.
Private endpoints are used for trading and account management. Each private request must be signed using your API Secret Key for verification.
REST API
https://fapi.hibt0.com/open-api
Signature Authentication
Private endpoints (used for trading and account management) require encryption with your API Key to validate that parameters or values have not been altered during transmission. Each API Key must have the appropriate permissions to access corresponding endpoints. When creating a new API Key, assign the required permissions. Before using an endpoint, ensure your API Key has the necessary permissions.
A valid request must include the following components:
Request URL: Example
https://api.hibt0.com/open-api/v2/order/open.Header - Access Key (
X-ACCESS-KEY): Your API Key's Access Key, as obtained during API Key creation.Header - Body Signature (
X-SIGNATURE): Encrypted data generated by signing the request body with your Secret Key.Timestamp (
timestamp): A field in the POST request body or GET request URL parameters representing the current millisecond timestamp. This is required for signing.Required and Optional Parameters: Each method specifies the required and optional parameters for the API call. Check the method documentation for details.
Signature: An encrypted value ensuring the integrity and authenticity of the request. **For your API Key's security, signatures expire after 5 minutes.
Mandatory Signature Parameter: Any authenticated request must include the timestamp parameter for signature generation (use the latest server time from the
v2/server/timeendpoint).
Encryption Method
Body Content of the Open Position POST Request
Sort the parameters in ASCII order.
amount=0.01&customID=11111&isSetSl=true&isSetSp=true&leverage=10&price=2660&side=1&slPrice=2450&spPrice=2770&symbol=btc_usdt×tamp=1724916869475&triggerType=2&type=1
Encrypt the sorted request parameters using HMAC SHA256 with the secretKey to obtain the result.
9543936a83c8b4fd0aae02a6e6fa272dc8ebc95b871f620eb23ae1a6dadffee7
Note: If a parameter field contains an array, convert it to a JSON string separately and then append it to the signature string.
Constructing HTTP Requests
Use X-ACCESS-KEY to store the access key information and pass it as a parameter in the header.Use X-SIGNATURE to store the generated signature information and pass it as a parameter in the header.Use X-TIMESTAMP to store the request timestamp and pass it as a parameter in the header.
Request Methods
Currently, there are only two methods: GET and POST.
GET Requests: All parameters are included in the URL path.
POST Requests: All parameters are sent in JSON format within the request body.
Response Format
Common Error Codes
21XXXX (Parameter Errors)
22XXXX (Business Errors)
210001
Invalid parameters
210004
Incorrect take-profit price
210005
Incorrect stop-loss price
210007
Only data from the past 3 months is allowed
210008
Only data within a 7-day range is allowed
210009
Only data within a 3-month range is allowed
210010
Invalid trading pair
210011
endTime exceeds the current time
210116
Invalid user
210117
Asset balance not found
220001
Data not found
220002
Timestamp expired
220003
X-ACCESS-KEY not provided
220004
API key authentication failed
220005
X-SIGNATURE not provided
220007
Access Key expired
220008
Signature verification failed
220011
Authorization expired
220012
IP address not in whitelist
220013
No query permissions
220014
No trading permissions
220015
WebSocket: Invalid event type
220017
Too many requests
210019
Unauthorized
210020
No trading or query permissions
210021
Invalid Access Key
Basic Information API
Server Time Retrieval
HTTP Request
GET /v2/server/time
Authentication: No
Request Parameters
None
Response Example
Retrieve All Trading Pairs
HTTP Request
GET /v2/market/symbols
Request Parameters: None
Response Example
Retrieve Ticker Data for Trading Pairs
HTTP Request
GET /v2/market/tickers
Request Parameters
symbol
Trading Pair
No (returns all if not provided)
string
Response Example
Retrieve K-Line Data for a Specific Trading Pair
HTTP Request
GET /v2/market/candle
Request Parameters
symbol
Trading Pair
Yes
string
period
Data time granularity (interval for each candle): M1, M5, M15, M30, H1, H4, H6, D1
Yes
string
start
Start timestamp for query, in milliseconds
No
int
end
End timestamp for query, in milliseconds
No
int
count
Number of K-Line data points to return [1, 500]. Default is 200, max is 500. If start and end are provided, the actual returned count depends on the time range.
No
int
Response Example
Retrieve Ticker Prices for Trading Pairs
HTTP Request
GET /v2/market/ticker/price
Request Parameters
symbol
Trading Pair
No (returns all pairs if omitted)
string
Response Example
Retrieve Market Depth for a Trading Pair
HTTP Request
GET /v2/market/depth
Request Parameters
symbol
Trading Pair
Yes
string
limit
Depth levels (5, 10, 20, 50, 100, 200)
No
int
Response Example
Retrieve Latest Trades for a Trading Pair
HTTP Request
GET /v2/market/deals
Request Parameters
symbol
Trading Pair
Yes
string
Response Example
Query Trading Pair Mark Price
HTTP Request
GET /v2/market/index
Request Parameters
symbol
Trading Pair
No (returns all pairs if not provided)
string
Response Example
Query Funding Rate
HTTP Request
GET /v2/market/fundingRate
Request Parameters
symbol
Trading Pair
Yes
string
startTime
Start timestamp in ms (only supports a 3-month range)
No
int64
endTime
End timestamp
No
int64
limit
Number of records (default 100, max 1000)
No
int
Response Example
Query Risk Limit
HTTP Request
GET /v2/market/riskLimit
Request Parameters
symbol
Trading Pair
Yes
string
Response Example
Query Latest Contract Market Data
HTTP Request
GET /v2/market/contracts
Request Parameters
symbol
Trading Pair
No (returns all if omitted)
string
Response Example
Query Contract Trading Specifications
HTTP Request
GET /v2/market/contractSpecifications
Request Parameters None
Response Example
Query Contract Order Book
HTTP Request
GET /v2/market/orderBook
Request Parameters
depth
Level 1-100
No
int
symbol
Trading pair
No
string
Response Example
Trading API
Open Position
HTTP Request
POST /v2/order/open
Authentication Required Yes
Request Parameters
Response Example
Batch Opening Positions
HTTP Request
POST /v2/order/batchOpen
Authentication Required Yes
Request Parameters
Response Example
Cancel Order
HTTP Request
POST /v2/order/cancel
Authentication Required Yes
Request Parameters
Response Example
Batch Cancel Orders
HTTP Request
POST /v2/order/batchCancel
Authentication Required Yes
Request Parameters
Response Example
Close Position
HTTP Request
POST /v2/order/close
Authentication Required Yes
Request Parameters
Response Example
Close All Positions
HTTP Request
POST /v2/order/closeAll
Authentication Required Yes
Request Parameters
Response Example
Query Unfinished Orders
HTTP Request
GET /v2/order/unFinish
Authentication Required Yes
Request Parameters
symbol
Trading pair
No
string
orderID
Order ID // Either orderID, customID, or positionID must be provided, or none at all
No
string
customID
Custom order ID
No
string
positionID
Position ID
No
string
timestamp
Current timestamp in milliseconds
Yes
Response Example
Query Details of Completed Orders
HTTP Request
GET /v2/order/finishedInfo
Authentication Required Yes
Request Parameters
symbol
Trading pair
string
orderID
Order ID // Either orderID, customID, or positionID must be provided
string
customID
Custom order ID
string
positionID
Position ID
string
timestamp
Current timestamp in milliseconds
number
Response Example
Query History of Completed Orders
HTTP Request
GET /v2/order/finished
Authentication Required Yes
Request Parameters
symbol
Trading pair
string
startTime
Start time (timestamp)
int
endTime
End time (timestamp)
int
pageIndex
Page number for pagination
int
pageSize
Number of items per page, max 50
int
timestamp
Current timestamp in milliseconds
number
Response Example
Add Conditional Order
HTTP Request
POST /v2/entrust/add
Authentication Required Yes
Request Parameters
Response Example
Cancel Conditional Order
HTTP Request
POST /v2/entrust/cancel
Authentication Required Yes
Request Parameters
Response Example
Retrieve Unfinished Conditional Orders
HTTP Request
GET /v2/entrust/unFinish
Authentication Required Yes
Request Parameters
symbol
Trading pair
string
timestamp
Current timestamp
number
Response Example
Retrieve Completed Conditional Orders List
HTTP Request
GET /v2/entrust/finished
Authentication Required Yes
Request Parameters
symbol
Trading pair
string
pageIndex
Pagination index
int
pageSize
Number of entries (maximum 50)
int
timestamp
Current timestamp
number
Response Example
Account Interface
Retrieve Account Balance
HTTP Request
GET /v2/account/balance
Authentication Required Yes
Request Parameters None
Response Example
Adjust Opening Leverage
HTTP Request
POST /v2/account/setLeverage
Authentication Required Yes
Request Parameters
Response Example
Get User Positions
HTTP Request
GET /v2/account/position
Authentication Required Yes
Request Parameters
symbol
Trading pair
No
string
positionID
Position ID
No
string
timestamp
Current timestamp in ms
Yes
Response Example
Get Account Trade History
HTTP Request
GET /v2/account/order
Authentication Required Yes
Request Parameters
symbol
Trading pair
Yes
string
startTime
Start time in seconds
No
int64
endTime
End time in seconds
No
int64
limit
Number of entries (default: 500, max: 1000)
No
int
timestamp
Current timestamp in ms
Yes
Response Example
Get Account Balance Record
HTTP Request
GET /v2/account/balanceRecord
Authentication Required Yes
Request Parameters
symbol
Trading pair
No
string
startTime
Start time in ms (interval: 30 days)
No
int64
endTime
End time in ms (interval: 30 days)
No
int64
event
Event type: 1: Deposit, 2: Deduction, 3: Transfer In, 4: Transfer Out, 9: Funding Fee, 201: Open Long, 202: Open Short, 204: Close Long, 205: Close Short, 206: Forced Liquidation
No
int
limit
Number of entries (default: 500, max: 1000)
No
int
timestamp
Current timestamp
Yes
Response Example
Get User Forced Liquidation History
HTTP Request
GET /v2/account/orderForced
Authentication Required Yes
Request Parameters
symbol
Trading pair
No
string
startTime
Start time in ms (start and end interval must be within 7 days)
No
int64
endTime
End time in ms
No
int64
action
Forced liquidation type: 4 - Forced Liquidation, 5 - FOK Liquidation, 6 - ADL (Auto-Deleveraging), 9 - Bankruptcy
No
int
limit
Number of entries (default: 500, max: 1000)
No
int
timestamp
Current timestamp
Yes
Response Example
Contract WebSocket API
Request URL Example: wss://fapi.hibt0.com/v2/ws
API Authentication
For subscriptions that require authentication, send the authentication message first.
ignature: Simply sign the timestamp string.
Subscribe to Topic
{"event":"sub", "topic":"Topic Content"}
Subscribe to Market Depth
Supported market depth topics: 5deep, 10deep, 20deep
Request JSON: {"event":"sub","topic":"btc_usdt.5deep"}
Response Example
Subscribe to Ticker
Request JSON: {"event":"sub","topic":"btc_usdt.ticker"}
Response Example
Subscribe to Index
Request JSON: {"event":"sub","topic":"btc_usdt.index"}
Response Example
Subscribe to Latest Trades
Request JSON: {"event":"sub","topic":"btc_usdt.trade"}
Response Example
Subscribe to K-Line
Request JSON: {"event":"sub","topic":"btc_usdt.candle.M1"}
Supported Time Intervals:
Response Example
Subscribe to Plan Order Trigger Push (Authentication Required)
Request JSON: {"event":"sub","topic":"user.entrust"}
Response Example
Subscribe to Position Change (Authentication Required)
Request JSON: {"event":"sub","topic":"user.position"}
Response Example
Subscribe to Order Execution Notifications (Authentication Required)
Response Example
Subscribe to Account Balance Changes (Authentication Required)
Request JSON: {"event":"sub","topic":"user.balance"}
Response Example
Last updated