spot

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

HTX Spot Skill

HTX 现货Skill

Spot trading on HTX using authenticated API endpoints. Requires API key and secret key for certain endpoints. Return the result in JSON format.
通过经过鉴权的API端点在HTX进行现货交易,部分端点需要提供API key和secret key,返回结果为JSON格式。

Quick Reference

快速参考

Reference Data Endpoints

参考数据接口

EndpointDescriptionRequiredOptionalAuthentication
/v2/market-status
Returns current market status with enum values including: 1=normal, 2=halted, 3=cancel-onlyNoneNoneNo
/v2/settings/common/symbols
Returns all supported trading symbols with detailed configuration including state, precision, and trading statusNonetsNo
/v2/settings/common/currencies
Returns all supported currencies with their configuration and display namesNonetsNo
/v1/settings/common/symbols
Returns symbol settings with pricing and trading precision informationNoneNoneNo
/v1/settings/common/market-symbols
Returns market symbol configuration for spot tradingNoneNoneNo
/v2/settings/common/chains
Returns blockchain chain information including chain names and configurationNoneNoneNo
/v2/reference/currencies
Returns currency and blockchain chain reference dataNoneNoneNo
/v1/common/timestamp
Returns current server timestamp in millisecondsNoneNoneNo
Endpoint描述必填参数可选参数是否需要鉴权
/v2/market-status
返回当前市场状态,枚举值包括:1=正常,2=暂停交易,3=仅允许撤单
/v2/settings/common/symbols
返回所有支持的交易对及详细配置,包括状态、精度、交易状态等ts
/v2/settings/common/currencies
返回所有支持的币种及其配置和展示名称ts
/v1/settings/common/symbols
返回交易对配置,包括定价和交易精度信息
/v1/settings/common/market-symbols
返回现货交易的市场交易对配置
/v2/settings/common/chains
返回区块链链信息,包括链名称和配置
/v2/reference/currencies
返回币种和区块链链的参考数据
/v1/common/timestamp
返回当前服务器时间戳,单位为毫秒

Market Data Endpoints

市场数据接口

EndpointDescriptionRequiredOptionalAuthentication
/market/history/klines
Returns OHLC candlestick data for the specified symbol and time periodsymbol, periodsize, fromNo
/market/detail
Returns the latest market ticker data for a symbol including price, volume, and 24h statssymbolNoneNo
/market/tickers
Returns latest ticker data for all trading pairsNoneNoneNo
/market/depth
Returns order book depth (bids and asks) for a symbolsymbol, typeNoneNo
/market/trade
Returns the latest trade data for a symbolsymbolNoneNo
/market/history/trade
Returns recent trades for a symbolsymbolsizeNo
/market/overview
Returns 24-hour market summary statistics for all symbolsNoneNoneNo
/market/orderbook
Returns complete order book for a symbol with full depthsymboldepthNo
Endpoint描述必填参数可选参数是否需要鉴权
/market/history/klines
返回指定交易对和时间周期的OHLC K线数据symbol, periodsize, from
/market/detail
返回指定交易对的最新市场 ticker 数据,包括价格、成交量和24小时统计数据symbol
/market/tickers
返回所有交易对的最新ticker数据
/market/depth
返回指定交易对的订单簿深度(买盘和卖盘)symbol, type
/market/trade
返回指定交易对的最新成交数据symbol
/market/history/trade
返回指定交易对的近期成交记录symbolsize
/market/overview
返回所有交易对的24小时市场汇总统计数据
/market/orderbook
返回指定交易对的全深度完整订单簿symboldepth

Account Endpoints

账户接口

