Every request made through theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/gateio-api/llms.txt
Use this file to discover all available pages before exploring further.
gateio-api SDK is promise-based, which means errors propagate through standard JavaScript rejection paths. Understanding the shape of those errors — and the SDK options that control how they are processed — is essential before deploying any trading automation to production.
How REST Errors Surface
The SDK uses axios under the hood for all HTTP requests. When a request fails — whether due to a network problem, an HTTP status outside the 2xx range, or an application-level rejection returned by the Gate.com API — the SDK intercepts the raw axios error insideBaseRestClient.parseException and re-throws a structured object.
The re-thrown error has the following shape:
API credentials (
apiKey, apiSecret) are automatically stripped from the requestOptions field of every thrown error object so they never appear in logs or error reporting tools.Accessing the Gate.com Error Body
Gate.com includes a machine-readablelabel and a human-readable message in every error response. After the SDK processes the exception, both values live under the body property of the thrown object:
Controlling Error Processing with parseExceptions
The parseExceptions option (default: true) controls whether the SDK post-processes raw axios errors into the structured format described above.
| Value | Behaviour |
|---|---|
true (default) | Axios errors are caught and re-thrown as structured objects with code, message, body, and headers. |
false | Raw axios errors bubble up unmodified. You receive an AxiosError instance with error.response?.data containing the Gate.com body. |
Catching Undefined Parameters with strictParamValidation
Setting strictParamValidation: true causes the SDK to throw a synchronous error before the HTTP request is even dispatched if any parameter value is undefined. This is useful during development to catch typos and missing fields early.
Async/Await vs. Promise Chain Patterns
Both patterns work equally well. Choose the one that fits your codebase style.- async/await + try/catch
- .catch() chain
WebSocket Error Events
TheWebsocketClient extends Node.js EventEmitter and exposes error-related events you can listen to for robust error handling:
| Event | When it fires |
|---|---|
exception | The SDK encountered an error — including raw WebSocket transport errors (e.g. connection refused, TLS failure), internal message-processing failures, or an uncaught error thrown inside one of your own event handlers. |
error | Defined in the event type map for forward compatibility; subscribe to exception for active error handling. |
The
exception event fires for all WebSocket error conditions: raw transport errors (onerror), internal SDK processing failures, and uncaught errors thrown inside your own update, response, or authenticated event handlers. This centralises error logging in a single handler.Common Error Scenarios
INVALID_PARAM_VALUE — bad parameter
INVALID_PARAM_VALUE — bad parameter
Gate.com returns this label when a request parameter does not match the expected format or range. Double-check the currency pair format (
BTC_USDT, not BTCUSDT), order side (buy/sell), and numeric precision requirements in the Gate.com API docs.INVALID_KEY — authentication failure
INVALID_KEY — authentication failure
Returned when the
apiKey does not exist, has been revoked, or the request signature is invalid. Verify your key is active in the Gate.com API Key Management console. Also check that your system clock is accurate — Gate.com uses timestamp-based HMAC signing and will reject requests where the timestamp is too far from server time.RATELIMIT — too many requests
RATELIMIT — too many requests
You have exceeded Gate.com’s rate limit for the endpoint. Implement an exponential back-off strategy and consult the Gate.com rate limit documentation for per-endpoint limits. The HTTP
code in the SDK error will be 429.Network timeout (no e.body)
Network timeout (no e.body)
If
e.body is undefined and e.code is also undefined, the error occurred before the server responded — typically a DNS failure, TCP timeout, or proxy misconfiguration. Inspect e.message for details. Consider enabling keepAlive: true in RestClientOptions for high-frequency workloads to reduce connection overhead.Missing API keys at construction time
Missing API keys at construction time
If you provide only one of Either provide both credentials or omit both (for unauthenticated public endpoints only).
apiKey or apiSecret (but not both), the RestClient constructor throws synchronously: