Every private Gate.com API operation — placing orders, reading balances, managing positions — requires a signed request that proves the call comes from you. 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 handles this signing automatically once you supply your credentials at construction time. You never call a sign function yourself; the SDK intercepts each outgoing private request, attaches the correct HMAC-SHA512 signature and timestamp, and sends it on your behalf. This page explains where credentials come from, how to pass them to each client, and how to tune the signing behaviour for your environment.
Creating API Credentials
Log in to Gate.com and go to API Key Management. Click Create API Key, give it a descriptive name, and choose the minimum set of permissions your application requires:- Read — for fetching market data, balances, order history
- Trade — for placing, modifying, and cancelling orders
- Withdrawal — only if your application needs to initiate withdrawals (treat this with extreme care)
Passing Credentials to RestClient
Supply apiKey and apiSecret in the options object passed to the RestClient constructor. The recommended approach reads them from environment variables so the values are never in your source files:
getSpotTicker()) work without credentials and do not trigger any signing logic.
Passing Credentials to WebsocketClient
The WebsocketClient accepts the same credential fields. Authentication for private WebSocket channels (such as spot.orders and spot.balances) is handled transparently:
How HMAC-SHA512 Signing Works
When you call any private REST endpoint, the SDK constructs a canonical string from the HTTP method, request path, query string, and body hash, then signs it using HMAC-SHA512 with yourapiSecret as the key. The resulting signature, along with your apiKey and a millisecond timestamp, are added as request headers before the call is dispatched. Gate.com’s servers verify the signature on receipt.
For WebSocket connections, the SDK similarly signs the authentication payload at connection time. You do not interact with any of this directly — it is entirely internal to the client.
Testnet Configuration
Gate.com provides a futures testnet environment for safe experimentation. Enable it by settingbaseUrlKey to 'futuresTestnet' in the client options:
WebsocketClient, pass useTestnet: true:
Testnet API keys are separate from live keys. Create testnet credentials through the futures testnet portal — live credentials will not work against the testnet endpoints.
RestClientOptions Reference
These are the authentication-related fields in the RestClientOptions interface. Pass any of them in the object you hand to the RestClient or WebsocketClient constructor.
Your Gate.com API key, obtained from the API Key Management page. Required for all private (authenticated) REST endpoints and WebSocket channels.
Your Gate.com API secret, shown once at key creation time. The SDK uses this to generate the HMAC-SHA512 signature on every private request. Store it in an environment variable or secrets manager — never hardcode it.
The maximum age (in milliseconds) of a signed request that Gate.com’s servers will accept. If a request arrives outside this window — due to clock drift between your server and Gate.com — it will be rejected. Defaults to Gate.com’s global value. Increase this only if you are seeing timestamp-related errors in environments with unreliable system clocks.
When set to
true, the SDK throws an error if any parameter passed to a request method is undefined. This can help catch bugs during development where a variable is accidentally left uninitialised before being passed to an API call.Override the default REST API base URL entirely. Use this when pointing at a custom proxy or local mock server. Example:
'https://api.gate.io'. When set, baseUrlKey is ignored.Select one of the built-in base URL presets instead of the default live endpoint. Use
'futuresTestnet' to target the futures testnet at https://fx-api-testnet.gateio.ws/api/v4. Ignored if baseUrl is also set.When
true (the default), the SDK post-processes request errors and throws them as structured exceptions. Set to false to receive raw Axios error objects instead.Enable HTTP keep-alive for REST API requests made via Axios. Keeping the underlying TCP connection open between requests reduces latency for workloads that make many sequential calls. Disabled by default.
When
keepAlive is true, controls how often (in milliseconds) TCP keep-alive packets are sent over idle sockets. Only relevant if keepAlive is enabled.An optional function that replaces the SDK’s default HMAC-SHA512 implementation. Node.js’s built-in
crypto.createHmac is significantly faster than browser-compatible crypto implementations. If you are running in Node.js and need maximum signing throughput — for example, a high-frequency trading system sending many authenticated requests per second — provide a custom function using crypto.createHmac:Full Configuration Example
The following example brings all of the above together using environment variables, strict validation, and a high-performance custom sign function:Next Steps
Quickstart
See a complete working example from installation to your first API call.
Gate.com API Reference
Full documentation for all REST endpoints and WebSocket channels.