EndpointDescriptionRequiredOptionalAuthentication
/v1/account/accounts
Returns all account details for the authenticated userNoneNoneYes
/v1/account/accounts/{account-id}/balance
Returns balance details for a specific account including assets and liabilitiesaccount-idNoneYes
/v2/account/valuation
Returns total asset valuation for all accounts in the user's portfolioNonevaluationCurrencyYes
/v2/account/asset-valuation
Returns detailed asset valuation and portfolio compositionNoneNoneYes
/v1/account/transfer
Transfers assets between accountsfrom-account, to-account, currency, amountNoneYes
/v1/account/history
Returns account history and transaction recordsNoneaccount-id, currency, typeYes
/v1/account/ledger
Returns detailed ledger entries for account transactionsaccount-idcurrency, type, from-id, sizeYes
/v1/futures/transfer
Transfers funds between spot trading account and futures contract accountcurrency, amount, typeNoneYes
/v1/point/account
Returns current HTX points balance and historyNoneNoneYes
/v1/point/transfer
Transfers HTX points between accountsfrom-user, to-user, amountNoneYes
/v1/account/deduct-info
Returns user deduction settings and informationNoneNoneYes
/v1/account/deduct-currencies
Returns list of currencies available for fee deductionNoneNoneYes
/v1/account/deduct-config
Configures fee deduction method for spot and margin accountsdeductCurrencyNoneYes
Endpoint描述必填参数可选参数是否需要鉴权
/v1/account/accounts
返回已鉴权用户的所有账户详情
/v1/account/accounts/{account-id}/balance
返回指定账户的余额详情,包括资产和负债account-id
/v2/account/valuation
返回用户投资组合中所有账户的总资产估值valuationCurrency
/v2/account/asset-valuation
返回详细的资产估值和投资组合构成
/v1/account/transfer
在账户之间划转资产from-account, to-account, currency, amount
/v1/account/history
返回账户历史和交易记录account-id, currency, type
/v1/account/ledger
返回账户交易的详细账本条目account-idcurrency, type, from-id, size
/v1/futures/transfer
在现货交易账户和期货合约账户之间划转资金currency, amount, type
/v1/point/account
返回当前HTX积分余额和历史记录
/v1/point/transfer
在账户之间划转HTX积分from-user, to-user, amount
/v1/account/deduct-info
返回用户抵扣设置和信息
/v1/account/deduct-currencies
返回可用于手续费抵扣的币种列表
/v1/account/deduct-config
配置现货和杠杆账户的手续费抵扣方式deductCurrency

Trading Endpoints

交易接口

EndpointDescriptionRequiredOptionalAuthentication
/v1/order/orders/place
Places a new spot trading order (limit or market)account-id, amount, symbol, typeprice, client-order-id, source, time-in-forceYes
/v1/order/orders/{order-id}/cancel
Cancels a pending orderorder-idNoneYes
/v1/order/orders/batchcancel
Cancels multiple orders matching specified criteriaNoneaccount-id, symbolYes
/v1/order/orders/{order-id}
Returns details of a specific orderorder-idNoneYes
/v1/order/orders
Returns orders matching specified criteria (open, closed, cancelled)account-idsymbol, states, types, start-time, end-time, from, direct, sizeYes
/v1/order/orders/getClientOrder
Returns order details using client-order-idclient-order-idNoneYes
/v1/order/matchresults
Returns trade history and fill detailsNonesymbol, types, start-time, end-time, from, direct, sizeYes
Endpoint描述必填参数可选参数是否需要鉴权
/v1/order/orders/place
提交新的现货交易订单(限价或市价)account-id, amount, symbol, typeprice, client-order-id, source, time-in-force
/v1/order/orders/{order-id}/cancel
撤销待成交订单order-id
/v1/order/orders/batchcancel
批量撤销符合指定条件的订单account-id, symbol
/v1/order/orders/{order-id}
返回指定订单的详情order-id
/v1/order/orders
返回符合指定条件的订单(未成交、已成交、已撤销)account-idsymbol, states, types, start-time, end-time, from, direct, size
/v1/order/orders/getClientOrder
通过client-order-id查询订单详情client-order-id
/v1/order/matchresults
返回交易历史和成交明细symbol, types, start-time, end-time, from, direct, size

Conditional Order Endpoints

条件单接口

EndpointDescriptionRequiredOptionalAuthentication
/v1/stop-order/orders/place
Places a conditional order that executes when trigger conditions are metaccount-id, symbol, order-price, order-size, trigger-price, operatororder-type, trailing-rate, client-order-idYes
/v1/stop-order/orders/{order-id}/cancel
Cancels a conditional order before it is triggeredorder-idNoneYes
/v1/stop-order/openOrders
Returns list of open conditional orders not yet triggeredaccount-idsymbol, side, sizeYes
/v1/stop-order/orders
Returns history of conditional ordersaccount-idsymbol, side, states, from, sizeYes
/v1/stop-order/orders/{order-id}
Returns details of a specific conditional orderorder-idNoneYes
Endpoint描述必填参数可选参数是否需要鉴权
/v1/stop-order/orders/place
提交条件单,当触发条件满足时自动执行account-id, symbol, order-price, order-size, trigger-price, operatororder-type, trailing-rate, client-order-id
/v1/stop-order/orders/{order-id}/cancel
在条件单触发前撤销条件单order-id
/v1/stop-order/openOrders
返回尚未触发的未成交条件单列表account-idsymbol, side, size
/v1/stop-order/orders
返回条件单历史记录account-idsymbol, side, states, from, size
/v1/stop-order/orders/{order-id}
返回指定条件单的详情order-id

Margin Loan (Cross/Isolated) Endpoints

