About this guide: I'm Lawrence, the writer behind supa.is. Between February and May 2026 I've published 150+ articles on supa.is across crypto and brokerage tooling โ including 30+ Hyperliquid-specific guides (recent examples: Hyperliquid API Key Setup, Hyperliquid Python SDK Tutorial, Hyperliquid Websocket Reconnect Fix). The most-repeated reader question across that Hyperliquid archive is exactly how to handle API error responses when building a trading bot, which is why I'm publishing this standardized guide instead of answering one-off.
Building an automated trading bot on Hyperliquid is incredibly rewarding, but debugging API errors can be a nightmare if you don't understand how the exchange structures its responses. Whether you are using the official Python SDK, interacting with the REST API directly, or managing WebSocket connections, you will eventually hit an error.
A bot that crashes on a bad request loses money. A bot that gracefully handles rate limits keeps running.
In this guide, we will break down Hyperliquid's API error responses, explain the most common error codes you will encounter, and provide actionable steps to fix them.
How Hyperliquid Structures API Responses
Hyperliquid communicates with your bot using standard HTTP status codes. Unlike some exchanges that return a generic 200 OK and put error messages in the response body, Hyperliquid uses standard HTTP status codes to indicate the type of failure, while the response body provides the specific details.
When you make a request to Hyperliquid's API, there are three main outcomes:
- Success (200 OK): The request was received and processed successfully. The response body will contain the data you requested (e.g., order confirmations, account balances, or market data).
- Client Error (4xx): The request was malformed, unauthorized, or invalid in some way. The issue lies on your end, and you need to fix your code or request parameters.
- Server Error (5xx): Hyperliquid's servers encountered an unexpected issue. These are rare but possible, especially during high volatility or maintenance windows.
401 Unauthorized means your API key is wrong or revoked. A 400 Bad Request means you sent invalid data. A 429 Too Many Requests means you are hitting rate limits.
Common HTTP Status Codes in Hyperliquid API
Here is a breakdown of the most common HTTP status codes you will encounter when interacting with Hyperliquid's API:
Like what you're reading? Try it yourself โ this link supports ChartedTrader at no cost to you.
Sign up on Hyperliquid โ| HTTP Code | Meaning | Common Cause |
|---|---|---|
| 200 | OK | Request successful. |
| 400 | Bad Request | Invalid JSON, missing fields, or malformed request. |
| 401 | Unauthorized | Invalid API key, expired signature, or insufficient permissions. |
| 403 | Forbidden | API key lacks the required permissions (e.g., trying to trade with a read-only key). |
| 404 | Not Found | The endpoint you are hitting does not exist. |
| 429 | Too Many Requests | You are exceeding Hyperliquid's rate limits. |
| 500 | Internal Server Error | Hyperliquid's servers are experiencing an issue. |
| 503 | Service Unavailable | Hyperliquid is undergoing maintenance or is temporarily down. |
Decoding Hyperliquid-Specific Error Messages
While HTTP codes tell you the broad category of the error, Hyperliquid's response body provides the specific reason. The official documentation outlines the structure of these error responses, which typically include an error code and a human-readable message.
Here are the most common Hyperliquid-specific errors and how to resolve them.
1. "Invalid API Key" or "Unauthorized"
This is the most common error for new developers. It means your authentication failed. How to fix it: * Double-check your API key: A single typo will cause authentication to fail. * Check your API key permissions: Trying to place a trade with a read-only key will throw a403 Forbidden or "Unauthorized" error. Make sure your key has the necessary permissions. For a deep dive on this, check out our Hyperliquid API Key Setup: Read vs Trade Permissions guide.
* Verify your signature: If you are using the REST API directly (not the SDK), you need to sign your requests. Ensure your timestamp is accurate and your signature algorithm matches Hyperliquid's requirements exactly.
* Check your IP whitelist: If you restricted your key to specific IPs, make sure your server's IP is whitelisted.
2. "Insufficient Balance" or "Insufficient Margin"
Your bot tried to place an order, but your account didn't have enough funds to cover it. How to fix it: * Check your account balance: Ensure you have enough USDC in your Hyperliquid account. Remember that Hyperliquid uses USDC as its primary settlement currency. * Account for fees: When placing an order, the required margin includes the potential fees. If you are placing a large market order, the slippage and fees might push your required margin over your available balance. * Check your margin mode: If you are using Isolated Margin, your margin is limited to the specific position. If you are using Cross Margin, your entire account balance is at risk. Make sure you understand the difference, as explained in our Hyperliquid Cross Margin vs Isolated Margin guide. * Check your leverage: Sometimes the error is actually a leverage limit issue. Ensure your position size doesn't exceed the maximum leverage allowed for that specific coin.3. "Invalid Order Parameters"
This error means the data you sent for your order was invalid. This could be a wrong symbol, an invalid price, or a quantity that doesn't meet the minimum. How to fix it: * Verify the coin symbol: Hyperliquid uses specific symbols for its perpetual contracts (e.g.,BTC-USD, ETH-USD). Ensure you are using the exact symbol format.
* Check price and quantity: Ensure your price is a valid number and your quantity meets the minimum order size for that specific coin.
* Check order type: Ensure the order type you are using (e.g., Limit, Market, Stop) is supported for that specific coin and trading mode.
* Check your slippage tolerance: If you are placing a market order, ensure your slippage tolerance isn't set too tight, which can cause the order to be rejected if the price moves too fast.
4. "Rate Limit Exceeded"
Hyperliquid, like all exchanges, has rate limits to prevent abuse and ensure fair access for all users. If you send too many requests in a short period, you will get a429 Too Many Requests error.
How to fix it:
* Implement exponential backoff: When your bot receives a 429 error, don't immediately retry. Wait a short period (e.g., 1 second), then retry. If you get another 429, wait longer (e.g., 2 seconds, then 4 seconds). This is known as exponential backoff.
* Batch your requests: If you are fetching data for multiple coins, try to batch your requests instead of sending them one by one.
* Cache your data: Don't fetch the same data repeatedly. If you need the current price of BTC, fetch it once and cache it for a few seconds before fetching it again.
5. "WebSocket Connection Lost"
If you are using WebSockets for real-time data, you might experience connection drops. This is common in long-running bots. How to fix it: * Implement automatic reconnection: Your bot should detect when the WebSocket connection is lost and automatically attempt to reconnect. Our Hyperliquid Websocket Reconnect Fix guide covers this in detail. * Handle re-subscriptions: When your bot reconnects, it needs to re-subscribe to the channels it was previously listening to (e.g., order book updates, trade updates).Best Practices for Error Handling in Your Hyperliquid Bot
Handling errors is not just about fixing them when they happen; it's about designing your bot to be resilient from the start. Here are some best practices:
1. Log Everything
When your bot encounters an error, log it. Include the HTTP status code, the error message from Hyperliquid, and the request you sent. This will make debugging much easier later.
import logging
logging.basicConfig(level=logging.INFO)
try:
# Attempt to place an order
response = client.place_order(...)
except Exception as e:
logging.error(f"Order placement failed: {e}")
# Handle the error
2. Use Try-Except Blocks
Never let an unhandled exception crash your bot. Wrap your API calls in try-except blocks to catch and handle errors gracefully.3. Retry with Caution
For transient errors (like network timeouts or rate limits), retrying is a good strategy. However, be careful not to retry too quickly, as this can exacerbate the problem (e.g., hitting rate limits even harder).4. Monitor Your Bot
Set up alerts for when your bot encounters errors. If your bot starts getting "Insufficient Balance" errors, you want to know about it immediately so you can deposit more funds or pause the bot.FAQ
What should I do if I get a 429 Too Many Requests error?
A429 error means you are hitting Hyperliquid's rate limits. You should implement exponential backoff in your code. When you receive a 429, wait for a short period before retrying your request. If you receive another 429, wait even longer. This prevents you from overwhelming the exchange and getting banned.
How do I find out the specific error code from Hyperliquid?
The specific error code and message will be in the response body of the HTTP request. When you catch an exception or check the response status code, inspect the response payload. Hyperliquid's API returns a JSON object with anerror field that contains the code and a human-readable message.
Can I increase my rate limits on Hyperliquid?
Rate limits on Hyperliquid are generally based on your account tier and trading volume. Higher volume traders typically get higher rate limits. If you are a high-volume trader and believe your rate limits are too low, you can contact Hyperliquid support to discuss your needs.Why am I getting "Invalid API Key" even though I just created it?
This is usually a permissions issue. When you create an API key on Hyperliquid, you must explicitly grant it the permissions it needs (e.g., read, trade, withdraw). If you are trying to place a trade with a read-only key, you will get an "Invalid API Key" or "Unauthorized" error. Go back to the Hyperliquid dashboard and check your API key settings.Is it safe to use the Hyperliquid Python SDK for trading?
Yes, the Hyperliquid Python SDK is widely used and actively maintained. It handles a lot of the complexity of the API, including authentication and WebSocket connections. However, you should still implement proper error handling in your code, as the SDK can still throw exceptions if the API returns an error.Risk Warning
Risk Warning: Crypto trading involves substantial risk of loss. Never invest more than you can afford to lose. This is not financial advice.