Gate TypeScript SDK
Crawlable snapshot of the Gate TypeScript SDK page with install and integration context.
What This SDK Covers
- Gate REST API integrations for exchange-specific workflows.
- Gate WebSocket support for market and account stream handling.
- TypeScript-friendly usage patterns for service and automation stacks.
- Routable examples under /examples for implementation reference.
Install Package
npm install gateio-api
# or
pnpm add gateio-api
yarn add gateio-api
Quickstart REST Walkthrough
Easily start calling Gate's futures REST APIs in JavaScript.
- Install the Gate.com (previously Gate.io) JavaScript SDK via NPM: `npm install gateio-api`. - Import the RestClient class (REST API wrapper for Gate's APIs). - Create an authenticated RestClient instance with your API credentials. - Call REST API methods as functions and await the promise containing the response.
In this example, we:
- Create both a REST client and authenticated WebSocket client. - Subscribe to private futures balance and user trade topics. - Query futures account balance for `usdt` settlement. - Calculate 50% of available balance and submit a market futures order on `BTC_USDT`. - Log API and stream responses for visibility.
This setup demonstrates a practical flow where private WebSocket subscriptions provide live account updates while REST handles account queries and order submission.
For a full map of available REST API methods, check out the endpoint reference below.
Quickstart REST Example
/**
* This example demonstrates a simple commented workflow of:
* - initialising the RestClient and WebsocketClient for Gate.io exchange
* - connecting to an accountโs private websockets (to receive updates asynchronously)
* - checking if connection is successful
* - fetching available futures balance
* - placing an order using 50% of the available balance
**/
import { RestClient, WebsocketClient } from 'gateio-api';
// Define the account object with API key and secret
const account = {
// Replace 'yourApiHere' with your actual API key or use environment variables
key: process.env.API_KEY || 'yourApiHere',
// Replace 'yourSecretHere' with your actual API secret or use environment variables
secret: process.env.API_SECRET || 'yourSecretHere',
};
// Initialize the RestClient with the API credentials
const gateRestClient = new RestClient({
apiKey: account.key,
apiSecret: account.secret,
});
// initialise websocket client - if you want only public data, you can initialise the client without the apiKey and apiSecret, just WebsocketClient()
const gateWSClient = new WebsocketClient({
apiKey: account.key,
apiSecret: account.secret,
});
// Data received
gateWSClient.on('update', (data) => {
console.info('data received: ', JSON.stringify(data));
});
async function subscribePrivateWs() {
try {
// Enter your user ID here
const myUserID = '20011';
//sub to balances updates
const userBalances = {
topic: 'futures.balances',
payload: [myUserID],
};
//sub to trades updates
const userTrades = {
topic: 'futures.usertrades',
payload: [myUserID, '!all'],
};
/**
* Either send one topic (with params) at a time
*/
// client.subscribe({
// topic: 'futures.usertrades',
// payload: [myUserID, '!all'],
// }, 'perpFuturesUSDTV4');
/**
* Or send multiple topics in a batch (grouped by ws connection (WsKey))
* You can also use strings for topics that don't have any parameters, even if you mix multiple requests into one function call:
*/
gateWSClient.subscribe([userBalances, userTrades], 'perpFuturesUSDTV4');
return true;
} catch (e) {
console.error('Req error: ', e);
throw e;
}
}
async function main() {
try {
await subscribePrivateWs();
console.log('Subscribed to privateWs topics!');
// Get futures account balance via REST
const balances = await gateRestClient.getFuturesAccount({ settle: 'usdt' });
// total usdt balance
// const usdtBalance = Number(balances.total);
// available usdt balance
const availableBalance = Number(balances.available);
// submit market order with 50% of the balance
const orderAmount = availableBalance * 0.5;
// Submit a market order with 50% of the balance
const marketOrder = await gateRestClient.submitFuturesOrder({
settle: 'usdt', // Specify the settlement currency
contract: 'BTC_USDT', // Specify the contract
size: orderAmount, // Order size: positive for long, negative for short, in USDT
price: '0', // Market order, so price is set to '0'
tif: 'ioc', // Time in force: 'ioc' (Immediate Or Cancel)
});
console.log('Order submitted:', marketOrder);
} catch (e) {
console.error(e);
throw e;
}
}
main();
// for more detailed ws connection, you can use a lot more listeners like below:
gateWSClient.on('open', (data) => {
console.log('connected ', data?.wsKey);
});
// Something happened, attempting to reconnect
gateWSClient.on('reconnect', (data) => {
console.log('reconnect: ', data);
});
// Reconnect successful
gateWSClient.on('reconnected', (data) => {
console.log('reconnected: ', data);
});
// Connection closed. If unexpected, expect reconnect -> reconnected.
gateWSClient.on('close', (data) => {
console.error('close: ', data);
});
// Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
gateWSClient.on('response', (data) => {
console.info('server reply: ', JSON.stringify(data), '\n');
});
gateWSClient.on('exception', (data) => {
console.error('exception: ', data);
});
gateWSClient.on('authenticated', (data) => {
console.error('authenticated: ', data);
});
Quickstart WebSocket Example
/* eslint-disable @typescript-eslint/no-unused-vars */
import { LogParams, WebsocketClient, WsTopicRequest } from 'gateio-api';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const account = {
key: process.env.API_KEY || 'apiKeyHere',
secret: process.env.API_SECRET || 'apiSecretHere',
};
// Define a custom logger object to handle logging at different levels
const customLogger = {
// Trace level logging: used for detailed debugging information
trace: (...params: LogParams): void => {
// Uncomment the line below to enable trace logging
// console.log(new Date(), 'trace', ...params);
},
// Info level logging: used for general informational messages
info: (...params: LogParams): void => {
console.log(new Date(), 'info', ...params);
},
// Error level logging: used for error messages
error: (...params: LogParams): void => {
console.error(new Date(), 'error', ...params);
},
};
async function start() {
const client = new WebsocketClient(
{
apiKey: account.key,
apiSecret: account.secret,
},
customLogger,
);
// console.log('auth with: ', account);
client.on('open', (data) => {
console.log('connected ', data?.wsKey);
});
// Data received
client.on('update', (data) => {
console.info('data received: ', JSON.stringify(data));
});
// Something happened, attempting to reconnect
client.on('reconnect', (data) => {
console.log('reconnect: ', data);
});
// Reconnect successful
client.on('reconnected', (data) => {
console.log('reconnected: ', data);
});
// Connection closed. If unexpected, expect reconnect -> reconnected.
client.on('close', (data) => {
console.error('close: ', data);
});
// Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
client.on('response', (data) => {
console.info('server reply: ', JSON.stringify(data), '\n');
});
client.on('exception', (data) => {
console.error('exception: ', data);
});
client.on('authenticated', (data) => {
console.error('authenticated: ', data);
});
try {
// client.subscribe(topics, 'spotV4');
const topicWithoutParamsAsString = 'spot.balances';
// This has the same effect as above, it's just a different way of messaging which topic this is for
// const topicWithoutParamsAsObject: WsTopicRequest = {
// topic: 'spot.balances',
// };
const userOrders: WsTopicRequest = {
topic: 'spot.orders',
payload: ['BTC_USDT', 'ETH_USDT', 'MATIC_USDT'],
};
const userTrades: WsTopicRequest = {
topic: 'spot.usertrades',
payload: ['BTC_USDT', 'ETH_USDT', 'MATIC_USDT'],
};
const userPriceOrders: WsTopicRequest = {
topic: 'spot.priceorders',
payload: ['!all'],
};
/**
* Either send one topic (with optional params) at a time
*/
// client.subscribe(topicWithoutParamsAsObject, 'spotV4');
/**
* Or send multiple topics in a batch (grouped by ws connection (WsKey))
* You can also use strings for topics that don't have any parameters, even if you mix multiple requests into one function call:
*/
client.subscribe(
[topicWithoutParamsAsString, userOrders, userTrades, userPriceOrders],
'spotV4',
);
/**
* You can also subscribe in separate function calls as you wish.
*
* Any duplicate requests should get filtered out (e.g. here we subscribed to "spot.balances" twice, but the WS client will filter this out)
*/
client.subscribe(
[
'spot.balances',
'spot.margin_balances',
'spot.funding_balances',
'spot.cross_balances',
],
'spotV4',
);
} catch (e) {
console.error('Req error: ', e);
}
}
start();
Quickstart WebSocket API Example
import { WebsocketAPIClient, WS_KEY_MAP } from 'gateio-api';
const account = {
key: process.env.API_KEY || 'insert_key_here',
secret: process.env.API_SECRET || 'insert_secret_here',
};
async function start() {
const client = new WebsocketAPIClient({
apiKey: account.key,
apiSecret: account.secret,
reauthWSAPIOnReconnect: true,
});
try {
/**
* Optional: authenticate in advance. This will prepare and authenticate a connection.
* Useful to save time for the first request but completely optional. It will also happen automatically when you make your first request.
*/
// console.log(new Date(), 'Authenticating in advance...');
// await client.getWSClient().connectWSAPI('spotV4');
// console.log(new Date(), 'Authenticating in advance...OK!');
/* ============ SPOT TRADING EXAMPLES ============ */
// SPOT ORDER PLACE - Submit a new spot order
const newOrder = await client.submitNewSpotOrder({
text: 't-my-custom-id',
currency_pair: 'BTC_USDT',
type: 'limit',
account: 'spot',
side: 'buy',
amount: '1',
price: '10000',
});
console.log(new Date(), 'Result of the order:', newOrder.data);
// SPOT ORDER CANCEL - Cancel a specific spot order
const cancelOrder = await client.cancelSpotOrder({
order_id: '1700664330',
currency_pair: 'BTC_USDT',
account: 'spot',
});
console.log(new Date(), 'Cancel order result:', cancelOrder.data);
// SPOT ORDER CANCEL BY IDS - Cancel orders by ID list
const cancelOrdersByIds = await client.cancelSpotOrderById([
{
currency_pair: 'BTC_USDT',
id: '1700664343',
account: 'spot',
},
]);
console.log(
new Date(),
'Cancel orders by IDs result:',
cancelOrdersByIds.data,
);
// SPOT ORDER CANCEL BY CURRENCY PAIR - Cancel all orders for a currency pair
const cancelOrdersByCurrencyPair = await client.cancelSpotOrderForSymbol({
currency_pair: 'BTC_USDT',
side: 'buy',
account: 'spot',
});
console.log(
new Date(),
'Cancel orders by currency pair result:',
cancelOrdersByCurrencyPair.data,
);
// SPOT ORDER AMEND - Update an existing spot order
const amendOrder = await client.updateSpotOrder({
order_id: '1700664330',
currency_pair: 'BTC_USDT',
price: '12000',
amount: '0.002',
amend_text: 'price-update',
});
console.log(new Date(), 'Amend order result:', amendOrder.data);
// SPOT ORDER STATUS - Get status of a specific spot order
const orderStatus = await client.getSpotOrderStatus({
order_id: '1700664330',
currency_pair: 'BTC_USDT',
account: 'spot',
});
console.log(new Date(), 'Order status result:', orderStatus.data);
// SPOT ORDER LIST - Get list of spot orders
const getOrders = await client.getSpotOrders({
currency_pair: 'BTC_USDT',
status: 'open',
page: 1,
limit: 10,
account: 'spot',
side: 'buy',
});
console.log(new Date(), 'Result of the orders:', getOrders.data);
/* ============ FUTURES TRADING EXAMPLES ============ */
/**
* Gate has different websocket groups depending on the futures product.
*
* This affects which connection your command is sent to, so make sure to pass one matching your request. Look at WS_KEY_MAP (or the examples below) for details on the available product groups.
*/
const FUTURES_CONNECTION_GROUP_WS_KEY = WS_KEY_MAP.perpFuturesUSDTV4;
/**
* Also optional, as for spot. Keep in mind the first parameter (wsKey) might vary depending on which WS URL is needed.
*/
// console.log(new Date(), 'Authenticating in advance...');
// await client.getWSClient().connectWSAPI(futuresConnectionGroup);
// await client.getWSClient().connectWSAPI('perpFuturesUSDTV4');
// await client.getWSClient().connectWSAPI('perpFuturesBTCV4');
// await client.getWSClient().connectWSAPI('deliveryFuturesUSDTV4');
// await client.getWSClient().connectWSAPI('perpFuturesBTCV4');
// console.log(new Date(), 'Authenticating in advance...OK!');
// FUTURES ORDER PLACE - Submit a new futures order
const newFuturesOrder = await client.submitNewFuturesOrder(
{
contract: 'BTC_USDT',
size: 10,
price: '31503.28',
tif: 'gtc',
text: 't-my-custom-id',
iceberg: 0,
close: false,
reduce_only: false,
auto_size: undefined,
stp_act: 'cn',
},
FUTURES_CONNECTION_GROUP_WS_KEY,
);
console.log(new Date(), 'New futures order result:', newFuturesOrder.data);
// FUTURES ORDER BATCH PLACE - Submit multiple futures orders
const batchFuturesOrders = await client.submitNewFuturesBatchOrder(
[
{
contract: 'BTC_USDT',
size: 10,
price: '31403.18',
tif: 'gtc',
text: 't-my-custom-id-1',
},
{
contract: 'ETH_USDT',
size: 20,
price: '2500.50',
tif: 'gtc',
text: 't-my-custom-id-2',
},
],
FUTURES_CONNECTION_GROUP_WS_KEY,
);
console.log(
new Date(),
'Batch futures orders result:',
batchFuturesOrders.data,
);
// FUTURES ORDER CANCEL - Cancel a specific futures order
const cancelFuturesOrder = await client.cancelFuturesOrder(
{
order_id: '74046514',
},
FUTURES_CONNECTION_GROUP_WS_KEY,
);
console.log(
new Date(),
'Cancel futures order result:',
cancelFuturesOrder.data,
);
// FUTURES ORDER CANCEL BY IDS - Cancel futures orders by ID list
const cancelFuturesOrdersByIds = await client.cancelFuturesOrderById(
['1694883366', '123'],
FUTURES_CONNECTION_GROUP_WS_KEY,
);
console.log(
new Date(),
'Cancel futures orders by IDs result:',
cancelFuturesOrdersByIds.data,
);
// FUTURES ORDER CANCEL ALL - Cancel all open futures orders
const cancelAllFuturesOrders = await client.cancelFuturesAllOpenOrders(
{
contract: 'BTC_USDT',
side: 'bid',
},
FUTURES_CONNECTION_GROUP_WS_KEY,
);
console.log(
new Date(),
'Cancel all futures orders result:',
cancelAllFuturesOrders.data,
);
// FUTURES ORDER AMEND - Update an existing futures order
const amendFuturesOrder = await client.updateFuturesOrder(
{
order_id: '74046543',
price: '31303.18',
size: 15,
amend_text: 'price-and-size-update',
},
FUTURES_CONNECTION_GROUP_WS_KEY,
);
console.log(
new Date(),
'Amend futures order result:',
amendFuturesOrder.data,
);
// FUTURES ORDER LIST - Get list of futures orders
const getFuturesOrders = await client.getFuturesOrders(
{
contract: 'BTC_USDT',
status: 'open',
limit: 10,
offset: 0,
last_id: undefined,
count_total: 0,
},
FUTURES_CONNECTION_GROUP_WS_KEY,
);
console.log(
new Date(),
'Futures orders list result:',
getFuturesOrders.data,
);
// FUTURES ORDER STATUS - Get status of a specific futures order
const futuresOrderStatus = await client.getFuturesOrderStatus(
{
order_id: '74046543',
},
FUTURES_CONNECTION_GROUP_WS_KEY,
);
console.log(
new Date(),
'Futures order status result:',
futuresOrderStatus.data,
);
} catch (e) {
console.error(new Date(), 'Error:', e);
}
}
start();
Endpoint Function Reference
Endpoint maps
Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.
The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.
This can be used to easily find which method to call, once you have found which endpoint you're looking to use.
All REST clients are in the src folder. For usage examples, make sure to check the examples folder.
List of clients:
If anything is missing or wrong, please open an issue or let us know in our Node.js Traders telegram group!
How to use table
Table consists of 4 parts:
- Function name
- AUTH
- HTTP Method
- Endpoint
Function name is the name of the function that can be called through the SDK. Check examples folder in the repo for more help on how to use them!
AUTH is a boolean value that indicates if the function requires authentication - which means you need to pass your API key and secret to the SDK.
HTTP Method shows HTTP method that the function uses to call the endpoint. Sometimes endpoints can have same URL, but different HTTP method so you can use this column to differentiate between them.
Endpoint is the URL that the function uses to call the endpoint. Best way to find exact function you need for the endpoint is to search for URL in this table and find corresponding function name.
RestClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in RestClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getSystemMaintenanceStatus() | GET | /v1/public/system_info | |
| submitWithdrawal() | ๐ | POST | /withdrawals |
| submitSpotMainAccountTransfer() | ๐ | POST | /withdrawals/push |
| cancelWithdrawal() | ๐ | DELETE | /withdrawals/{withdrawal_id} |
| getCurrencyChains() | GET | /wallet/currency_chains | |
| createDepositAddress() | ๐ | GET | /wallet/deposit_address |
| getWithdrawalRecords() | ๐ | GET | /wallet/withdrawals |
| getDepositRecords() | ๐ | GET | /wallet/deposits |
| submitTransfer() | ๐ | POST | /wallet/transfers |
| submitMainSubTransfer() | ๐ | POST | /wallet/sub_account_transfers |
| getMainSubTransfers() | ๐ | GET | /wallet/sub_account_transfers |
| submitSubToSubTransfer() | ๐ | POST | /wallet/sub_account_to_sub_account |
| getTransferStatus() | ๐ | GET | /wallet/order_status |
| getWithdrawalStatus() | ๐ | GET | /wallet/withdraw_status |
| getSubBalance() | ๐ | GET | /wallet/sub_account_balances |
| getSubMarginBalances() | ๐ | GET | /wallet/sub_account_margin_balances |
| getSubFuturesBalances() | ๐ | GET | /wallet/sub_account_futures_balances |
| getSubCrossMarginBalances() | ๐ | GET | /wallet/sub_account_cross_margin_balances |
| getSavedAddresses() | ๐ | GET | /wallet/saved_address |
| getTradingFees() | ๐ | GET | /wallet/fee |
| getBalances() | ๐ | GET | /wallet/total_balance |
| getSmallBalances() | ๐ | GET | /wallet/small_balance |
| convertSmallBalance() | ๐ | POST | /wallet/small_balance |
| getSmallBalanceHistory() | ๐ | GET | /wallet/small_balance_history |
| getPushOrders() | ๐ | GET | /wallet/push |
| getLowCapExchangeList() | ๐ | GET | /wallet/getLowCapExchangeList |
| createSubAccount() | ๐ | POST | /sub_accounts |
| getSubAccounts() | ๐ | GET | /sub_accounts |
| getSubAccount() | ๐ | GET | /sub_accounts/{user_id} |
| createSubAccountApiKey() | ๐ | POST | /sub_accounts/{user_id}/keys |
| getSubAccountApiKeys() | ๐ | GET | /sub_accounts/{user_id}/keys |
| updateSubAccountApiKey() | ๐ | PUT | /sub_accounts/{user_id}/keys/{key} |
| deleteSubAccountApiKey() | ๐ | DELETE | /sub_accounts/{user_id}/keys/{key} |
| getSubAccountApiKey() | ๐ | GET | /sub_accounts/{user_id}/keys/{key} |
| lockSubAccount() | ๐ | POST | /sub_accounts/{user_id}/lock |
| unlockSubAccount() | ๐ | POST | /sub_accounts/{user_id}/unlock |
| getSubAccountMode() | ๐ | GET | /sub_accounts/unified_mode |
| getUnifiedAccountInfo() | ๐ | GET | /unified/accounts |
| getUnifiedMaxBorrow() | ๐ | GET | /unified/borrowable |
| getUnifiedMaxTransferable() | ๐ | GET | /unified/transferable |
| getUnifiedMaxTransferables() | ๐ | GET | /unified/transferables |
| getUnifiedBatchMaxBorrowable() | ๐ | GET | /unified/batch_borrowable |
| submitUnifiedBorrowOrRepay() | ๐ | POST | /unified/loans |
| getUnifiedLoans() | ๐ | GET | /unified/loans |
| getUnifiedLoanRecords() | ๐ | GET | /unified/loan_records |
| getUnifiedInterestRecords() | ๐ | GET | /unified/interest_records |
| getUnifiedRiskUnitDetails() | ๐ | GET | /unified/risk_units |
| setUnifiedAccountMode() | ๐ | PUT | /unified/unified_mode |
| getUnifiedAccountMode() | ๐ | GET | /unified/unified_mode |
| getUnifiedEstimateRate() | ๐ | GET | /unified/estimate_rate |
| getUnifiedCurrencyDiscountTiers() | GET | /unified/currency_discount_tiers | |
| getLoanMarginTiers() | GET | /unified/loan_margin_tiers | |
| portfolioMarginCalculate() | POST | /unified/portfolio_calculator | |
| getUserCurrencyLeverageConfig() | ๐ | GET | /unified/leverage/user_currency_config |
| getUserCurrencyLeverageSettings() | ๐ | GET | /unified/leverage/user_currency_setting |
| updateUserCurrencyLeverage() | ๐ | POST | /unified/leverage/user_currency_setting |
| getUnifiedLoanCurrencies() | ๐ | GET | /unified/currencies |
| getHistoricalLendingRates() | ๐ | GET | /unified/history_loan_rate |
| submitUnifiedLoanRepay() | ๐ | POST | /unified/loans/repay |
| getSpotCurrencies() | GET | /spot/currencies | |
| getSpotCurrency() | GET | /spot/currencies/{currency} | |
| getSpotCurrencyPairs() | GET | /spot/currency_pairs | |
| getSpotCurrencyPair() | GET | /spot/currency_pairs/{currency_pair} | |
| getSpotTicker() | GET | /spot/tickers | |
| getSpotOrderBook() | GET | /spot/order_book | |
| getSpotTrades() | GET | /spot/trades | |
| getSpotCandles() | GET | /spot/candlesticks | |
| getSpotFeeRates() | ๐ | GET | /spot/fee |
| getSpotBatchFeeRates() | ๐ | GET | /spot/batch_fee |
| getSpotAccounts() | ๐ | GET | /spot/accounts |
| getSpotAccountBook() | ๐ | GET | /spot/account_book |
| submitSpotBatchOrders() | ๐ | POST | /spot/batch_orders |
| getSpotOpenOrders() | ๐ | GET | /spot/open_orders |
| submitSpotClosePosCrossDisabled() | ๐ | POST | /spot/cross_liquidate_orders |
| submitSpotOrder() | ๐ | POST | /spot/orders |
| getSpotOrders() | ๐ | GET | /spot/orders |
| cancelSpotOpenOrders() | ๐ | DELETE | /spot/orders |
| batchCancelSpotOrders() | ๐ | POST | /spot/cancel_batch_orders |
| getSpotOrder() | ๐ | GET | /spot/orders/{order_id} |
| updateSpotOrder() | ๐ | PATCH | /spot/orders/{order_id} |
| cancelSpotOrder() | ๐ | DELETE | /spot/orders/{order_id} |
| getSpotTradingHistory() | ๐ | GET | /spot/my_trades |
| submitSpotCountdownOrders() | ๐ | POST | /spot/countdown_cancel_all |
| batchUpdateSpotOrders() | ๐ | POST | /spot/amend_batch_orders |
| getSpotInsuranceHistory() | ๐ | GET | /spot/insurance_history |
| submitSpotPriceTriggerOrder() | ๐ | POST | /spot/price_orders |
| getSpotAutoOrders() | ๐ | GET | /spot/price_orders |
| cancelAllOpenSpotOrders() | ๐ | DELETE | /spot/price_orders |
| getPriceTriggeredOrder() | ๐ | GET | /spot/price_orders/{order_id} |
| cancelSpotTriggeredOrder() | ๐ | DELETE | /spot/price_orders/{order_id} |
| setCollateralCurrency() | ๐ | POST | /unified/collateral_currencies |
| getMarginAccounts() | ๐ | GET | /margin/accounts |
| getMarginBalanceHistory() | ๐ | GET | /margin/account_book |
| getFundingAccounts() | ๐ | GET | /margin/funding_accounts |
| updateAutoRepaymentSetting() | ๐ | POST | /margin/auto_repay |
| getAutoRepaymentSetting() | ๐ | GET | /margin/auto_repay |
| getMarginTransferableAmount() | ๐ | GET | /margin/transferable |
| getCrossMarginCurrencies() | GET | /margin/cross/currencies | |
| getCrossMarginCurrency() | GET | /margin/cross/currencies/{currency} | |
| getCrossMarginAccount() | ๐ | GET | /margin/cross/accounts |
| getCrossMarginAccountHistory() | ๐ | GET | /margin/cross/account_book |
| submitCrossMarginBorrowLoan() | ๐ | POST | /margin/cross/loans |
| getCrossMarginBorrowHistory() | ๐ | GET | /margin/cross/loans |
| getCrossMarginBorrowLoan() | ๐ | GET | /margin/cross/loans/{loan_id} |
| submitCrossMarginRepayment() | ๐ | POST | /margin/cross/repayments |
| getCrossMarginRepayments() | ๐ | GET | /margin/cross/repayments |
| getCrossMarginInterestRecords() | ๐ | GET | /margin/cross/interest_records |
| getCrossMarginTransferableAmount() | ๐ | GET | /margin/cross/transferable |
| getEstimatedInterestRates() | ๐ | GET | /margin/cross/estimate_rate |
| getCrossMarginBorrowableAmount() | ๐ | GET | /margin/cross/borrowable |
| getMarginUserLoanTiers() | ๐ | GET | /margin/user/loan_margin_tiers |
| getMarginPublicLoanTiers() | GET | /margin/loan_margin_tiers | |
| setMarginUserLeverage() | ๐ | POST | /margin/leverage/user_market_setting |
| getMarginUserAccounts() | ๐ | GET | /margin/user/account |
| getLendingMarkets() | GET | /margin/uni/currency_pairs | |
| getLendingMarket() | GET | /margin/uni/currency_pairs/{currency_pair} | |
| getEstimatedInterestRate() | ๐ | GET | /margin/uni/estimate_rate |
| submitMarginUNIBorrowOrRepay() | ๐ | POST | /margin/uni/loans |
| getMarginUNILoans() | ๐ | GET | /margin/uni/loans |
| getMarginUNILoanRecords() | ๐ | GET | /margin/uni/loan_records |
| getMarginUNIInterestRecords() | ๐ | GET | /margin/uni/interest_records |
| getMarginUNIMaxBorrow() | ๐ | GET | /margin/uni/borrowable |
| getFlashSwapCurrencyPairs() | GET | /flash_swap/currency_pairs | |
| submitFlashSwapOrder() | ๐ | POST | /flash_swap/orders |
| getFlashSwapOrders() | ๐ | GET | /flash_swap/orders |
| getFlashSwapOrder() | ๐ | GET | /flash_swap/orders/{order_id} |
| submitFlashSwapOrderPreview() | ๐ | POST | /flash_swap/orders/preview |
| getFuturesContracts() | GET | /futures/{settle}/contracts | |
| getFuturesContract() | GET | /futures/{settle}/contracts/{contract} | |
| getFuturesOrderBook() | GET | /futures/{settle}/order_book | |
| getFuturesTrades() | GET | /futures/{settle}/trades | |
| getFuturesCandles() | GET | /futures/{settle}/candlesticks | |
| getPremiumIndexKLines() | GET | /futures/{settle}/premium_index | |
| getFuturesTickers() | GET | /futures/{settle}/tickers | |
| getFundingRates() | GET | /futures/{settle}/funding_rate | |
| getFuturesInsuranceBalanceHistory() | GET | /futures/{settle}/insurance | |
| getFuturesStats() | GET | /futures/{settle}/contract_stats | |
| getIndexConstituents() | GET | /futures/{settle}/index_constituents/{index} | |
| getLiquidationHistory() | GET | /futures/{settle}/liq_orders | |
| getRiskLimitTiers() | GET | /futures/{settle}/risk_limit_tiers | |
| getFuturesAccount() | ๐ | GET | /futures/{settle}/accounts |
| getFuturesAccountBook() | ๐ | GET | /futures/{settle}/account_book |
| getFuturesPositions() | ๐ | GET | /futures/{settle}/positions |
| getFuturesPosition() | ๐ | GET | /futures/{settle}/positions/{contract} |
| updateFuturesMargin() | ๐ | POST | /futures/{settle}/positions/{contract}/margin |
| updateFuturesLeverage() | ๐ | POST | /futures/{settle}/positions/{contract}/leverage |
| updateFuturesPositionMode() | ๐ | POST | /futures/{settle}/positions/cross_mode |
| updatePositionRiskLimit() | ๐ | POST | /futures/{settle}/positions/{contract}/risk_limit |
| updateFuturesDualMode() | ๐ | POST | /futures/{settle}/dual_mode |
| getDualModePosition() | ๐ | GET | /futures/{settle}/dual_comp/positions/{contract} |
| updateDualModePositionMargin() | ๐ | POST | /futures/{settle}/dual_comp/positions/{contract}/margin |
| updateDualModePositionLeverage() | ๐ | POST | /futures/{settle}/dual_comp/positions/{contract}/leverage |
| updateDualModePositionRiskLimit() | ๐ | POST | /futures/{settle}/dual_comp/positions/{contract}/risk_limit |
| submitFuturesOrder() | ๐ | POST | /futures/{settle}/orders |
| getFuturesOrders() | ๐ | GET | /futures/{settle}/orders |
| cancelAllFuturesOrders() | ๐ | DELETE | /futures/{settle}/orders |
| getFuturesOrdersByTimeRange() | ๐ | GET | /futures/{settle}/orders_timerange |
| submitFuturesBatchOrders() | ๐ | POST | /futures/{settle}/batch_orders |
| getFuturesOrder() | ๐ | GET | /futures/{settle}/orders/{order_id} |
| cancelFuturesOrder() | ๐ | DELETE | /futures/{settle}/orders/{order_id} |
| updateFuturesOrder() | ๐ | PUT | /futures/{settle}/orders/{order_id} |
| getFuturesTradingHistory() | ๐ | GET | /futures/{settle}/my_trades |
| getFuturesTradingHistoryByTimeRange() | ๐ | GET | /futures/{settle}/my_trades_timerange |
| getFuturesPositionHistory() | ๐ | GET | /futures/{settle}/position_close |
| getFuturesLiquidationHistory() | ๐ | GET | /futures/{settle}/liquidates |
| getFuturesAutoDeleveragingHistory() | ๐ | GET | /futures/{settle}/auto_deleverages |
| setFuturesOrderCancelCountdown() | ๐ | POST | /futures/{settle}/countdown_cancel_all |
| getFuturesUserTradingFees() | ๐ | GET | /futures/{settle}/fee |
| batchCancelFuturesOrders() | ๐ | POST | /futures/{settle}/batch_cancel_orders |
| batchUpdateFuturesOrders() | ๐ | POST | /futures/{settle}/batch_amend_orders |
| getRiskLimitTable() | GET | /futures/{settle}/risk_limit_table | |
| submitFuturesPriceTriggeredOrder() | ๐ | POST | /futures/{settle}/price_orders |
| getFuturesAutoOrders() | ๐ | GET | /futures/{settle}/price_orders |
| cancelAllOpenFuturesOrders() | ๐ | DELETE | /futures/{settle}/price_orders |
| getFuturesPriceTriggeredOrder() | ๐ | GET | /futures/{settle}/price_orders/{order_id} |
| cancelFuturesPriceTriggeredOrder() | ๐ | DELETE | /futures/{settle}/price_orders/{order_id} |
| updateFuturesPriceTriggeredOrder() | ๐ | PUT | /futures/{settle}/price_orders/{order_id} |
| getFuturesPositionCloseHistory() | ๐ | GET | /futures/{settle}/position_close_history |
| getFuturesInsuranceHistory() | ๐ | GET | /futures/{settle}/insurance |
| getAllDeliveryContracts() | GET | /delivery/{settle}/contracts | |
| getDeliveryContract() | GET | /delivery/{settle}/contracts/{contract} | |
| getDeliveryOrderBook() | GET | /delivery/{settle}/order_book | |
| getDeliveryTrades() | GET | /delivery/{settle}/trades | |
| getDeliveryCandles() | GET | /delivery/{settle}/candlesticks | |
| getDeliveryTickers() | GET | /delivery/{settle}/tickers | |
| getDeliveryInsuranceBalanceHistory() | GET | /delivery/{settle}/insurance | |
| getDeliveryAccount() | ๐ | GET | /delivery/{settle}/accounts |
| getDeliveryBook() | ๐ | GET | /delivery/{settle}/account_book |
| getDeliveryPositions() | ๐ | GET | /delivery/{settle}/positions |
| getDeliveryPosition() | ๐ | GET | /delivery/{settle}/positions/{contract} |
| updateDeliveryMargin() | ๐ | POST | /delivery/{settle}/positions/{contract}/margin |
| updateDeliveryLeverage() | ๐ | POST | /delivery/{settle}/positions/{contract}/leverage |
| updateDeliveryRiskLimit() | ๐ | POST | /delivery/{settle}/positions/{contract}/risk_limit |
| submitDeliveryOrder() | ๐ | POST | /delivery/{settle}/orders |
| getDeliveryOrders() | ๐ | GET | /delivery/{settle}/orders |
| cancelAllDeliveryOrders() | ๐ | DELETE | /delivery/{settle}/orders |
| getDeliveryOrder() | ๐ | GET | /delivery/{settle}/orders/{order_id} |
| cancelDeliveryOrder() | ๐ | DELETE | /delivery/{settle}/orders/{order_id} |
| getDeliveryTradingHistory() | ๐ | GET | /delivery/{settle}/my_trades |
| getDeliveryClosedPositions() | ๐ | GET | /delivery/{settle}/position_close |
| getDeliveryLiquidationHistory() | ๐ | GET | /delivery/{settle}/liquidates |
| getDeliverySettlementHistory() | ๐ | GET | /delivery/{settle}/settlements |
| submitDeliveryTriggeredOrder() | ๐ | POST | /delivery/{settle}/price_orders |
| getDeliveryAutoOrders() | ๐ | GET | /delivery/{settle}/price_orders |
| cancelAllOpenDeliveryOrders() | ๐ | DELETE | /delivery/{settle}/price_orders |
| getDeliveryTriggeredOrder() | ๐ | GET | /delivery/{settle}/price_orders/{order_id} |
| cancelTriggeredDeliveryOrder() | ๐ | DELETE | /delivery/{settle}/price_orders/{order_id} |
| getOptionsUnderlyings() | GET | /options/underlyings | |
| getOptionsExpirationTimes() | GET | /options/expirations | |
| getOptionsContracts() | GET | /options/contracts | |
| getOptionsContract() | GET | /options/contracts/{contract} | |
| getOptionsSettlementHistory() | GET | /options/settlements | |
| getOptionsContractSettlement() | GET | /options/settlements/{contract} | |
| getOptionsMySettlements() | ๐ | GET | /options/my_settlements |
| getOptionsOrderBook() | GET | /options/order_book | |
| getOptionsTickers() | GET | /options/tickers | |
| getOptionsUnderlyingTicker() | GET | /options/underlying/tickers/{underlying} | |
| getOptionsCandles() | GET | /options/candlesticks | |
| getOptionsUnderlyingCandles() | GET | /options/underlying/candlesticks | |
| getOptionsTrades() | GET | /options/trades | |
| getOptionsAccount() | ๐ | GET | /options/accounts |
| getOptionsAccountChange() | ๐ | GET | /options/account_book |
| getOptionsPositionsUnderlying() | ๐ | GET | /options/positions |
| getOptionsPositionContract() | ๐ | GET | /options/positions/{contract} |
| getOptionsLiquidation() | ๐ | GET | /options/position_close |
| submitOptionsOrder() | ๐ | POST | /options/orders |
| getOptionsOrders() | ๐ | GET | /options/orders |
| cancelAllOpenOptionsOrders() | ๐ | DELETE | /options/orders |
| getOptionsOrder() | ๐ | GET | /options/orders/{order_id} |
| cancelOptionsOrder() | ๐ | DELETE | /options/orders/{order_id} |
| submitOptionsCountdownCancel() | ๐ | POST | /options/countdown_cancel_all |
| getOptionsPersonalHistory() | ๐ | GET | /options/my_trades |
| setOptionsMMPSettings() | ๐ | POST | /options/mmp |
| getOptionsMMPSettings() | ๐ | GET | /options/mmp |
| resetOptionsMMPSettings() | ๐ | POST | /options/mmp/reset |
| getLendingCurrencies() | GET | /earn/uni/currencies | |
| getLendingCurrency() | GET | /earn/uni/currencies/{currency} | |
| submitLendOrRedeemOrder() | ๐ | POST | /earn/uni/lends |
| getLendingOrders() | ๐ | GET | /earn/uni/lends |
| updateLendingOrder() | ๐ | PATCH | /earn/uni/lends |
| getLendingRecords() | ๐ | GET | /earn/uni/lend_records |
| getLendingTotalInterest() | ๐ | GET | /earn/uni/interests/{currency} |
| getLendingInterestRecords() | ๐ | GET | /earn/uni/interest_records |
| updateInterestReinvestment() | ๐ | PUT | /earn/uni/interest_reinvest |
| getLendingInterestStatus() | ๐ | GET | /earn/uni/interest_status/{currency} |
| getLendingAnnualizedTrendChart() | ๐ | GET | /earn/uni/chart |
| getLendingEstimatedRates() | ๐ | GET | /earn/uni/rate |
| submitLoanOrder() | ๐ | POST | /loan/collateral/orders |
| getLoanOrders() | ๐ | GET | /loan/collateral/orders |
| getLoanOrder() | ๐ | GET | /loan/collateral/orders/{order_id} |
| submitLoanRepay() | ๐ | POST | /loan/collateral/repay |
| getLoanRepaymentHistory() | ๐ | GET | /loan/collateral/repay_records |
| updateLoanCollateral() | ๐ | POST | /loan/collateral/collaterals |
| getLoanCollateralRecords() | ๐ | GET | /loan/collateral/collaterals |
| getLoanTotalAmount() | ๐ | GET | /loan/collateral/total_amount |
| getLoanCollateralizationRatio() | ๐ | GET | /loan/collateral/ltv |
| getLoanSupportedCurrencies() | GET | /loan/collateral/currencies | |
| submitMultiLoanOrder() | ๐ | POST | /loan/multi_collateral/orders |
| getMultiLoanOrders() | ๐ | GET | /loan/multi_collateral/orders |
| getMultiLoanOrder() | ๐ | GET | /loan/multi_collateral/orders/{order_id} |
| repayMultiLoan() | ๐ | POST | /loan/multi_collateral/repay |
| getMultiLoanRepayRecords() | ๐ | GET | /loan/multi_collateral/repay |
| updateMultiLoan() | ๐ | POST | /loan/multi_collateral/mortgage |
| getMultiLoanAdjustmentRecords() | ๐ | GET | /loan/multi_collateral/mortgage |
| getMultiLoanCurrencyQuota() | ๐ | GET | /loan/multi_collateral/currency_quota |
| getMultiLoanSupportedCurrencies() | GET | /loan/multi_collateral/currencies | |
| getMultiLoanRatio() | GET | /loan/multi_collateral/ltv | |
| getMultiLoanFixedRates() | GET | /loan/multi_collateral/fixed_rate | |
| getMultiLoanCurrentRates() | GET | /loan/multi_collateral/current_rate | |
| submitEth2Swap() | ๐ | POST | /earn/staking/eth2/swap |
| getEth2RateHistory() | ๐ | GET | /earn/staking/eth2/rate_records |
| getDualInvestmentProducts() | GET | /earn/dual/investment_plan | |
| getDualInvestmentOrders() | ๐ | GET | /earn/dual/orders |
| submitDualInvestmentOrder() | ๐ | POST | /earn/dual/orders |
| getStructuredProducts() | GET | /earn/structured/products | |
| getStructuredProductOrders() | ๐ | GET | /earn/structured/orders |
| submitStructuredProductOrder() | ๐ | POST | /earn/structured/orders |
| getStakingCoins() | ๐ | GET | /earn/staking/coins |
| submitStakingSwap() | ๐ | POST | /earn/staking/swap |
| getAccountDetail() | ๐ | GET | /account/detail |
| getAccountRateLimit() | ๐ | GET | /account/rate_limit |
| createStpGroup() | ๐ | POST | /account/stp_groups |
| getStpGroups() | ๐ | GET | /account/stp_groups |
| getStpGroupUsers() | ๐ | GET | /account/stp_groups/{stp_id}/users |
| addUsersToStpGroup() | ๐ | POST | /account/stp_groups/{stp_id}/users |
| deleteUserFromStpGroup() | ๐ | DELETE | /account/stp_groups/{stp_id}/users |
| setGTDeduction() | ๐ | POST | /account/debit_fee |
| getGTDeduction() | ๐ | GET | /account/debit_fee |
| getAccountMainKeys() | ๐ | GET | /account/main_keys |
| getAgencyTransactionHistory() | ๐ | GET | /rebate/agency/transaction_history |
| getAgencyCommissionHistory() | ๐ | GET | /rebate/agency/commission_history |
| getPartnerTransactionHistory() | ๐ | GET | /rebate/partner/transaction_history |
| getPartnerCommissionHistory() | ๐ | GET | /rebate/partner/commission_history |
| getPartnerSubordinateList() | ๐ | GET | /rebate/partner/sub_list |
| getBrokerCommissionHistory() | ๐ | GET | /rebate/broker/commission_history |
| getBrokerTransactionHistory() | ๐ | GET | /rebate/broker/transaction_history |
| getUserRebateInfo() | ๐ | GET | /rebate/user/info |
| createOTCQuote() | ๐ | POST | /otc/quote |
| createOTCFiatOrder() | ๐ | POST | /otc/order/create |
| createOTCStablecoinOrder() | ๐ | POST | /otc/stable_coin/order/create |
| getOTCUserDefaultBank() | ๐ | GET | /otc/get_user_def_bank |
| markOTCOrderAsPaid() | ๐ | POST | /otc/order/paid |
| cancelOTCOrder() | ๐ | POST | /otc/order/cancel |
| getOTCFiatOrderList() | ๐ | GET | /otc/order/list |
| getOTCStablecoinOrderList() | ๐ | GET | /otc/stable_coin/order/list |
| getOTCFiatOrderDetail() | ๐ | GET | /otc/order/detail |
| getCrossExSymbols() | GET | /crossex/rule/symbols | |
| getCrossExRiskLimits() | GET | /crossex/rule/risk_limits | |
| getCrossExTransferCoins() | GET | /crossex/transfers/coin | |
| createCrossExTransfer() | ๐ | POST | /crossex/transfers |
| getCrossExTransferHistory() | ๐ | GET | /crossex/transfers |
| createCrossExOrder() | ๐ | POST | /crossex/orders |
| cancelCrossExOrder() | ๐ | DELETE | /crossex/orders/{order_id} |
| modifyCrossExOrder() | ๐ | PUT | /crossex/orders/{order_id} |
| getCrossExOrder() | ๐ | GET | /crossex/orders/{order_id} |
| createCrossExConvertQuote() | ๐ | POST | /crossex/convert/quote |
| createCrossExConvertOrder() | ๐ | POST | /crossex/convert/orders |
| updateCrossExAccount() | ๐ | PUT | /crossex/accounts |
| getCrossExAccounts() | ๐ | GET | /crossex/accounts |
| setCrossExPositionLeverage() | ๐ | POST | /crossex/positions/leverage |
| getCrossExPositionLeverage() | ๐ | GET | /crossex/positions/leverage |
| setCrossExMarginPositionLeverage() | ๐ | POST | /crossex/margin_positions/leverage |
| getCrossExMarginPositionLeverage() | ๐ | GET | /crossex/margin_positions/leverage |
| closeCrossExPosition() | ๐ | DELETE | /crossex/position |
| getCrossExInterestRate() | ๐ | GET | /crossex/interest_rate |
| getCrossExFeeRate() | ๐ | GET | /crossex/fee |
| getCrossExPositions() | ๐ | GET | /crossex/positions |
| getCrossExMarginPositions() | ๐ | GET | /crossex/margin_positions |
| getCrossExAdlRank() | ๐ | GET | /crossex/adl_rank |
| getCrossExOpenOrders() | ๐ | GET | /crossex/open_orders |
| getCrossExHistoryOrders() | ๐ | GET | /crossex/history_orders |
| getCrossExHistoryPositions() | ๐ | GET | /crossex/history_positions |
| getCrossExHistoryMarginPositions() | ๐ | GET | /crossex/history_margin_positions |
| getCrossExHistoryMarginInterests() | ๐ | GET | /crossex/history_margin_interests |
| getCrossExHistoryTrades() | ๐ | GET | /crossex/history_trades |
| getCrossExAccountBook() | ๐ | GET | /crossex/account_book |
| getCrossExCoinDiscountRate() | ๐ | GET | /crossex/coin_discount_rate |
| getAlphaAccounts() | ๐ | GET | /alpha/accounts |
| getAlphaAccountBook() | ๐ | GET | /alpha/account_book |
| createAlphaQuote() | ๐ | POST | /alpha/quote |
| createAlphaOrder() | ๐ | POST | /alpha/orders |
| getAlphaOrders() | ๐ | GET | /alpha/orders |
| getAlphaOrder() | ๐ | GET | /alpha/order |
| getAlphaCurrencies() | GET | /alpha/currencies | |
| getAlphaTickers() | GET | /alpha/tickers |
WebsocketAPIClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in WebsocketAPIClient.ts.
This client provides WebSocket API endpoints which allow for faster interactions with the Gate.io API via a WebSocket connection.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| submitNewSpotOrder() | ๐ | WS | spot.order_place |
| cancelSpotOrder() | ๐ | WS | spot.order_cancel |
| cancelSpotOrderById() | ๐ | WS | spot.order_cancel_ids |
| cancelSpotOrderForSymbol() | ๐ | WS | spot.order_cancel_cp |
| updateSpotOrder() | ๐ | WS | spot.order_amend |
| getSpotOrderStatus() | ๐ | WS | spot.order_status |
| getSpotOrders() | ๐ | WS | spot.order_list |
| submitNewFuturesOrder() | ๐ | WS | futures.order_place |
| submitNewFuturesBatchOrder() | ๐ | WS | futures.order_batch_place |
| cancelFuturesOrder() | ๐ | WS | futures.order_cancel |
| cancelFuturesOrderById() | ๐ | WS | futures.order_cancel_ids |
| cancelFuturesAllOpenOrders() | ๐ | WS | futures.order_cancel_cp |
| updateFuturesOrder() | ๐ | WS | futures.order_amend |
| getFuturesOrders() | ๐ | WS | futures.order_list |
| getFuturesOrderStatus() | ๐ | WS | futures.order_status |
Source: View endpoint map source
Reference Links
This is a static, crawlable snapshot. The interactive app loads after JavaScript starts and can refresh live data.