杠杆借贷(全仓/逐仓)接口

EndpointDescriptionRequiredOptionalAuthentication
/v1/margin/orders
Applies for a margin loan on cross or isolated margin accountcurrency, amountaccount-idYes
/v1/margin/orders/{order-id}/repay
Repays a margin loan with interestorder-id, amountNoneYes
/v1/margin/orders
Returns margin loan orders and their statusNonecurrency, state, from, sizeYes
/v1/margin/accounts
Returns margin account details including borrowed amounts and interestNoneaccount-idYes
/v1/margin/accounts/balance
Returns detailed balance information for margin accountsNoneaccount-idYes

Endpoint描述必填参数可选参数是否需要鉴权
/v1/margin/orders
向全仓或逐仓杠杆账户申请杠杆借贷currency, amountaccount-id
/v1/margin/orders/{order-id}/repay
偿还杠杆借贷本金和利息order-id, amount
/v1/margin/orders
返回杠杆借贷订单及其状态currency, state, from, size
/v1/margin/accounts
返回杠杆账户详情,包括借贷金额和利息account-id
/v1/margin/accounts/balance
返回杠杆账户的详细余额信息account-id

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
  • currency: Currency name (lowercase, e.g., btc, usdt)
  • show-desc: Show description (true, false)
  • ts: Timestamp for querying (optional)
  • authorizedUser: Authorized user flag (true, false)
  • symbol: 交易对(例如:btcusdt, ethusdt)
  • symbols: 逗号分隔的交易对列表
  • account-id: 账户ID(可通过/v1/account/accounts接口获取)
  • type: 订单类型
  • amount: 订单数量(市价买单的amount为计价币种数量,其他订单类型为标的币种数量)
  • price: 订单价格(限价单必填)
  • source: 订单来源(默认:spot-api)
  • client-order-id: 客户端自定义订单ID(最大长度:64)
  • self-match-prevent: 自成交预防(0=关闭,1=开启)
  • stop-price: 限价止损单的止损价格
  • operator: 条件单的操作符(gte, lte)
  • order-id: 订单ID
  • period: K线周期/时间间隔
  • size: 返回的记录数量
  • depth: 深度层级(例如:step0, step1, step2等)
  • side: 订单方向(buy, sell)
  • states: 订单状态(逗号分隔)
  • types: 订单类型(逗号分隔)
  • start-date: 开始日期(格式:yyyy-mm-dd)
  • end-date: 结束日期(格式:yyyy-mm-dd)
  • start-time: 开始时间(Unix毫秒时间戳)
  • end-time: 结束时间(Unix毫秒时间戳)
  • from: 分页起始ID
  • direct: 分页方向(prev, next)
  • accountType: 资产估值对应的账户类型
  • valuationCurrency: 估值币种(例如:BTC, USDT, CNY)
  • transactTypes: 交易类型(逗号分隔)
  • limit: 返回的记录数量
  • fromId: 查询起始ID
  • currency: 币种名称(小写,例如:btc, usdt)
  • show-desc: 是否展示描述(true, false)
  • ts: 查询用时间戳(可选)
  • authorizedUser: 已授权用户标记(true, false)

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

  • 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 AccessKeyId parameter)
  • secretKey: Your HTX API secret (for signing)
Base URLs:
对于需要鉴权的接口,你需要提供HTX API凭证。 所需凭证:
  • apiKey: 你的HTX API key(用于AccessKeyId参数)
  • secretKey: 你的HTX API secret(用于签名)
请求域名:

Security

安全规范

Share Credentials

共享凭证

Users can provide HTX API credentials by sending a file where the content is in the following format:
bash
fe45419a...xyz
secretabc...key
用户可以通过发送文件的方式提供HTX API凭证,文件内容格式如下:
bash
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
向用户展示凭证时:
  • API Key: 仅展示前5位 + 后4位:
    fe45419a...xyz
  • Secret Key: 始终脱敏,仅展示后5位:
    ***...key1
用户查询凭证时的返回示例:
账户:main
API Key:fe45419a...xyz
Secret:***...key1
环境:主网

Listing Accounts

账户列表展示

When listing accounts, show names and environment only — never keys:
HTX Accounts:
* main (Mainnet)
* trading (Mainnet - AWS)
列出账户时,仅展示名称和环境,永远不要展示密钥:
HTX账户列表:
* main(主网)
* trading(主网 - AWS)

Transactions in Mainnet

主网交易

When performing transactions in mainnet, always confirm with the user before proceeding by asking them to write "CONFIRM" to proceed.

在主网执行交易操作前,必须先向用户确认,要求用户输入"CONFIRM"后再继续。

HTX Accounts

HTX账户配置

