Use this file to discover all available pages before exploring further.
Getting up and running with gateio-api takes just a few minutes. You’ll install the package, create API credentials on Gate.com, instantiate a client, and make your first live API call. This guide walks through each step and includes ready-to-run code for both TypeScript and JavaScript environments.
1
Install the package
2
Add gateio-api to your project using your preferred package manager.
3
npm
npm install gateio-api
yarn
yarn add gateio-api
pnpm
pnpm add gateio-api
4
The package ships with built-in TypeScript declarations — no separate @types/ package is needed.
5
Create your API credentials
6
Log in to your Gate.com account and navigate to the API Key Management page. Create a new API key and note both the API Key and API Secret. You’ll also need to configure the appropriate permissions (read, trade, etc.) depending on what your application needs to do.
7
Never commit your API key or secret to source control. Use environment variables or a secrets manager to keep credentials out of your codebase. Anyone who obtains your secret can trade on your behalf and withdraw funds if withdrawal permissions are enabled.
8
Create a client instance
9
Instantiate a RestClient with your credentials. Both TypeScript (ES module imports) and CommonJS (require) are supported.
10
TypeScript
import { RestClient } from 'gateio-api';const client = new RestClient({ apiKey: process.env.GATE_API_KEY, apiSecret: process.env.GATE_API_SECRET,});
Set price below the current market price when testing a buy order so it rests in the order book rather than filling immediately. Remember to cancel test orders when you’re done.
22
Subscribe to real-time WebSocket data
23
Use the WebsocketClient to subscribe to live spot ticker updates. The client manages the connection automatically and emits data through Node.js events.