API Reference
REST and WebSocket APIs for programmatic access to markets, orders, positions, and real-time data on Hyperliquid DEX.
api.perpex.io/v1JWT BearerREST Endpoints
/api/v1/markets/api/v1/orderbook/:symbol/api/v1/account/api/v1/orders/api/v1/orders/:id/api/v1/tradesWebSocket Channels
wss://ws.perpex.iotradesReal-time trade stream for subscribed symbols
orderbookOrderbook updates with configurable depth
positionsUser position changes and liquidation alerts
candlesOHLCV candlestick data at various intervals
Authentication
Authentication requires API keys which can be generated from your account dashboard with customizable permissions for enhanced security. All authenticated requests must include a JWT Bearer token in the Authorization header.
Our API is designed for high performance with low latency and includes rate limiting to ensure fair usage. SDKs and client libraries are available in JavaScript, Python, and TypeScript to simplify integration.
Rate Limits & Best Practices
API requests are rate-limited to ensure fair usage and platform stability. REST endpoints allow up to 120 requests per minute per API key, while WebSocket connections support up to 10 concurrent subscriptions per connection. Exceeding these limits will result in temporary throttling with appropriate HTTP 429 status codes.
For optimal performance, we recommend using WebSocket subscriptions for real-time data instead of polling REST endpoints. Batch order operations are available through the POST /api/v1/orders/batch endpoint, allowing you to submit up to 10 orders in a single request. This reduces latency and helps you stay within rate limits during high-frequency trading.
Error Handling
All API responses follow a consistent format with standard HTTP status codes. Successful responses return a 200 status with the requested data, while errors include a descriptive error code and message to help you diagnose issues quickly. Common error codes include INSUFFICIENT_MARGIN for underfunded orders, INVALID_SYMBOL for unrecognized trading pairs, and ORDER_NOT_FOUND for operations on non-existent orders.
WebSocket connections include automatic heartbeat monitoring. If no message is received for 30 seconds, the server sends a ping frame. Clients should respond with a pong frame to maintain the connection. Disconnected clients should implement exponential backoff reconnection logic starting from 1 second up to a maximum of 30 seconds between retry attempts.