Registry / http-networking / gate-api

gate-api

JSON →
library7.2.78jsnpmunverified

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.

npm install gate-api
INSTALL
IMPORT
SIG · GATE-API
G
gate-api
http-networkingjavascriptv7.2.78
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GateApi (CommonJS)
const GateApi = require('gate-api');
This is the CommonJS import style demonstrated in the official quickstart for Node.js. The 'GateApi' object will contain all API clients and models.
GateApi (ESM Namespace Import)
import * as GateApi from 'gate-api';
import GateApi from 'gate-api';
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.
ApiClient, AccountApi (ESM Named Imports)
import { ApiClient, AccountApi } from 'gate-api';
Prefer named imports for specific classes (like ApiClient, AccountApi) to leverage tree-shaking and improve code readability in ES Module environments.

Initializes the Gate.io client with API key authentication and fetches user account details.

import { ApiClient, AccountApi } from 'gate-api'; const API_KEY = process.env.GATE_API_KEY ?? ''; const API_SECRET = process.env.GATE_API_SECRET ?? ''; if (!API_KEY || !API_SECRET) { console.error('API_KEY and API_SECRET must be set as environment variables.'); process.exit(1); } const client = new ApiClient(); // Optionally, change base path if not using the default production endpoint // client.basePath = "https://some-other-host"; // Configure Gate APIv4 key authentication: client.setApiKeySecret(API_KEY, API_SECRET); const api = new AccountApi(client); api.getAccountDetail() .then(value => console.log('API called successfully. Returned data: ', value.body)) .catch(error => console.error('Error fetching account detail:', error.body ? error.body : error));
Debug
Known issues
breakingThe 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.
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.
affects: >=4.15.2
breakingGate.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.
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.
affects: <=4.0.0
gotchaThis 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.
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.
affects: >=1.0.0
gotchaAggressive 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.
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.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Unauthorized (HTTP status 401)
Incorrect API key or secret, invalid signature, or IP address not whitelisted for the API key.
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.
Error: Request failed with status code 429 (Too Many Requests)
Your application has exceeded the API rate limits set by Gate.io.
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.
Error: Request failed with status code 400 (Bad Request)
The API request contains invalid parameters, is malformed, or is missing required fields.
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.
Upgrade
Version history
7.2.78latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources