Skip to content

Commit fe2a424

Browse files
committed
feat(): updated latest changes per release notes - as of 03-11-2024
1 parent 2cc9f55 commit fe2a424

15 files changed

+819
-535
lines changed

docs/endpointFunctionList.md

Lines changed: 492 additions & 484 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 { CoinMClient } = require('binance');
2+
3+
// 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
4+
// This Binance API SDK is available on npm via "npm install binance"
5+
// ENDPOINT: dapi/v1/order/asyn
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new CoinMClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getDownloadIdForFuturesOrderHistory(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 { CoinMClient } = require('binance');
2+
3+
// 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
4+
// This Binance API SDK is available on npm via "npm install binance"
5+
// ENDPOINT: dapi/v1/trade/asyn
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new CoinMClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getDownloadIdForFuturesTradeHistory(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 { CoinMClient } = require('binance');
2+
3+
// 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
4+
// This Binance API SDK is available on npm via "npm install binance"
5+
// ENDPOINT: dapi/v1/income/asyn
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new CoinMClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getDownloadIdForFuturesTransactionHistory(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 { CoinMClient } = require('binance');
2+
3+
// 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
4+
// This Binance API SDK is available on npm via "npm install binance"
5+
// ENDPOINT: dapi/v1/order/asyn/id
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new CoinMClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getFuturesOrderHistoryDownloadLink(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 { CoinMClient } = require('binance');
2+
3+
// 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
4+
// This Binance API SDK is available on npm via "npm install binance"
5+
// ENDPOINT: dapi/v1/trade/asyn/id
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new CoinMClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getFuturesTradeHistoryDownloadLink(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 { CoinMClient } = require('binance');
2+
3+
// 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
4+
// This Binance API SDK is available on npm via "npm install binance"
5+
// ENDPOINT: dapi/v1/income/asyn/id
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new CoinMClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getFuturesTransactionHistoryDownloadLink(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 { MainClient } = require('binance');
2+
3+
// 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
4+
// This Binance API SDK is available on npm via "npm install binance"
5+
// ENDPOINT: sapi/v1/portfolio/balance
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new MainClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getPortfolioMarginProAccountBalance(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 { MainClient } = require('binance');
2+
3+
// 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
4+
// This Binance API SDK is available on npm via "npm install binance"
5+
// ENDPOINT: sapi/v2/portfolio/account
6+
// METHOD: GET
7+
// PUBLIC: NO
8+
9+
const client = new MainClient({
10+
apiKey: 'insert_api_key_here',
11+
apiSecret: 'insert_api_secret_here',
12+
});
13+
14+
client.getPortfolioMarginProSpanAccountInfo(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": "binance",
3-
"version": "2.13.11",
3+
"version": "2.13.12",
44
"description": "Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/coinm-client.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CoinMPositionTrade,
88
CoinMSymbolOrderBookTicker,
99
FundingRate,
10+
FuturesTransactionHistoryDownloadLink,
1011
GetClassicPortfolioMarginNotionalLimitParams,
1112
PositionRisk,
1213
SymbolOrPair,
@@ -471,6 +472,54 @@ export class CoinMClient extends BaseRestClient {
471472
return this.getPrivate('dapi/v1/income', params);
472473
}
473474

475+
getDownloadIdForFuturesTransactionHistory(params: {
476+
startTime: number;
477+
endTime: number;
478+
}): Promise<{
479+
avgCostTimestampOfLast30d: number;
480+
downloadId: string;
481+
}> {
482+
return this.getPrivate('dapi/v1/income/asyn', params);
483+
}
484+
485+
getFuturesTransactionHistoryDownloadLink(params: {
486+
downloadId: string;
487+
}): Promise<FuturesTransactionHistoryDownloadLink> {
488+
return this.getPrivate('dapi/v1/income/asyn/id', params);
489+
}
490+
491+
getDownloadIdForFuturesOrderHistory(params: {
492+
startTime: number;
493+
endTime: number;
494+
}): Promise<{
495+
avgCostTimestampOfLast30d: number;
496+
downloadId: string;
497+
}> {
498+
return this.getPrivate('dapi/v1/order/asyn', params);
499+
}
500+
501+
getFuturesOrderHistoryDownloadLink(params: {
502+
downloadId: string;
503+
}): Promise<FuturesTransactionHistoryDownloadLink> {
504+
return this.getPrivate('dapi/v1/order/asyn/id', params);
505+
}
506+
507+
getDownloadIdForFuturesTradeHistory(params: {
508+
startTime: number;
509+
endTime: number;
510+
}): Promise<{
511+
avgCostTimestampOfLast30d: number;
512+
downloadId: string;
513+
}> {
514+
return this.getPrivate('dapi/v1/trade/asyn', params);
515+
}
516+
517+
getFuturesTradeHistoryDownloadLink(params: {
518+
downloadId: string;
519+
}): Promise<FuturesTransactionHistoryDownloadLink> {
520+
return this.getPrivate('dapi/v1/trade/asyn/id', params);
521+
}
522+
474523
/**
475524
*
476525
* Portfolio Margin Endpoints

src/main-client.ts

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ import {
530530
BnsolRewardHistoryRecord,
531531
BnsolRateHistoryRecord,
532532
GetBnsolRateHistoryReq,
533+
PortfolioMarginProSpanAccountInfo,
534+
PortfolioMarginProAccountBalance,
533535
} from './types/spot';
534536

535537
import {
@@ -553,61 +555,61 @@ export class MainClient extends BaseRestClient {
553555
}
554556

555557
/**
556-
* This method is used to get the latency and time sync between the client and the server.
557-
* This is not official API endpoint and is only used for internal testing purposes.
558-
* Use this method to check the latency and time sync between the client and the server.
559-
* Final values might vary slightly, but it should be within few ms difference.
560-
* If you have any suggestions or improvements to this measurement, please create an issue or pull request on GitHub.
561-
*/
562-
async fetchLatencySummary(): Promise<any> {
563-
const clientTimeReqStart = Date.now();
564-
const serverTime = await this.getServerTime();
565-
const clientTimeReqEnd = Date.now();
566-
console.log('serverTime', serverTime);
567-
568-
const serverTimeMs = serverTime;
569-
const roundTripTime = clientTimeReqEnd - clientTimeReqStart;
570-
const estimatedOneWayLatency = Math.floor(roundTripTime / 2);
571-
572-
// Adjust server time by adding estimated one-way latency
573-
const adjustedServerTime = serverTimeMs + estimatedOneWayLatency;
574-
575-
// Calculate time difference between adjusted server time and local time
576-
const timeDifference = adjustedServerTime - clientTimeReqEnd;
577-
578-
const result = {
579-
localTime: clientTimeReqEnd,
580-
serverTime: serverTimeMs,
581-
roundTripTime,
582-
estimatedOneWayLatency,
583-
adjustedServerTime,
584-
timeDifference,
585-
};
586-
587-
console.log('Time synchronization results:');
588-
console.log(result);
589-
590-
console.log(
591-
`Your approximate latency to exchange server:
558+
* This method is used to get the latency and time sync between the client and the server.
559+
* This is not official API endpoint and is only used for internal testing purposes.
560+
* Use this method to check the latency and time sync between the client and the server.
561+
* Final values might vary slightly, but it should be within few ms difference.
562+
* If you have any suggestions or improvements to this measurement, please create an issue or pull request on GitHub.
563+
*/
564+
async fetchLatencySummary(): Promise<any> {
565+
const clientTimeReqStart = Date.now();
566+
const serverTime = await this.getServerTime();
567+
const clientTimeReqEnd = Date.now();
568+
console.log('serverTime', serverTime);
569+
570+
const serverTimeMs = serverTime;
571+
const roundTripTime = clientTimeReqEnd - clientTimeReqStart;
572+
const estimatedOneWayLatency = Math.floor(roundTripTime / 2);
573+
574+
// Adjust server time by adding estimated one-way latency
575+
const adjustedServerTime = serverTimeMs + estimatedOneWayLatency;
576+
577+
// Calculate time difference between adjusted server time and local time
578+
const timeDifference = adjustedServerTime - clientTimeReqEnd;
579+
580+
const result = {
581+
localTime: clientTimeReqEnd,
582+
serverTime: serverTimeMs,
583+
roundTripTime,
584+
estimatedOneWayLatency,
585+
adjustedServerTime,
586+
timeDifference,
587+
};
588+
589+
console.log('Time synchronization results:');
590+
console.log(result);
591+
592+
console.log(
593+
`Your approximate latency to exchange server:
592594
One way: ${estimatedOneWayLatency}ms.
593595
Round trip: ${roundTripTime}ms.
594596
`,
595-
);
597+
);
596598

597-
if (timeDifference > 500) {
598-
console.warn(
599-
`WARNING! Time difference between server and client clock is greater than 500ms. It is currently ${timeDifference}ms.
599+
if (timeDifference > 500) {
600+
console.warn(
601+
`WARNING! Time difference between server and client clock is greater than 500ms. It is currently ${timeDifference}ms.
600602
Consider adjusting your system clock to avoid unwanted clock sync errors!
601603
Visit https://github.com/tiagosiebler/awesome-crypto-examples/wiki/Timestamp-for-this-request-is-outside-of-the-recvWindow for more information`,
602-
);
603-
} else {
604-
console.log(
605-
`Time difference between server and client clock is within acceptable range of 500ms. It is currently ${timeDifference}ms.`,
606-
);
607-
}
604+
);
605+
} else {
606+
console.log(
607+
`Time difference between server and client clock is within acceptable range of 500ms. It is currently ${timeDifference}ms.`,
608+
);
609+
}
608610

609-
return result;
610-
}
611+
return result;
612+
}
611613

612614
/**
613615
* Abstraction required by each client to aid with time sync / drift handling
@@ -3376,6 +3378,16 @@ async fetchLatencySummary(): Promise<any> {
33763378
return this.getPrivate('sapi/v1/portfolio/interest-history', params);
33773379
}
33783380

3381+
getPortfolioMarginProSpanAccountInfo(): Promise<PortfolioMarginProSpanAccountInfo> {
3382+
return this.getPrivate('sapi/v2/portfolio/account');
3383+
}
3384+
3385+
getPortfolioMarginProAccountBalance(params?: {
3386+
asset?: string;
3387+
}): Promise<PortfolioMarginProAccountBalance[]> {
3388+
return this.getPrivate('sapi/v1/portfolio/balance', params);
3389+
}
3390+
33793391
/**
33803392
*
33813393
* DERIVATIVES - Futures Data - Market

0 commit comments

Comments
 (0)