{"id":13211,"library":"gate-api","title":"Gate.io API Client for Node.js","description":"The `gate-api` package provides a TypeScript and JavaScript client for interacting with Gate.io's APIv4. It enables operations across spot, margin, and contract trading, offering both public interfaces for market data and authenticated private interfaces for automated trading. Currently at version 7.2.67, this SDK is automatically generated using OpenAPI Generator, targeting Node.js environments due to the security implications of storing API secrets in a browser. The package employs a unique versioning strategy: the MAJOR version increments only for breaking SDK changes, while the MINOR and PATCH versions directly reflect the underlying REST API version, allowing developers to correlate SDK changes with specific API updates. This client is distinct from `gateapi-js`, which is intended for public endpoints in browser environments.","status":"active","version":"7.2.67","language":"javascript","source_language":"en","source_url":"https://github.com/gate/gateapi-nodejs","tags":["javascript","typescript"],"install":[{"cmd":"npm install gate-api","lang":"bash","label":"npm"},{"cmd":"yarn add gate-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add gate-api","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is the CommonJS import style demonstrated in the official quickstart for Node.js. The 'GateApi' object will contain all API clients and models.","symbol":"GateApi (CommonJS)","correct":"const GateApi = require('gate-api');"},{"note":"For ES Modules (ESM) in TypeScript or modern Node.js, this namespace import provides access to all exported members (like ApiClient, AccountApi) via the 'GateApi' object. The default import style (`import GateApi from 'gate-api'`) is generally incorrect as the package uses named exports or a CommonJS-style module export that resolves to a namespace object in ESM.","wrong":"import GateApi from 'gate-api';","symbol":"GateApi (ESM Namespace Import)","correct":"import * as GateApi from 'gate-api';"},{"note":"Prefer named imports for specific classes (like ApiClient, AccountApi) to leverage tree-shaking and improve code readability in ES Module environments.","symbol":"ApiClient, AccountApi (ESM Named Imports)","correct":"import { ApiClient, AccountApi } from 'gate-api';"}],"quickstart":{"code":"import { ApiClient, AccountApi } from 'gate-api';\n\nconst API_KEY = process.env.GATE_API_KEY ?? '';\nconst API_SECRET = process.env.GATE_API_SECRET ?? '';\n\nif (!API_KEY || !API_SECRET) {\n    console.error('API_KEY and API_SECRET must be set as environment variables.');\n    process.exit(1);\n}\n\nconst client = new ApiClient();\n// Optionally, change base path if not using the default production endpoint\n// client.basePath = \"https://some-other-host\";\n\n// Configure Gate APIv4 key authentication:\nclient.setApiKeySecret(API_KEY, API_SECRET);\n\nconst api = new AccountApi(client);\n\napi.getAccountDetail()\n   .then(value => console.log('API called successfully. Returned data: ', value.body))\n   .catch(error => console.error('Error fetching account detail:', error.body ? error.body : error));\n","lang":"typescript","description":"Initializes the Gate.io client with API key authentication and fetches user account details."},"warnings":[{"fix":"Review the GitHub releases page (github.com/gate/gateapi-nodejs/releases) for specific breaking changes and migration guides when a major version is incremented.","message":"The SDK employs a non-standard semantic versioning for major versions. A MAJOR version increment signifies breaking changes in the SDK itself (e.g., method signatures, dropped language support), but the MINOR and PATCH versions will continue to align with the underlying Gate.io REST API version. Always consult release notes on GitHub when upgrading.","severity":"breaking","affected_versions":">=4.15.2"},{"fix":"Generate new APIv4 keys on the Gate.io platform and update your application to use the `gate-api` client, ensuring all API calls adhere to the v4 specification.","message":"Gate.io discontinued support for API v2 on September 1, 2023, transitioning exclusively to API v4. Older API keys and calls for v2 will no longer function, requiring users to generate new v4 API keys.","severity":"breaking","affected_versions":"<=4.0.0"},{"fix":"Ensure that `gate-api` is used exclusively in secure server-side Node.js environments. Do not embed API keys or secrets in client-side code accessible via browsers.","message":"This SDK is designed for Node.js environments only. It is not safe to store API secrets directly in browser-side applications. For public endpoints in a browser context, use the `gateapi-js` package instead.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Implement exponential back-off strategies for retrying failed API requests, especially for 5xx server errors. Avoid immediate retries and consider rate limit headers if provided by the API. For 4xx client errors, correct the request before retrying.","message":"Aggressive or immediate retries on API errors can lead to rate limiting (HTTP 429) or exacerbate server load. Gate.io, like most exchanges, has rate limits.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify `API_KEY` and `API_SECRET` are correct. Check the IP whitelist settings for your API key on the Gate.io platform. Ensure your system's clock is synchronized for correct timestamp-based signatures.","cause":"Incorrect API key or secret, invalid signature, or IP address not whitelisted for the API key.","error":"Error: Unauthorized (HTTP status 401)"},{"fix":"Implement proper rate limiting and exponential back-off logic in your application. Consult Gate.io's API documentation for specific rate limit details and best practices for polling.","cause":"Your application has exceeded the API rate limits set by Gate.io.","error":"Error: Request failed with status code 429 (Too Many Requests)"},{"fix":"Review the specific error message returned in the response body for details. Cross-reference your request parameters against the Gate.io APIv4 documentation for the endpoint you are calling to ensure correctness.","cause":"The API request contains invalid parameters, is malformed, or is missing required fields.","error":"Error: Request failed with status code 400 (Bad Request)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}