Build on HTX — REST & WebSocket APIs
HTX provides robust APIs for market data, trading, and account management. Developers can connect via REST for synchronous requests and WebSocket for real-time feeds. This documentation includes authentication, signature examples, rate limits, error handling, and code snippets to get you started building trading bots, analytics pipelines, and custom dashboards.
Authentication & Keys
API access requires creating API keys in your account dashboard. Keys have granular permissions (read-only, trading, withdrawals disabled by default). When generating keys, store them securely and rotate periodically. Use HMAC signatures with timestamps to sign requests. Never embed secret keys in client-side code or public repos.
Market Data Endpoints
Market data endpoints provide tickers, order books, historical trades, and kline/candlestick data. For high-frequency strategies, use the WebSocket feed to subscribe to order book diffs, trade streams, and heartbeat messages. Respect rate limits and backoff strategies to avoid temporary bans.
Trading & Order Management
Place limit, market, and stop orders via the trading API. The responses include order IDs, status updates, and fills. Implement idempotency keys when creating orders to prevent duplicate execution. Poll order status or subscribe to order updates via WebSocket to get real-time fills and partial fills data.
Rate Limits & Best Practices
HTX enforces rate limits to protect services. Documented limits vary per endpoint and per account tier. Use exponential backoff on 429 responses and respect retry-after headers. For heavy load, consider batched requests and websockets to reduce REST calls. Contact HTX for enterprise rate limit arrangements when integrating at scale.
// Example: place a limit order (pseudo) POST /api/v1/orders { "symbol": "BTC-USDT", "side": "buy", "type": "limit", "price": "30000", "size": "0.005" }
Follow the documentation and SDKs for specific language examples and sandbox credentials to test safely before going live.