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.
RestClient is the single entry point for every Gate.com REST API. One class covers spot trading, margin borrowing, perpetual and delivery futures, options contracts, cross-exchange (CrossEx) routing, Alpha meme-token trading, OTC conversions, and all wallet/account management operations. Every request is fully typed — parameters and responses are defined in TypeScript interfaces so your IDE can autocomplete field names and flag type errors before you deploy.
Installation
Install the SDK from npm and importRestClient in your project:
- ESM / TypeScript
- CommonJS
Instantiation
Construct aRestClient by passing your API credentials through RestClientOptions. For public (unauthenticated) endpoints you can omit the credentials entirely.
Credentials are read once at construction time. Never hard-code secrets in source code — use environment variables or a secrets manager.
Configuration Options
RestClient accepts a RestClientOptions object as its first argument. The most commonly used fields are:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Your Gate.com API key |
apiSecret | string | — | Your Gate.com API secret |
baseUrl | string | Gate production | Override the API base URL (e.g. for a proxy) |
baseUrlKey | GateBaseUrlKey | — | Select a named base-URL preset built into the SDK |
recvWindow | number | — | Global request-window override in milliseconds |
strictParamValidation | boolean | false | Throw on undefined parameters before signing |
parseExceptions | boolean | true | Post-process Axios errors into structured exceptions |
keepAlive | boolean | false | Enable HTTP keep-alive on the underlying Axios agent |
customSignMessageFn | function | — | Provide a custom HMAC signer (e.g. Node.js createHmac) |
Authentication
Authentication is handled automatically. When you provideapiKey and apiSecret, the client signs every private request with an HMAC-SHA512 signature before it leaves your machine. You never need to construct sign, timestamp, or KEY headers yourself.
Finding the Right Method
Every REST endpoint in the Gate.com API maps to a dedicated method onRestClient. The SDK ships with a full endpoint-to-function mapping in docs/endpointFunctionList.md. Search that file for an endpoint URL or an HTTP method name to find the corresponding SDK function.
Error Handling
The client uses Axios internally. When Gate.com returns a non-2xx status code the SDK throws an Axios error. Wrap calls intry/catch to handle failures gracefully:
Market Areas Covered
Spot Trading
Place limit and market orders, query balances, fetch tickers and candles, and use price-triggered orders on Gate.com spot markets.
Margin Trading
Manage isolated and cross margin accounts, borrow and repay loans, and query interest records.
Futures Trading
Trade perpetual and delivery futures contracts, manage positions and leverage, and access funding rates.
Options Trading
List option contracts by expiry, manage option positions and orders, and query settlement history.
CrossEx Trading
Route orders across Binance, OKX, Bybit, Kraken, and Gate from a single unified account.
Alpha & OTC
Trade meme tokens and new listings via Gate Alpha, or execute stablecoin and fiat conversions via OTC.
Wallet & Account
Manage deposits, withdrawals, sub-accounts, cross-account transfers, and unified account settings.
Checking Server Latency
TheRestClient includes a built-in latency helper that measures round-trip time to Gate’s servers and warns you if your system clock is drifting: