Resources / API

API Reference

REST and WebSocket APIs for programmatic access to markets, orders, positions, and real-time data on Hyperliquid DEX.

Base URLapi.perpex.io/v1
AuthJWT Bearer
01

REST Endpoints

Method
Endpoint
Description
GET
/api/v1/markets
List all available trading pairs and market data
GET
/api/v1/orderbook/:symbol
Real-time orderbook depth for a symbol
GET
/api/v1/account
Account balances, positions, and margin info
POST
/api/v1/orders
Place a new order (limit, market, stop, etc.)
DELETE
/api/v1/orders/:id
Cancel an existing open order
GET
/api/v1/trades
Trade history with pagination and filters
02

WebSocket Channels

Endpointwss://ws.perpex.io
trades

Real-time trade stream for subscribed symbols

orderbook

Orderbook updates with configurable depth

positions

User position changes and liquidation alerts

candles

OHLCV candlestick data at various intervals

03

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.

04

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.

05

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.