Skip to content

Commit

Permalink
Merge pull request #488 from JJ-Cro/master
Browse files Browse the repository at this point in the history
v2.13.19 feat(): added new endpoints, updated types
  • Loading branch information
tiagosiebler authored Dec 10, 2024
2 parents 1d64495 + 364911a commit 4d474a0
Show file tree
Hide file tree
Showing 13 changed files with 629 additions and 424 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ yarn-error.log
lib/*
testfile.ts
privaterepotracker
restClientRegex.ts
restClientRegex.ts
.DS_Store
844 changes: 426 additions & 418 deletions docs/endpointFunctionList.md

Large diffs are not rendered by default.

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

// This example shows how to call this Binance API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "binance" for Binance exchange
// This Binance API SDK is available on npm via "npm install binance"
// ENDPOINT: sapi/v1/loan/vip/accruedInterest
// METHOD: GET
// PUBLIC: NO

const client = new MainClient({
api_key: 'insert_api_key_here',
api_secret: 'insert_api_secret_here',
});

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

// This example shows how to call this Binance API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "binance" for Binance exchange
// This Binance API SDK is available on npm via "npm install binance"
// ENDPOINT: sapi/v1/loan/vip/interestRateHistory
// METHOD: GET
// PUBLIC: NO

const client = new MainClient({
api_key: 'insert_api_key_here',
api_secret: 'insert_api_secret_here',
});

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

// This example shows how to call this Binance API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "binance" for Binance exchange
// This Binance API SDK is available on npm via "npm install binance"
// ENDPOINT: sapi/v1/margin/order
// METHOD: POST
// PUBLIC: NO

const client = new MainClient({
api_key: 'insert_api_key_here',
api_secret: 'insert_api_secret_here',
});

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

// This example shows how to call this Binance API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "binance" for Binance exchange
// This Binance API SDK is available on npm via "npm install binance"
// ENDPOINT: api/v3/order/cancelReplace
// METHOD: POST
// PUBLIC: NO

const client = new MainClient({
api_key: 'insert_api_key_here',
api_secret: 'insert_api_secret_here',
});

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

// This example shows how to call this Binance API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "binance" for Binance exchange
// This Binance API SDK is available on npm via "npm install binance"
// ENDPOINT: api/v3/order
// METHOD: POST
// PUBLIC: NO

const client = new MainClient({
api_key: 'insert_api_key_here',
api_secret: 'insert_api_secret_here',
});

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

// This example shows how to call this Binance API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "binance" for Binance exchange
// This Binance API SDK is available on npm via "npm install binance"
// ENDPOINT: api/v3/orderList/oco
// METHOD: POST
// PUBLIC: NO

const client = new MainClient({
api_key: 'insert_api_key_here',
api_secret: 'insert_api_secret_here',
});

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

// This example shows how to call this Binance API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "binance" for Binance exchange
// This Binance API SDK is available on npm via "npm install binance"
// ENDPOINT: api/v3/order/test
// METHOD: POST
// PUBLIC: NO

const client = new MainClient({
api_key: 'insert_api_key_here',
api_secret: 'insert_api_secret_here',
});

client.testNewOrder(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": "binance",
"version": "2.13.18",
"version": "2.13.19",
"description": "Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
26 changes: 25 additions & 1 deletion src/main-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ import {
PortfolioMarginProSpanAccountInfo,
PortfolioMarginProAccountBalance,
SimpleEarnRedeemFlexibleProductParams,
VipLoanInterestRateHistoryParams,
VipLoanInterestRateRecord,
VipLoanAccruedInterestParams,
VipLoanAccruedInterestRecord,
} from './types/spot';

import {
Expand Down Expand Up @@ -1941,12 +1945,14 @@ export class MainClient extends BaseRestClient {

getManagedSubAccountMarginAssets(params: {
email: string;
accountType?: string;
}): Promise<ManagedSubAccountMarginAssetsResponse> {
return this.getPrivate('sapi/v1/managed-subaccount/marginAsset', params);
}

getManagedSubAccountFuturesAssets(params: {
email: string;
accountType?: string;
}): Promise<ManagedSubAccountFuturesAssetsResponse> {
return this.getPrivate(
'sapi/v1/managed-subaccount/fetch-future-asset',
Expand Down Expand Up @@ -2921,7 +2927,9 @@ export class MainClient extends BaseRestClient {
return this.postPrivate(`sapi/v1/simple-earn/locked/subscribe`, params);
}

redeemFlexibleProduct(params: SimpleEarnRedeemFlexibleProductParams): Promise<SimpleEarnRedeemResponse> {
redeemFlexibleProduct(
params: SimpleEarnRedeemFlexibleProductParams,
): Promise<SimpleEarnRedeemResponse> {
return this.postPrivate(`sapi/v1/simple-earn/flexible/redeem`, params);
}

Expand Down Expand Up @@ -3083,6 +3091,15 @@ export class MainClient extends BaseRestClient {
return this.getPrivate('sapi/v1/loan/vip/request/interestRate', params);
}

getVipLoanInterestRateHistory(
params: VipLoanInterestRateHistoryParams,
): Promise<{
rows: VipLoanInterestRateRecord[];
total: number;
}> {
return this.getPrivate('sapi/v1/loan/vip/interestRateHistory', params);
}

getVipLoanableAssets(params: GetLoanableAssetsDataParams): Promise<{
rows: LoanableAssetData[];
total: number;
Expand Down Expand Up @@ -3191,6 +3208,13 @@ export class MainClient extends BaseRestClient {
return this.getPrivate('sapi/v1/dci/product/accounts');
}

getVipLoanAccruedInterest(params?: VipLoanAccruedInterestParams): Promise<{
rows: VipLoanAccruedInterestRecord[];
total: number;
}> {
return this.getPrivate('sapi/v1/loan/vip/accruedInterest', params);
}

updateAutoCompoundStatus(
params: ChangeAutoCompoundStatusParams,
): Promise<ChangeAutoCompoundStatusResponse> {
Expand Down
34 changes: 33 additions & 1 deletion src/types/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4902,7 +4902,7 @@ export interface SimpleEarnRedeemFlexibleProductParams {
productId: string;
redeemAll?: boolean;
amount?: number;
destAccount?: 'SPOT' | 'FUND' ;
destAccount?: 'SPOT' | 'FUND';
}

export interface SimpleEarnRedeemResponse {
Expand Down Expand Up @@ -5468,3 +5468,35 @@ export interface PortfolioMarginProAccountBalance {
optionWalletBalance: string; // only for PM PRO SPAN
optionEquity: string; // only for PM PRO SPAN
}

export interface VipLoanInterestRateHistoryParams {
coin: string;
startTime?: number;
endTime?: number;
current?: number;
limit?: number;
}

export interface VipLoanInterestRateRecord {
coin: string;
annualizedInterestRate: string;
time: number;
}

export interface VipLoanAccruedInterestParams {
orderId?: number;
loanCoin?: string;
startTime?: number;
endTime?: number;
current?: number;
limit?: number;
}

export interface VipLoanAccruedInterestRecord {
loanCoin: string;
principalAmount: string;
interestAmount: string;
annualInterestRate: string;
accrualTime: number;
orderId: number;
}

0 comments on commit 4d474a0

Please sign in to comment.