Skip to content

Commit 06c38cc

Browse files
authored
Merge pull request #42 from JJ-Cro/update06012024
v1.1.3 feat(): added new endpoints, updated request types, updated re…
2 parents 077f353 + c92c7f8 commit 06c38cc

File tree

10 files changed

+391
-278
lines changed

10 files changed

+391
-278
lines changed

docs/endpointFunctionList.md

Lines changed: 276 additions & 274 deletions
Large diffs are not rendered by default.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { RestClient } = require('gateio-api');
2+
3+
// 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
4+
// This Gate.io API SDK is available on npm via "npm install gateio-api"
5+
// ENDPOINT: /unified/history_loan_rate
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new RestClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getHistoricalLendingRates(params)
15+
.then((response) => {
16+
console.log(response);
17+
})
18+
.catch((error) => {
19+
console.error(error);
20+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { RestClient } = require('gateio-api');
2+
3+
// 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
4+
// This Gate.io API SDK is available on npm via "npm install gateio-api"
5+
// ENDPOINT: /spot/insurance_history
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new RestClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getSpotInsuranceHistory(params)
15+
.then((response) => {
16+
console.log(response);
17+
})
18+
.catch((error) => {
19+
console.error(error);
20+
});

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gateio-api",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Complete & robust Node.js SDK for Gate.io's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
55
"scripts": {
66
"clean": "rm -rf dist/*",

src/RestClient.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ import {
116116
GetSpotAccountBookReq,
117117
GetSpotAutoOrdersReq,
118118
GetSpotCandlesReq,
119+
GetSpotInsuranceHistoryReq,
119120
GetSpotOrderBookReq,
120121
GetSpotOrderReq,
121122
GetSpotOrdersReq,
@@ -132,6 +133,7 @@ import {
132133
UpdateSubAccountApiKeyReq,
133134
} from './types/request/subaccount.js';
134135
import {
136+
GetUnifiedHistoryLendingRateReq,
135137
GetUnifiedInterestRecordsReq,
136138
GetUnifiedLoanRecordsReq,
137139
GetUnifiedLoansReq,
@@ -276,6 +278,7 @@ import {
276278
SpotCurrency,
277279
SpotFeeRates,
278280
SpotHistoricTradeRecord,
281+
SpotInsuranceHistory,
279282
SpotOrder,
280283
SpotOrderBook,
281284
SpotPriceTriggeredOrder,
@@ -294,6 +297,7 @@ import {
294297
PortfolioMarginCalculation,
295298
UnifiedAccountInfo,
296299
UnifiedCurrencyDiscountTiers,
300+
UnifiedHistoryLendingRate,
297301
UnifiedInterestRecord,
298302
UnifiedLoan,
299303
UnifiedLoanRecord,
@@ -1109,6 +1113,18 @@ export class RestClient extends BaseRestClient {
11091113
});
11101114
}
11111115

1116+
/**
1117+
* Get historical lending rates
1118+
*
1119+
* @param params Parameters for retrieving historical lending rates
1120+
* @returns Promise<UnifiedHistoryLendingRate>
1121+
*/
1122+
getHistoricalLendingRates(
1123+
params: GetUnifiedHistoryLendingRateReq,
1124+
): Promise<UnifiedHistoryLendingRate> {
1125+
return this.getPrivate('/unified/history_loan_rate', params);
1126+
}
1127+
11121128
/**==========================================================================================================================
11131129
* SPOT
11141130
* ==========================================================================================================================
@@ -1548,6 +1564,22 @@ export class RestClient extends BaseRestClient {
15481564
});
15491565
}
15501566

1567+
/**
1568+
* Query spot insurance fund historical data
1569+
*
1570+
* @param params Parameters for querying spot insurance fund history
1571+
* @returns Promise<{
1572+
* currency: string;
1573+
* balance: string;
1574+
* time: number;
1575+
* }[]>
1576+
*/
1577+
getSpotInsuranceHistory(
1578+
params: GetSpotInsuranceHistoryReq,
1579+
): Promise<SpotInsuranceHistory[]> {
1580+
return this.getPrivate('/spot/insurance_history', params);
1581+
}
1582+
15511583
/**
15521584
* Create a price-triggered order
15531585
*

src/types/request/spot.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ export interface UpdateSpotBatchOrdersReq {
106106
amend_text?: string;
107107
}
108108

109+
export interface GetSpotInsuranceHistoryReq {
110+
business: 'margin' | 'unified';
111+
currency: string;
112+
from: number;
113+
to: number;
114+
page?: number;
115+
limit?: number;
116+
}
117+
109118
export interface GetSpotAutoOrdersReq {
110119
status: 'open' | 'finished';
111120
market?: string;

src/types/request/unified.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface GetUnifiedInterestRecordsReq {
2929
}
3030

3131
export interface SetUnifiedAccountModeReq {
32-
mode: 'classic' | 'multi_currency' | 'portfolio';
32+
mode: 'classic' | 'multi_currency' | 'portfolio' | 'single_currency';
3333
settings?: {
3434
usdt_futures?: boolean;
3535
spot_hedge?: boolean;
@@ -70,3 +70,10 @@ export interface PortfolioMarginCalculatorReq {
7070
}[];
7171
spot_hedge?: boolean;
7272
}
73+
74+
export interface GetUnifiedHistoryLendingRateReq {
75+
currency: string;
76+
tier?: string;
77+
page?: number;
78+
limit?: number;
79+
}

src/types/response/spot.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ export interface SpotOrder {
180180
action_mode?: 'ACK' | 'RESULT' | 'FULL';
181181
}
182182

183+
export interface SpotInsuranceHistory {
184+
currency: string;
185+
balance: string;
186+
time: number;
187+
}
188+
183189
export interface SpotPriceTriggeredOrder {
184190
trigger: {
185191
price: string;

src/types/response/unified.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ export interface UnifiedAccountInfo {
1515
spot_in_use: string;
1616
funding: string;
1717
funding_version: string;
18+
cross_balance: string;
19+
iso_balance: string;
20+
im: string;
21+
mm: string;
22+
mmr: string;
23+
margin_balance: string;
24+
available_margin: string;
1825
};
1926
};
2027
total: string;
@@ -98,6 +105,16 @@ export interface UserCurrencyLeverageConfig {
98105
except_leverage_borrowable: string;
99106
}
100107

108+
export interface UnifiedHistoryLendingRate {
109+
currency: string;
110+
tier: string;
111+
tier_up_rate: string;
112+
rates: {
113+
time: number;
114+
rate: string;
115+
}[];
116+
}
117+
101118
export interface MarginTier {
102119
tier: string;
103120
margin_rate: string;

0 commit comments

Comments
 (0)