HTX Spot Skill
Spot trading on HTX using authenticated API endpoints. Requires API key and secret key for certain endpoints. Return the result in JSON format.
Quick Reference
Endpoint Description Required Optional Authentication
/v2/market-status (GET) Get market status None None No
/v2/settings/common/symbols (GET) Get all supported trading symbols None symbols, ts No
/v2/settings/common/currencies (GET) Get all supported currencies None ts No
/v2/settings/common/currencys (GET) Get currency settings None ts No
/v2/settings/common/market-symbols (GET) Get market symbols setting symbols None No
/v2/settings/common/chains (GET) Get chains information None show-desc, ts No
/v2/reference/currencies (GET) Currency & chains None authorizedUser No
/v1/common/timestamp (GET) Get current timestamp None None No
/market/history/kline (GET) Get kline/candlestick data symbol, period size No
/market/detail/merged (GET) Get market details merged symbol None No
/market/tickers (GET) Get tickers for all pairs None None No
/market/depth (GET) Get market depth symbol depth, type No
/market/trade (GET) Get most recent trades symbol None No
/market/history/trade (GET) Get historical trades symbol size No
/market/detail (GET) Get 24hr market summary symbol None No
/v1/account/accounts (GET) Get all accounts None None Yes
/v1/account/accounts/{account-id}/balance (GET) Get account balance account-id None Yes
/v1/account/asset-valuation (GET) Get asset valuation accountType valuationCurrency, subUid Yes
/v1/account/ledger (GET) Get account ledger accountId currency, transactTypes, startTime, endTime, sort, limit, fromId Yes
/v1/order/orders/place (POST) Place a new order account-id, symbol, type amount, price, source, client-order-id, self-match-prevent, stop-price, operator Yes
/v1/order/batch-orders (POST) Place a batch of orders None Body: array of orders Yes
/v1/order/orders/{order-id}/submitcancel (POST) Cancel an order order-id None Yes
/v1/order/orders/submitCancelClientOrder (POST) Cancel order by client order ID client-order-id None Yes
/v1/order/orders/batchcancel (POST) Cancel multiple orders order-ids None Yes
/v1/order/orders/batchCancelOpenOrders (POST) Cancel all open orders account-id symbol, side, size Yes
/v1/order/openOrders (GET) Get all open orders None account-id, symbol, side, size, from, direct Yes
/v1/order/orders/{order-id} (GET) Get order detail order-id None Yes
/v1/order/orders/getClientOrder (GET) Get order detail by client order ID clientOrderId None Yes
/v1/order/orders/{order-id}/matchresults (GET) Get order match results order-id None Yes
/v1/order/orders (GET) Search past orders None symbol, types, start-date, end-date, states, from, direct, size Yes
/v1/order/history (GET) Search historical orders (48h) None symbol, start-time, end-time, direct, size Yes
/v1/order/matchresults (GET) Search match results None symbol, types, start-date, end-date, from, direct, size Yes
/v2/reference/transact-fee-rate (GET) Get current fee rate symbols None Yes
Parameters
Common Parameters
-
symbol: Trading symbol (e.g., btcusdt, ethusdt)
-
symbols: Comma-separated list of symbols
-
account-id: Account ID (can be obtained from /v1/account/accounts)
-
type: Order type
-
amount: Order amount (for buy market orders, amount is in quote currency; for others, in base currency)
-
price: Order price (required for limit orders)
-
source: Order source (default: spot-api)
-
client-order-id: Client-defined order ID (max length: 64)
-
self-match-prevent: Self-match prevention (0=disabled, 1=enabled)
-
stop-price: Stop price for stop-limit orders
-
operator: Operator for stop orders (gte, lte)
-
order-id: Order ID
-
period: Kline period/interval
-
size: Number of records to return
-
depth: Depth level (e.g., step0, step1, step2, etc.)
-
side: Order side (buy, sell)
-
states: Order states (comma-separated)
-
types: Order types (comma-separated)
-
start-date: Start date (format: yyyy-mm-dd)
-
end-date: End date (format: yyyy-mm-dd)
-
start-time: Start time (unix timestamp in milliseconds)
-
end-time: End time (unix timestamp in milliseconds)
-
from: Start ID for pagination
-
direct: Direction for pagination (prev, next)
-
accountType: Account type for asset valuation
-
valuationCurrency: Currency for valuation (e.g., BTC, USDT, CNY)
-
transactTypes: Transaction types (comma-separated)
-
limit: Number of records to return
-
fromId: Starting ID for query
Enums
-
period: 1min | 5min | 15min | 30min | 60min | 4hour | 1day | 1mon | 1week | 1year
-
type (order): buy-market | sell-market | buy-limit | sell-limit | buy-ioc | sell-ioc | buy-limit-maker | sell-limit-maker | buy-stop-limit | sell-stop-limit | buy-limit-fok | sell-limit-fok | buy-stop-limit-fok | sell-stop-limit-fok
-
side: buy | sell
-
states: submitted | partial-filled | partial-canceled | filled | canceled
-
operator: gte | lte
-
accountType: spot | margin | otc | point | super-margin | investment | borrow
-
transactTypes: trade | etf | transact-fee | deduction | transfer | credit | liquidation | interest | deposit-withdraw | withdraw-fee | exchange | other-types
-
depth (step): step0 | step1 | step2 | step3 | step4 | step5
Authentication
For endpoints that require authentication, you will need to provide HTX API credentials. Required credentials:
-
apiKey: Your HTX API key (for X-MBX-APIKEY header)
-
secretKey: Your HTX API secret (for signing)
Base URLs:
-
Mainnet: https://api.huobi.pro
-
Mainnet (AWS): https://api-aws.huobi.pro
Security
Share Credentials
Users can provide HTX API credentials by sending a file where the content is in the following format:
fe45419a...xyz secretabc...key
Never Display Full Secrets
When showing credentials to users:
-
API Key: Show first 5 + last 4 characters: fe45419a...xyz
-
Secret Key: Always mask, show only last 5: ***...key1
Example response when asked for credentials: Account: main API Key: fe45419a...xyz Secret: ***...key1 Environment: Mainnet
Listing Accounts
When listing accounts, show names and environment only — never keys: HTX Accounts:
-
main (Mainnet)
-
trading (Mainnet - AWS)
Transactions in Mainnet
When performing transactions in mainnet, always confirm with the user before proceeding by asking them to write "CONFIRM" to proceed.
HTX Accounts
main
-
API Key: your_mainnet_api_key
-
Secret: your_mainnet_secret
-
Environment: https://api.huobi.pro
-
Description: Primary trading account
trading
-
API Key: your_aws_api_key
-
Secret: your_aws_secret
-
Environment: https://api-aws.huobi.pro
-
Description: AWS optimized trading
TOOLS.md Structure
HTX Accounts
main
- API Key: fe45419a...xyz
- Secret: secretabc...key
- Environment: https://api.huobi.pro
- Description: Primary trading account
trading
- API Key: test456...abc
- Secret: testsecret...xyz
- Environment: https://api-aws.huobi.pro
- Description: AWS optimized trading
Agent Behavior
-
Credentials requested: Mask secrets (show last 5 chars only)
-
Listing accounts: Show names and environment, never keys
-
Account selection: Ask if ambiguous, default to main
-
When doing a transaction in mainnet, confirm with user before by asking to write "CONFIRM" to proceed
-
New credentials: Prompt for name, environment
Adding New Accounts
When user provides new credentials:
-
Ask for account name
-
Ask: Which environment (Mainnet or Mainnet-AWS)
-
Store in TOOLS.md with masked display confirmation
Signing Requests
All authenticated endpoints require HMAC SHA256 signature:
-
Create the pre-sign string in the following order:
-
HTTP method (GET/POST) + "\n"
-
API host (e.g., api.huobi.pro) + "\n"
-
API path (e.g., /v1/order/orders) + "\n"
-
Sorted query string parameters
-
Append required parameters to all authenticated requests:
-
AccessKeyId: Your API key
-
SignatureMethod: HmacSHA256
-
SignatureVersion: 2
-
Timestamp: UTC timestamp in format yyyy-MM-ddTHH:mm:ss
-
Sign the pre-sign string with secretKey using HMAC SHA256
-
Append signature to query string as Signature parameter
-
For POST requests, also include signature in the URL query string
Example pre-sign string:
POST\n api.huobi.pro\n /v1/order/orders/place\n AccessKeyId=xxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15:19:30
User Agent Header
Include User-Agent header with the following string: htx-spot/1.0.0 (Skill)
Important Notes
-
All timestamps are in Unix milliseconds
-
Symbol names should be lowercase (e.g., btcusdt, not BTCUSDT)
-
For market buy orders, the amount parameter represents the quote currency amount
-
For all other order types, amount represents the base currency amount
-
Account ID must be obtained from /v1/account/accounts endpoint before trading
-
Rate limits apply - see HTX API documentation for details
-
Signature must be calculated for every authenticated request
-
Timestamp in signature must be within 1 minute of server time