Node.js & JavaScript SDK for Gate.com (Gate.io) REST APIs, WebSockets & WebSocket API
Public spot tickers:
const { WebsocketClient } = require('gateio-api');
const ws = new WebsocketClient();
ws.subscribe({ topic: 'spot.tickers', payload: ['BTC_USDT'] }, 'spotV4');
WebsocketClient handles what a raw WebSocket does not:
- reconnect
- heartbeat
- resubscribe
Updated & performant JavaScript & Node.js SDK for the Gate.com (gate.io) REST APIs and WebSockets.
Take a look at our dedicated Gate.io API quickstart guides for major frameworks and JavaScript runtimes.
- Professional, robust & performant Gate.com SDK with extensive production use in live trading environments.
- Extensive integration with Gate.com (Gate.io) REST APIs and WebSockets.
- Complete TypeScript support (with type declarations for most API requests & responses).
- Strongly typed requests and responses.
- Automated end-to-end tests ensuring reliability.
- Actively maintained with a modern, promise-driven interface.
- Gate.com REST APIs for Gate.com Spot, Margin, Perpetual Futures, Delivery Futures, Options, CrossEx, Alpha & OTC Trading APIs.
- Unified RestClient for all Gate.com trading products.
- Strongly typed on most requests and responses.
- Support for Cross-Exchange (CrossEx) trading across multiple exchanges
- Support for Alpha account trading (meme tokens and new listings)
- Support for OTC (fiat and stablecoin) trading
- Support for seamless API authentication for private Gate.com REST API and WebSocket calls.
- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
- Event driven messaging.
- Smart websocket persistence with automatic reconnection handling.
- Automatically handle silent websocket disconnections through timed heartbeats, including the scheduled 24hr disconnect.
- Automatically handle listenKey persistence and expiration/refresh.
- Emit
reconnected event when dropped connection is restored.
- Support for Gate.com Spot, Margin, Perpetual Futures, Delivery Futures, Options, CrossEx, Alpha & OTC.
- WebSocket API for Gate.com Spot, Margin, Perpetual Futures, Delivery Futures & CrossEx.
- Automatic connectivity via existing WebsocketClient, just call sendWSAPIRequest to trigger a request.
- Automatic authentication, just call sendWSAPIRequest with channel & parameters.
- Choose between two interfaces for WS API communication:
- Event-driven interface, fire & forget via sendWSAPIRequest and receive async replies via wsClient's event emitter.
- Promise-driven interface, simply use the WebsocketAPIClient for a REST-like experience. Use the WebSocket API like a REST API! See examples/ws-api-client.ts for a demonstration.
- Heavy automated end-to-end testing with real API calls.
- Proxy support via axios integration.
- Active community support & collaboration in telegram: Node.js Algo Traders.
- QuickStart Guide: https://siebly.io/sdk/gate/javascript
- Gate JavaScript Tutorial: https://siebly.io/sdk/gate/javascript/tutorial
Table of Contents
Installation
npm install --save gateio-api
Frameworks & Quickstart Guides
Our complete Gate.io SDK supports all the major JavaScript runtimes. For maximum convenience, we've included guides to quickly get you started with the most popular runtimes. If you're not sure how to use this SDK with a runtime or framework not listed here, feel free to open an issue on GitHub.
Refer to runtime setup for installation commands, project configuration, and public price examples.
Examples
Refer to the examples folder for implementation demos, including:
- REST API Examples: spot trading, futures trading, account management
- WebSocket Examples: public market data streams, private account data, WebSocket API usage
- Spot Trading: comprehensive spot market examples
- Futures Trading: perpetual and delivery futures examples
- WebSocket API: both event-driven and promise-driven approaches
Issues & Discussion
- Issues? Check the issues tab.
- Discuss & collaborate with other node devs? Join our Node.js Algo Traders engineering community on telegram.
- Follow our announcement channel for real-time updates on X/Twitter
Related Projects
Check out our JavaScript/TypeScript/Node.js SDKs & Projects:
- Visit our website: https://Siebly.io
- Try our REST API & WebSocket SDKs published on npmjs:
- Try my misc utilities:
- Check out my examples:
Documentation
The Gate.io SDK documentation covers installation, client setup, public market data, authenticated trading, and WebSocket subscriptions.
Most methods accept JS objects. These can be populated using parameters specified by Gate.com's API documentation, or check the type definition in each class within this repository.
API Documentation Links
Structure
This project uses typescript. Resources are stored in 2 key structures:
- src - the whole connector written in typescript
- examples - some implementation examples & demonstrations. Contributions are welcome!
Usage
Create API credentials on Gate.com's website:
REST API
The SDK provides a unified RestClient for all Gate.com trading products including Spot, Margin, Perpetual Futures, Delivery Futures, Options, CrossEx, Alpha, and OTC Trading. This single client handles all REST API operations across all trading markets.
To use any of Gate.com's REST APIs in JavaScript/TypeScript/Node.js, import (or require) the RestClient: