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
559 changes: 283 additions & 276 deletions docs/endpointFunctionList.md

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/getEth2RateHistory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { RestClient } = require('gateio-api');

// This example shows how to call this Gate.io API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "gateio-api" for Gate.io exchange
// This Gate.io API SDK is available on npm via "npm install gateio-api"
// ENDPOINT: /earn/staking/eth2/rate_records
// METHOD: GET
// PUBLIC: NO

const client = new RestClient({
apiKey: 'insert_api_key_here',
apiSecret: 'insert_api_secret_here',
});

client.getEth2RateHistory(params)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/getMarginPublicLoanTiers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { RestClient } = require('gateio-api');

// This example shows how to call this Gate.io API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "gateio-api" for Gate.io exchange
// This Gate.io API SDK is available on npm via "npm install gateio-api"
// ENDPOINT: /margin/loan_margin_tiers
// METHOD: GET
// PUBLIC: YES

const client = new RestClient({
apiKey: 'insert_api_key_here',
apiSecret: 'insert_api_secret_here',
});

client.getMarginPublicLoanTiers(params)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/getMarginUserAccounts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { RestClient } = require('gateio-api');

// This example shows how to call this Gate.io API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "gateio-api" for Gate.io exchange
// This Gate.io API SDK is available on npm via "npm install gateio-api"
// ENDPOINT: /margin/user/account
// METHOD: GET
// PUBLIC: NO

const client = new RestClient({
apiKey: 'insert_api_key_here',
apiSecret: 'insert_api_secret_here',
});

client.getMarginUserAccounts(params)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/getMarginUserLoanTiers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { RestClient } = require('gateio-api');

// This example shows how to call this Gate.io API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "gateio-api" for Gate.io exchange
// This Gate.io API SDK is available on npm via "npm install gateio-api"
// ENDPOINT: /margin/user/loan_margin_tiers
// METHOD: GET
// PUBLIC: NO

const client = new RestClient({
apiKey: 'insert_api_key_here',
apiSecret: 'insert_api_secret_here',
});

client.getMarginUserLoanTiers(params)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/getUnifiedLoanCurrencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { RestClient } = require('gateio-api');

// This example shows how to call this Gate.io API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "gateio-api" for Gate.io exchange
// This Gate.io API SDK is available on npm via "npm install gateio-api"
// ENDPOINT: /unified/currencies
// METHOD: GET
// PUBLIC: NO

const client = new RestClient({
apiKey: 'insert_api_key_here',
apiSecret: 'insert_api_secret_here',
});

client.getUnifiedLoanCurrencies(params)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/getUnifiedMaxTransferables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { RestClient } = require('gateio-api');

// This example shows how to call this Gate.io API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "gateio-api" for Gate.io exchange
// This Gate.io API SDK is available on npm via "npm install gateio-api"
// ENDPOINT: /unified/transferables
// METHOD: GET
// PUBLIC: NO

const client = new RestClient({
apiKey: 'insert_api_key_here',
apiSecret: 'insert_api_secret_here',
});

client.getUnifiedMaxTransferables(params)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/setMarginUserLeverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { RestClient } = require('gateio-api');

// This example shows how to call this Gate.io API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "gateio-api" for Gate.io exchange
// This Gate.io API SDK is available on npm via "npm install gateio-api"
// ENDPOINT: /margin/leverage/user_market_setting
// METHOD: POST
// PUBLIC: NO

const client = new RestClient({
apiKey: 'insert_api_key_here',
apiSecret: 'insert_api_secret_here',
});

