Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ Updated & performant JavaScript & Node.js SDK for the Gate.com (gate.io) REST AP
- 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 & Announcements APIs.
- 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.
- WebSocket API for Gate.com Spot, Margin, Perpetual Futures & Delivery Futures.
- 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:
Expand Down Expand Up @@ -124,6 +127,9 @@ Most methods accept JS objects. These can be populated using parameters specifie
- [Margin Trading API](https://www.gate.com/docs/developers/apiv4/en/#margin-new)
- [Futures Trading API](https://www.gate.com/docs/developers/apiv4/en/#futures-new)
- [Options Trading API](https://www.gate.com/docs/developers/apiv4/en/#options-new)
- [CrossEx Trading API](https://www.gate.com/docs/developers/apiv4/en/#crossex)
- [Alpha Trading API](https://www.gate.com/docs/developers/apiv4/en/#alpha)
- [OTC Trading API](https://www.gate.com/docs/developers/apiv4/en/#otc)
- [WebSocket API](https://www.gate.com/docs/developers/apiv4/en/#websocket-api)
- [REST Endpoint Function List](./docs/endpointFunctionList.md)
- [TSDoc Documentation (autogenerated using typedoc)](https://tsdocs.dev/docs/gateio-api)
Expand All @@ -145,7 +151,7 @@ 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, and Options. This single client handles all REST API operations across all trading markets.
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`:

Expand All @@ -160,6 +166,7 @@ const client = new RestClient({
apiSecret: PRIVATE_KEY,
});

// Spot Trading Example
client
.getSpotTicker()
.then((result) => {
Expand All @@ -171,15 +178,51 @@ client

client
.getSpotOrders({
currency_pair: 'BTC_USDT', // Specify the currency pair
status: 'open', // Specify the status of the orders to fetch
currency_pair: 'BTC_USDT',
status: 'open',
})
.then((result) => {
console.log('getSpotOrders result: ', result);
})
.catch((err) => {
console.error('getSpotOrders error: ', err);
});

// CrossEx Trading Example - Trade across multiple exchanges
client
.getCrossExSymbols()
.then((result) => {
console.log('CrossEx symbols: ', result);
})
.catch((err) => {
console.error('CrossEx error: ', err);
});

// Alpha Trading Example - Trade meme tokens and new listings
client
.getAlphaCurrencies()
.then((result) => {
console.log('Alpha currencies: ', result);
})
.catch((err) => {
console.error('Alpha error: ', err);
});

// OTC Trading Example - Fiat and stablecoin trading
client
.createOTCQuote({
side: 'BUY',
pay_coin: 'USDT',
get_coin: 'USD',
pay_amount: '1000',
create_quote_token: '1',
})
.then((result) => {
console.log('OTC quote: ', result);
})
.catch((err) => {
console.error('OTC error: ', err);
});
```

See [RestClient](./src/RestClient.ts) for further information, or the [examples](./examples/) for lots of usage examples.
Expand Down
Loading
Loading