Skip to content

Commit

Permalink
Merge pull request #42 from JJ-Cro/update06012024
Browse files Browse the repository at this point in the history
v1.1.3 feat(): added new endpoints, updated request types, updated re…
  • Loading branch information
tiagosiebler authored Jan 13, 2025
2 parents 077f353 + c92c7f8 commit 06c38cc
Show file tree
Hide file tree
Showing 10 changed files with 391 additions and 278 deletions.
550 changes: 276 additions & 274 deletions docs/endpointFunctionList.md

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/getHistoricalLendingRates.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/history_loan_rate
// METHOD: GET
// PUBLIC: NO

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

client.getHistoricalLendingRates(params)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
20 changes: 20 additions & 0 deletions examples/apidoc/RestClient/getSpotInsuranceHistory.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: /spot/insurance_history
// METHOD: GET
// PUBLIC: NO

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

client.getSpotInsuranceHistory(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.2",
"version": "1.1.3",
"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
32 changes: 32 additions & 0 deletions src/RestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ import {
GetSpotAccountBookReq,
GetSpotAutoOrdersReq,
GetSpotCandlesReq,
GetSpotInsuranceHistoryReq,
GetSpotOrderBookReq,
GetSpotOrderReq,
GetSpotOrdersReq,
Expand All @@ -132,6 +133,7 @@ import {
UpdateSubAccountApiKeyReq,
} from './types/request/subaccount.js';
import {
GetUnifiedHistoryLendingRateReq,
GetUnifiedInterestRecordsReq,
GetUnifiedLoanRecordsReq,
GetUnifiedLoansReq,
Expand Down Expand Up @@ -276,6 +278,7 @@ import {
SpotCurrency,
SpotFeeRates,
SpotHistoricTradeRecord,
SpotInsuranceHistory,
SpotOrder,
SpotOrderBook,
SpotPriceTriggeredOrder,
Expand All @@ -294,6 +297,7 @@ import {
PortfolioMarginCalculation,
UnifiedAccountInfo,
UnifiedCurrencyDiscountTiers,
UnifiedHistoryLendingRate,
UnifiedInterestRecord,
UnifiedLoan,
UnifiedLoanRecord,
Expand Down Expand Up @@ -1109,6 +1113,18 @@ export class RestClient extends BaseRestClient {
});
}

/**
* Get historical lending rates
*
* @param params Parameters for retrieving historical lending rates
* @returns Promise<UnifiedHistoryLendingRate>
*/
getHistoricalLendingRates(
params: GetUnifiedHistoryLendingRateReq,
): Promise<UnifiedHistoryLendingRate> {
return this.getPrivate('/unified/history_loan_rate', params);
}

/**==========================================================================================================================
* SPOT
* ==========================================================================================================================
Expand Down Expand Up @@ -1548,6 +1564,22 @@ export class RestClient extends BaseRestClient {
});
}

/**
* Query spot insurance fund historical data
*
* @param params Parameters for querying spot insurance fund history
* @returns Promise<{
* currency: string;
* balance: string;
* time: number;
* }[]>
*/
getSpotInsuranceHistory(
params: GetSpotInsuranceHistoryReq,
): Promise<SpotInsuranceHistory[]> {
return this.getPrivate('/spot/insurance_history', params);
}

/**
* Create a price-triggered order
*
Expand Down
9 changes: 9 additions & 0 deletions src/types/request/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ export interface UpdateSpotBatchOrdersReq {
amend_text?: string;
}

export interface GetSpotInsuranceHistoryReq {
business: 'margin' | 'unified';
currency: string;
from: number;
to: number;
page?: number;
limit?: number;
}

export interface GetSpotAutoOrdersReq {
status: 'open' | 'finished';
market?: string;
Expand Down
9 changes: 8 additions & 1 deletion src/types/request/unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface GetUnifiedInterestRecordsReq {
}

export interface SetUnifiedAccountModeReq {
mode: 'classic' | 'multi_currency' | 'portfolio';
mode: 'classic' | 'multi_currency' | 'portfolio' | 'single_currency';
settings?: {
usdt_futures?: boolean;
spot_hedge?: boolean;
Expand Down Expand Up @@ -70,3 +70,10 @@ export interface PortfolioMarginCalculatorReq {
}[];
spot_hedge?: boolean;
}

export interface GetUnifiedHistoryLendingRateReq {
currency: string;
tier?: string;
page?: number;
limit?: number;
}
6 changes: 6 additions & 0 deletions src/types/response/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ export interface SpotOrder {
action_mode?: 'ACK' | 'RESULT' | 'FULL';
}

export interface SpotInsuranceHistory {
currency: string;
balance: string;
time: number;
}

export interface SpotPriceTriggeredOrder {
trigger: {
price: string;
Expand Down
17 changes: 17 additions & 0 deletions src/types/response/unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export interface UnifiedAccountInfo {
spot_in_use: string;
funding: string;
funding_version: string;
cross_balance: string;
iso_balance: string;
im: string;
mm: string;
mmr: string;
margin_balance: string;
available_margin: string;
};
};
total: string;
Expand Down Expand Up @@ -98,6 +105,16 @@ export interface UserCurrencyLeverageConfig {
except_leverage_borrowable: string;
}

export interface UnifiedHistoryLendingRate {
currency: string;
tier: string;
tier_up_rate: string;
rates: {
time: number;
rate: string;
}[];
}

export interface MarginTier {
tier: string;
margin_rate: string;
Expand Down

0 comments on commit 06c38cc

Please sign in to comment.