client.setMarginUserLeverage(params)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gateio-api",
"version": "1.1.6",
"version": "1.1.7",
"description": "Complete & robust Node.js SDK for Gate.io's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
"scripts": {
"clean": "rm -rf dist/*",
Expand Down
119 changes: 114 additions & 5 deletions src/RestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ import {
CrossMarginMorrowLoanRecord,
MarginAccount,
MarginBalanceHistoryRecord,
MarginUserAccount,
} from './types/response/margin.js';
import {
LendingMarket,
Expand Down Expand Up @@ -300,6 +301,7 @@ import {
UnifiedHistoryLendingRate,
UnifiedInterestRecord,
UnifiedLoan,
UnifiedLoanCurrency,
UnifiedLoanRecord,
UnifiedRiskUnitDetails,
UserCurrencyLeverageConfig,
Expand All @@ -320,7 +322,7 @@ import {
WithdrawalStatus,
} from './types/response/wallet.js';
import { WithdrawalRecord } from './types/response/withdrawal.js';
import { CurrencyPair } from './types/shared.js';
import { CurrencyPair, FromToPageLimit } from './types/shared.js';

/**
* Unified REST API client for all of Gate's REST APIs
Expand Down Expand Up @@ -932,6 +934,23 @@ export class RestClient extends BaseRestClient {
return this.getPrivate('/unified/transferable', params);
}

/**
* Batch query maximum transferable amounts for unified accounts
*
* After withdrawing currency, the transferable amount will change.
*
* @param params Parameters containing currencies to query (up to 100 at once)
* @returns Promise with array of currency and maximum transferable amount
*/
getUnifiedMaxTransferables(params: { currencies: string }): Promise<
{
currency: string;
amount: string;
}[]
> {
return this.getPrivate('/unified/transferables', params);
}

/**
* Borrow or repay
*
Expand Down Expand Up @@ -1114,6 +1133,18 @@ export class RestClient extends BaseRestClient {
});
}

/**
* List loan currencies supported by unified account
*
* @param params Optional parameters for filtering
* @returns Promise with array of loan currencies
*/
getUnifiedLoanCurrencies(params?: {
currency?: string;
}): Promise<UnifiedLoanCurrency[]> {
return this.getPrivate('/unified/currencies', params);
}

/**
* Get historical lending rates
*
Expand Down Expand Up @@ -1924,6 +1955,67 @@ export class RestClient extends BaseRestClient {
return this.getPrivate('/margin/cross/borrowable', params);
}

/**
* Check the user's own leverage lending gradient in the current market
*
* @param params Parameters containing currency pair to query
* @returns Promise with array of market gradient information
*/
getMarginUserLoanTiers(params: { currency_pair: string }): Promise<
{
tier_amount: string;
mmr: string;
leverage: string;
}[]
> {
return this.getPrivate('/margin/user/loan_margin_tiers', params);
}

/**
* Query the current market leverage lending gradient
*
* @param params Parameters containing currency pair to query
* @returns Promise with array of market gradient information
*/
getMarginPublicLoanTiers(params: { currency_pair: string }): Promise<
{
tier_amount: string;
mmr: string;
leverage: string;
}[]
> {
return this.get('/margin/loan_margin_tiers', params);
}

/**
* Set the user market leverage multiple
*
* @param params Parameters containing currency pair and leverage value
* @returns Promise<void> - Returns nothing on success (204 No Content)
*/
setMarginUserLeverage(params: {
currency_pair: string;
leverage: string;
}): Promise<any> {
return this.postPrivate('/margin/leverage/user_market_setting', {
body: params,
});
}

/**
* Query the user's leverage account list
*
* Supports querying risk rate per position account and margin rate per position account
*
* @param params Optional parameters for filtering by currency pair
* @returns Promise with array of margin account details
*/
getMarginUserAccounts(params?: {
currency_pair?: string;
}): Promise<MarginUserAccount[]> {
return this.getPrivate('/margin/user/account', params);
}

/**==========================================================================================================================
* MARGIN UNI
* ==========================================================================================================================
Expand Down Expand Up @@ -4067,22 +4159,39 @@ export class RestClient extends BaseRestClient {
return this.postPrivate(`/earn/staking/eth2/swap`, { body: params });
}

/**
* Get ETH2 historical rate of return data
*
* Returns the ETH earnings rate record for the last 31 days
*
* @returns Promise<Array<{date_time: number, date: string, rate: string}>>
*/
getEth2RateHistory(): Promise<
{ date_time: number; date: string; rate: string }[]
> {
return this.getPrivate(`/earn/staking/eth2/rate_records`);
}

/**
* Dual Investment product list
*
* @returns Promise<GetDualInvestmentProductsResp[]>
*/
getDualInvestmentProducts(): Promise<DualInvestmentProduct[]> {
return this.get(`/earn/dual/investment_plan`);
getDualInvestmentProducts(params?: {
plan_id?: string;
}): Promise<DualInvestmentProduct[]> {
return this.get(`/earn/dual/investment_plan`, params);
}

/**
* Dual Investment order list
*
* @returns Promise<GetDualInvestmentOrdersResp[]>
*/
getDualInvestmentOrders(): Promise<DualInvestmentOrder[]> {
return this.getPrivate(`/earn/dual/orders`);
getDualInvestmentOrders(
params?: FromToPageLimit,
): Promise<DualInvestmentOrder[]> {
return this.getPrivate(`/earn/dual/orders`, params);
}
/**
* Place Dual Investment order
Expand Down
1 change: 1 addition & 0 deletions src/types/request/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface GetSpotAccountBookReq {
page?: number;
limit?: number;
type?: string;
code?: string;
}

export interface SubmitSpotClosePosCrossDisabledReq {
Expand Down
1 change: 1 addition & 0 deletions src/types/response/earn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface DualInvestmentOrder {
apy_display: string;
apy_settlement: string;
delivery_time: number;
text: string;
}

export interface StructuredProduct {
Expand Down
5 changes: 5 additions & 0 deletions src/types/response/futures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ export interface FuturesAccount {
cross_maintenance_margin: string;
cross_unrealised_pnl: string;
cross_available: string;
cross_margin_balance: string;
cross_mmr: string;
cross_imr: string;
isolated_position_margin: string;
enable_new_dual_mode: boolean;
margin_mode: number;
history: {
dnw: string;
pnl: string;
Expand Down
Loading
Loading