main

main

  • API Key: your_mainnet_api_key
  • Secret: your_mainnet_secret
  • Environment: https://api.huobi.pro
  • Description: Primary trading account
  • API Key: your_mainnet_api_key
  • Secret: your_mainnet_secret
  • 环境:https://api.huobi.pro
  • 描述:主交易账户

trading

trading

  • API Key: your_aws_api_key
  • Secret: your_aws_secret
  • Environment: https://api-aws.huobi.pro
  • Description: AWS optimized trading

TOOLS.md Structure

TOOLS.md 结构

bash
undefined
bash
undefined

HTX Accounts

HTX 账户列表

main

main

  • API Key: fe45419a...xyz
  • Secret: secretabc...key
  • Environment: https://api.huobi.pro
  • Description: Primary trading account
  • API Key: fe45419a...xyz
  • Secret: secretabc...key
  • 环境:https://api.huobi.pro
  • 描述:主交易账户

trading

trading

undefined
undefined

Agent Behavior

Agent 行为规范

  1. Credentials requested: Mask secrets (show last 5 chars only)
  2. Listing accounts: Show names and environment, never keys
  3. Account selection: Ask if ambiguous, default to main
  4. When doing a transaction in mainnet, confirm with user before by asking to write "CONFIRM" to proceed
  5. New credentials: Prompt for name, environment
  1. 凭证查询:对secret进行脱敏,仅展示后5位
  2. 账户列表展示:仅展示名称和环境,永远不展示密钥
  3. 账户选择:如果存在歧义则询问用户,默认使用main账户
  4. 在主网执行交易前,要求用户输入"CONFIRM"确认后再继续
  5. 新增凭证:提示用户输入账户名称、选择环境

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
当用户提供新的凭证时:
  • 询问账户名称
  • 询问:选择哪个环境(主网 或 主网-AWS)
  • 存储到
    TOOLS.md
    中,并向用户确认脱敏后的展示内容

Signing Requests

请求签名

All authenticated endpoints require HMAC SHA256 signature:
  1. 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
  2. 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
  3. Sign the pre-sign string with secretKey using HMAC SHA256
  4. Append signature to query string as Signature parameter
  5. 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
所有需要鉴权的接口都需要HMAC SHA256签名:
  1. 按照以下顺序构造预签名字符串:
    • HTTP方法(GET/POST) + "\n"
    • API域名(例如:api.huobi.pro) + "\n"
    • API路径(例如:/v1/order/orders) + "\n"
    • 排序后的查询字符串参数
  2. 所有鉴权请求都需要追加以下参数:
    • AccessKeyId: 你的API key
    • SignatureMethod: HmacSHA256
    • SignatureVersion: 2
    • Timestamp: UTC时间戳,格式为yyyy-MM-ddTHH:mm:ss
  3. 使用secretKey通过HMAC SHA256算法对预签名字符串进行签名
  4. 将签名结果作为Signature参数追加到查询字符串中
  5. 对于POST请求,同样需要将签名放在URL查询字符串中
预签名字符串示例:
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

User-Agent 请求头

Include
User-Agent
header with the following string:
htx-spot/1.0.0 (Skill)
请求需要携带
User-Agent
头,内容为:
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
  • For order queries, the order created via API will no longer be queryable after being cancelled for more than 2 hours
  • The maximum query window for historical data is typically 48 hours, with data available for the last 180 days
  • When placing batch orders, maximum 10 orders per batch
  • Fee rates query supports maximum 10 trading pairs at a time
  • All request endpoints must match the endpoints specified in the documentation.
  • 所有时间戳均为Unix毫秒格式
  • 交易对名称需要使用小写(例如:btcusdt,不要用BTCUSDT)
  • 市价买单的
    amount
    参数代表计价币种的金额
  • 其他所有订单类型的
    amount
    参数代表标的币种的数量
  • 交易前必须通过
    /v1/account/accounts
    接口获取账户ID
  • 接口有频率限制,详情请参考HTX API官方文档
  • 每个鉴权请求都需要单独计算签名
  • 签名中的时间戳与服务器时间的差值不能超过1分钟
  • 订单查询时,通过API创建的订单撤销超过2小时后将无法查询
  • 历史数据的最大查询窗口通常为48小时,最多可查询最近180天的数据
  • 批量下单时,每批最多支持10个订单
  • 手续费费率查询每次最多支持10个交易对
  • 所有请求端点必须与文档中指定的端点一致

API Documentation

API文档

For more details, refer to the official HTX API documentation: https://www.htx.com/en-us/opend/newApiPages/
更多详情请参考HTX官方API文档:https://www.htx.com/en-us/opend/newApiPages/