@apicity/binance 0.4.3 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1227 -32
- package/dist/src/binance.d.ts.map +1 -1
- package/dist/src/binance.js +893 -9
- package/dist/src/binance.js.map +1 -1
- package/dist/src/example.d.ts.map +1 -1
- package/dist/src/example.js +412 -0
- package/dist/src/example.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.d.ts +1395 -78
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/zod.d.ts +851 -0
- package/dist/src/zod.d.ts.map +1 -1
- package/dist/src/zod.js +352 -0
- package/dist/src/zod.js.map +1 -1
- package/package.json +5 -2
package/dist/src/binance.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import { BinanceError } from "./types.js";
|
|
2
|
-
import
|
|
2
|
+
import * as BinanceSchemas from "./zod.js";
|
|
3
|
+
import { BinanceAggTradesRequestSchema, BinanceAvgPriceRequestSchema, BinanceCoinMAggTradesRequestSchema, BinanceCoinMBasisRequestSchema, BinanceCoinMConstituentsRequestSchema, BinanceCoinMContinuousKlinesRequestSchema, BinanceCoinMDepthRequestSchema, BinanceCoinMDeliveryPriceRequestSchema, BinanceCoinMFundingRateRequestSchema, BinanceCoinMGlobalLongShortAccountRatioRequestSchema, BinanceCoinMIndexPriceKlinesRequestSchema, BinanceCoinMKlinesRequestSchema, BinanceCoinMMarkPriceKlinesRequestSchema, BinanceCoinMOpenInterestHistRequestSchema, BinanceCoinMOpenInterestRequestSchema, BinanceCoinMPremiumIndexKlinesRequestSchema, BinanceCoinMPremiumIndexRequestSchema, BinanceCoinMTakerBuySellVolRequestSchema, BinanceCoinMTickerRequestSchema, BinanceCoinMTopLongShortAccountRatioRequestSchema, BinanceCoinMTopLongShortPositionRatioRequestSchema, BinanceCoinMTradesRequestSchema, BinanceDepthRequestSchema, BinanceExchangeInfoRequestSchema, BinanceExecutionRulesRequestSchema, BinanceHistoricalBlockTradesRequestSchema, BinanceHistoricalTradesRequestSchema, BinanceKlinesRequestSchema, BinanceOptionBlockTradesRequestSchema, BinanceOptionDepthRequestSchema, BinanceOptionExerciseHistoryRequestSchema, BinanceOptionIndexRequestSchema, BinanceOptionKlinesRequestSchema, BinanceOptionMarkPriceRequestSchema, BinanceOptionOpenInterestRequestSchema, BinanceOptionTickerRequestSchema, BinanceOptionTradesRequestSchema, BinanceReferencePriceCalculationRequestSchema, BinanceReferencePriceRequestSchema, BinanceTicker24hrRequestSchema, BinanceTickerBookTickerRequestSchema, BinanceTickerPriceRequestSchema, BinanceTickerRequestSchema, BinanceTickerTradingDayRequestSchema, BinanceTradesRequestSchema, BinanceUiKlinesRequestSchema, } from "./zod.js";
|
|
3
4
|
export function createBinance(opts) {
|
|
4
|
-
const baseURL = (opts?.
|
|
5
|
+
const baseURL = (opts?.spotBaseURL ??
|
|
6
|
+
opts?.publicBaseURLs?.spot ??
|
|
7
|
+
opts?.baseURL ??
|
|
8
|
+
"https://api.binance.com").replace(/\/+$/, "");
|
|
9
|
+
const spotDataBaseURL = (opts?.spotDataBaseURL ??
|
|
10
|
+
opts?.publicBaseURLs?.spotData ??
|
|
11
|
+
"https://data-api.binance.vision").replace(/\/+$/, "");
|
|
12
|
+
const fapiBaseURL = (opts?.fapiBaseURL ??
|
|
13
|
+
opts?.publicBaseURLs?.fapi ??
|
|
14
|
+
"https://fapi.binance.com").replace(/\/+$/, "");
|
|
15
|
+
const futuresDataBaseURL = (opts?.futuresDataBaseURL ??
|
|
16
|
+
opts?.fapiBaseURL ??
|
|
17
|
+
opts?.publicBaseURLs?.fapi ??
|
|
18
|
+
"https://fapi.binance.com").replace(/\/+$/, "");
|
|
19
|
+
const coinMBaseURL = (opts?.dapiBaseURL ??
|
|
20
|
+
opts?.publicBaseURLs?.dapi ??
|
|
21
|
+
opts?.coinMBaseURL ??
|
|
22
|
+
"https://dapi.binance.com").replace(/\/+$/, "");
|
|
23
|
+
const eapiBaseURL = (opts?.eapiBaseURL ??
|
|
24
|
+
opts?.publicBaseURLs?.eapi ??
|
|
25
|
+
"https://eapi.binance.com").replace(/\/+$/, "");
|
|
5
26
|
const doFetch = opts?.fetch ?? fetch;
|
|
6
27
|
const timeout = opts?.timeout ?? 30000;
|
|
7
28
|
function attachAbortHandler(signal, controller) {
|
|
@@ -32,7 +53,14 @@ export function createBinance(opts) {
|
|
|
32
53
|
}
|
|
33
54
|
return undefined;
|
|
34
55
|
}
|
|
35
|
-
async function makeJsonRequest(method, path, body, signal) {
|
|
56
|
+
async function makeJsonRequest(method, path, body, signal, requestOptions = {}) {
|
|
57
|
+
const requestBaseURL = typeof requestOptions === "string"
|
|
58
|
+
? requestOptions
|
|
59
|
+
: (requestOptions.baseOverride ?? baseURL);
|
|
60
|
+
const requestAuth = typeof requestOptions === "string"
|
|
61
|
+
? "none"
|
|
62
|
+
: (requestOptions.auth ??
|
|
63
|
+
(requestOptions.baseOverride === undefined ? undefined : "none"));
|
|
36
64
|
const controller = new AbortController();
|
|
37
65
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
38
66
|
if (signal) {
|
|
@@ -45,14 +73,14 @@ export function createBinance(opts) {
|
|
|
45
73
|
headers,
|
|
46
74
|
signal: controller.signal,
|
|
47
75
|
};
|
|
48
|
-
if (opts?.apiKey) {
|
|
76
|
+
if (requestAuth !== "none" && opts?.apiKey) {
|
|
49
77
|
headers["X-MBX-APIKEY"] = opts.apiKey;
|
|
50
78
|
}
|
|
51
79
|
if (body !== undefined) {
|
|
52
80
|
headers["Content-Type"] = "application/json";
|
|
53
81
|
init.body = JSON.stringify(body);
|
|
54
82
|
}
|
|
55
|
-
const res = await doFetch(`${
|
|
83
|
+
const res = await doFetch(`${requestBaseURL}${path}`, init);
|
|
56
84
|
clearTimeout(timeoutId);
|
|
57
85
|
if (!res.ok) {
|
|
58
86
|
let resBody = null;
|
|
@@ -64,7 +92,14 @@ export function createBinance(opts) {
|
|
|
64
92
|
}
|
|
65
93
|
throw new BinanceError(formatErrorMessage(res.status, resBody), res.status, resBody, errorCode(resBody));
|
|
66
94
|
}
|
|
67
|
-
|
|
95
|
+
const text = await res.text();
|
|
96
|
+
if (text.length === 0) {
|
|
97
|
+
const emptyResponse = typeof requestOptions === "string"
|
|
98
|
+
? undefined
|
|
99
|
+
: requestOptions.emptyResponse;
|
|
100
|
+
return (emptyResponse ?? null);
|
|
101
|
+
}
|
|
102
|
+
return JSON.parse(text);
|
|
68
103
|
}
|
|
69
104
|
catch (error) {
|
|
70
105
|
clearTimeout(timeoutId);
|
|
@@ -73,13 +108,28 @@ export function createBinance(opts) {
|
|
|
73
108
|
throw new BinanceError(`Binance request failed: ${error}`, 500);
|
|
74
109
|
}
|
|
75
110
|
}
|
|
76
|
-
function buildQuery(params) {
|
|
111
|
+
function buildQuery(params, options = {}) {
|
|
112
|
+
const arrayFormat = options.arrayFormat ?? "json";
|
|
77
113
|
const qs = new URLSearchParams();
|
|
78
114
|
for (const [key, value] of Object.entries(params)) {
|
|
79
|
-
if (value === undefined) {
|
|
115
|
+
if (value === undefined || value === null) {
|
|
80
116
|
continue;
|
|
81
117
|
}
|
|
82
|
-
|
|
118
|
+
if (Array.isArray(value)) {
|
|
119
|
+
if (arrayFormat === "repeat") {
|
|
120
|
+
for (const item of value) {
|
|
121
|
+
qs.append(key, String(item));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (arrayFormat === "csv") {
|
|
125
|
+
qs.append(key, value.map(String).join(","));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
qs.append(key, JSON.stringify(value));
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
qs.append(key, String(value));
|
|
83
133
|
}
|
|
84
134
|
const query = qs.toString();
|
|
85
135
|
return query ? `?${query}` : "";
|
|
@@ -106,6 +156,16 @@ export function createBinance(opts) {
|
|
|
106
156
|
});
|
|
107
157
|
return makeJsonRequest("GET", `/api/v3/exchangeInfo${query}`, undefined, signal);
|
|
108
158
|
}, { schema: BinanceExchangeInfoRequestSchema });
|
|
159
|
+
// GET https://api.binance.com/api/v3/executionRules{query}
|
|
160
|
+
// Docs: https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#query-execution-rules
|
|
161
|
+
const executionRules = Object.assign(async (req = {}, signal) => {
|
|
162
|
+
const query = buildQuery({
|
|
163
|
+
symbol: req.symbol,
|
|
164
|
+
symbols: req.symbols,
|
|
165
|
+
symbolStatus: req.symbolStatus,
|
|
166
|
+
});
|
|
167
|
+
return makeJsonRequest("GET", `/api/v3/executionRules${query}`, undefined, signal);
|
|
168
|
+
}, { schema: BinanceExecutionRulesRequestSchema });
|
|
109
169
|
// GET https://api.binance.com/api/v3/depth{query}
|
|
110
170
|
// Docs: https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#order-book
|
|
111
171
|
const depth = Object.assign(async (req, signal) => {
|
|
@@ -219,6 +279,7 @@ export function createBinance(opts) {
|
|
|
219
279
|
symbol: req.symbol,
|
|
220
280
|
symbols: req.symbols,
|
|
221
281
|
type: req.type,
|
|
282
|
+
symbolStatus: req.symbolStatus,
|
|
222
283
|
});
|
|
223
284
|
return makeJsonRequest("GET", `/api/v3/ticker/24hr${query}`, undefined, signal);
|
|
224
285
|
}, { schema: BinanceTicker24hrRequestSchema });
|
|
@@ -272,12 +333,667 @@ export function createBinance(opts) {
|
|
|
272
333
|
tradingDay: tickerTradingDay,
|
|
273
334
|
twentyFourHr: tickerTwentyFourHr,
|
|
274
335
|
});
|
|
336
|
+
// GET https://eapi.binance.com/eapi/v1/ping
|
|
337
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Test-Connectivity
|
|
338
|
+
const eapiPing = Object.assign(async (signal) => {
|
|
339
|
+
return makeJsonRequest("GET", "/eapi/v1/ping", undefined, signal, { baseOverride: eapiBaseURL });
|
|
340
|
+
}, { schema: undefined });
|
|
341
|
+
// GET https://eapi.binance.com/eapi/v1/time
|
|
342
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Check-Server-Time
|
|
343
|
+
const eapiTime = Object.assign(async (signal) => {
|
|
344
|
+
return makeJsonRequest("GET", "/eapi/v1/time", undefined, signal, { baseOverride: eapiBaseURL });
|
|
345
|
+
}, { schema: undefined });
|
|
346
|
+
// GET https://eapi.binance.com/eapi/v1/exchangeInfo
|
|
347
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Exchange-Information
|
|
348
|
+
const eapiExchangeInfo = Object.assign(async (signal) => {
|
|
349
|
+
return makeJsonRequest("GET", "/eapi/v1/exchangeInfo", undefined, signal, { baseOverride: eapiBaseURL });
|
|
350
|
+
}, { schema: undefined });
|
|
351
|
+
// GET https://eapi.binance.com/eapi/v1/ticker{query}
|
|
352
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/24hr-Ticker-Price-Change-Statistics
|
|
353
|
+
const eapiTicker = Object.assign(async (req = {}, signal) => {
|
|
354
|
+
const query = buildQuery({
|
|
355
|
+
symbol: req.symbol,
|
|
356
|
+
});
|
|
357
|
+
return makeJsonRequest("GET", `/eapi/v1/ticker${query}`, undefined, signal, { baseOverride: eapiBaseURL });
|
|
358
|
+
}, { schema: BinanceOptionTickerRequestSchema });
|
|
359
|
+
// GET https://eapi.binance.com/eapi/v1/exerciseHistory{query}
|
|
360
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Historical-Exercise-Records
|
|
361
|
+
const eapiExerciseHistory = Object.assign(async (req = {}, signal) => {
|
|
362
|
+
const query = buildQuery({
|
|
363
|
+
underlying: req.underlying,
|
|
364
|
+
startTime: req.startTime,
|
|
365
|
+
endTime: req.endTime,
|
|
366
|
+
limit: req.limit,
|
|
367
|
+
});
|
|
368
|
+
return makeJsonRequest("GET", `/eapi/v1/exerciseHistory${query}`, undefined, signal, { baseOverride: eapiBaseURL });
|
|
369
|
+
}, { schema: BinanceOptionExerciseHistoryRequestSchema });
|
|
370
|
+
// GET https://eapi.binance.com/eapi/v1/openInterest{query}
|
|
371
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Open-Interest
|
|
372
|
+
const eapiOpenInterest = Object.assign(async (req, signal) => {
|
|
373
|
+
const query = buildQuery({
|
|
374
|
+
underlyingAsset: req.underlyingAsset,
|
|
375
|
+
expiration: req.expiration,
|
|
376
|
+
});
|
|
377
|
+
return makeJsonRequest("GET", `/eapi/v1/openInterest${query}`, undefined, signal, { baseOverride: eapiBaseURL });
|
|
378
|
+
}, { schema: BinanceOptionOpenInterestRequestSchema });
|
|
379
|
+
// GET https://eapi.binance.com/eapi/v1/depth{query}
|
|
380
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Order-Book
|
|
381
|
+
const eapiDepth = Object.assign(async (req, signal) => {
|
|
382
|
+
const query = buildQuery({
|
|
383
|
+
symbol: req.symbol,
|
|
384
|
+
limit: req.limit,
|
|
385
|
+
});
|
|
386
|
+
return makeJsonRequest("GET", `/eapi/v1/depth${query}`, undefined, signal, { baseOverride: eapiBaseURL });
|
|
387
|
+
}, { schema: BinanceOptionDepthRequestSchema });
|
|
388
|
+
// GET https://eapi.binance.com/eapi/v1/trades{query}
|
|
389
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Recent-Trades-List
|
|
390
|
+
const eapiTrades = Object.assign(async (req, signal) => {
|
|
391
|
+
const query = buildQuery({
|
|
392
|
+
symbol: req.symbol,
|
|
393
|
+
limit: req.limit,
|
|
394
|
+
});
|
|
395
|
+
return makeJsonRequest("GET", `/eapi/v1/trades${query}`, undefined, signal, { baseOverride: eapiBaseURL });
|
|
396
|
+
}, { schema: BinanceOptionTradesRequestSchema });
|
|
397
|
+
// GET https://eapi.binance.com/eapi/v1/blockTrades{query}
|
|
398
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Recent-Block-Trade-List
|
|
399
|
+
const eapiBlockTrades = Object.assign(async (req = {}, signal) => {
|
|
400
|
+
const query = buildQuery({
|
|
401
|
+
symbol: req.symbol,
|
|
402
|
+
limit: req.limit,
|
|
403
|
+
});
|
|
404
|
+
return makeJsonRequest("GET", `/eapi/v1/blockTrades${query}`, undefined, signal, { baseOverride: eapiBaseURL, emptyResponse: [] });
|
|
405
|
+
}, { schema: BinanceOptionBlockTradesRequestSchema });
|
|
406
|
+
// GET https://eapi.binance.com/eapi/v1/index{query}
|
|
407
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Symbol-Price-Ticker
|
|
408
|
+
const eapiIndex = Object.assign(async (req, signal) => {
|
|
409
|
+
const query = buildQuery({
|
|
410
|
+
underlying: req.underlying,
|
|
411
|
+
});
|
|
412
|
+
return makeJsonRequest("GET", `/eapi/v1/index${query}`, undefined, signal, { baseOverride: eapiBaseURL });
|
|
413
|
+
}, { schema: BinanceOptionIndexRequestSchema });
|
|
414
|
+
// GET https://eapi.binance.com/eapi/v1/klines{query}
|
|
415
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Kline-Candlestick-Data
|
|
416
|
+
const eapiKlines = Object.assign(async (req, signal) => {
|
|
417
|
+
const query = buildQuery({
|
|
418
|
+
symbol: req.symbol,
|
|
419
|
+
interval: req.interval,
|
|
420
|
+
startTime: req.startTime,
|
|
421
|
+
endTime: req.endTime,
|
|
422
|
+
limit: req.limit,
|
|
423
|
+
});
|
|
424
|
+
return makeJsonRequest("GET", `/eapi/v1/klines${query}`, undefined, signal, { baseOverride: eapiBaseURL });
|
|
425
|
+
}, { schema: BinanceOptionKlinesRequestSchema });
|
|
426
|
+
// GET https://eapi.binance.com/eapi/v1/mark{query}
|
|
427
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Option-Mark-Price
|
|
428
|
+
const eapiMark = Object.assign(async (req = {}, signal) => {
|
|
429
|
+
const query = buildQuery({
|
|
430
|
+
symbol: req.symbol,
|
|
431
|
+
});
|
|
432
|
+
return makeJsonRequest("GET", `/eapi/v1/mark${query}`, undefined, signal, { baseOverride: eapiBaseURL });
|
|
433
|
+
}, { schema: BinanceOptionMarkPriceRequestSchema });
|
|
434
|
+
// GET https://fapi.binance.com/fapi/v1/ping
|
|
435
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Test-Connectivity
|
|
436
|
+
const fapiPing = Object.assign(async (signal) => {
|
|
437
|
+
return makeJsonRequest("GET", "/fapi/v1/ping", undefined, signal, { baseOverride: fapiBaseURL });
|
|
438
|
+
}, { schema: undefined });
|
|
439
|
+
// GET https://fapi.binance.com/fapi/v1/time
|
|
440
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Check-Server-Time
|
|
441
|
+
const fapiTime = Object.assign(async (signal) => {
|
|
442
|
+
return makeJsonRequest("GET", "/fapi/v1/time", undefined, signal, { baseOverride: fapiBaseURL });
|
|
443
|
+
}, { schema: undefined });
|
|
444
|
+
// GET https://fapi.binance.com/fapi/v1/exchangeInfo
|
|
445
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Exchange-Information
|
|
446
|
+
const fapiExchangeInfo = Object.assign(async (signal) => {
|
|
447
|
+
return makeJsonRequest("GET", "/fapi/v1/exchangeInfo", undefined, signal, { baseOverride: fapiBaseURL });
|
|
448
|
+
}, { schema: undefined });
|
|
449
|
+
// GET https://fapi.binance.com/fapi/v1/depth{query}
|
|
450
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Order-Book
|
|
451
|
+
const fapiDepth = Object.assign(async (req, signal) => {
|
|
452
|
+
const query = buildQuery({ symbol: req.symbol, limit: req.limit });
|
|
453
|
+
return makeJsonRequest("GET", `/fapi/v1/depth${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
454
|
+
}, { schema: BinanceSchemas.BinanceFapiDepthRequestSchema });
|
|
455
|
+
// GET https://fapi.binance.com/fapi/v1/rpiDepth{query}
|
|
456
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Order-Book-RPI
|
|
457
|
+
const fapiRpiDepth = Object.assign(async (req, signal) => {
|
|
458
|
+
const query = buildQuery({ symbol: req.symbol, limit: req.limit });
|
|
459
|
+
return makeJsonRequest("GET", `/fapi/v1/rpiDepth${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
460
|
+
}, { schema: BinanceSchemas.BinanceFapiRpiDepthRequestSchema });
|
|
461
|
+
// GET https://fapi.binance.com/fapi/v1/trades{query}
|
|
462
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Recent-Trades-List
|
|
463
|
+
const fapiTrades = Object.assign(async (req, signal) => {
|
|
464
|
+
const query = buildQuery({ symbol: req.symbol, limit: req.limit });
|
|
465
|
+
return makeJsonRequest("GET", `/fapi/v1/trades${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
466
|
+
}, { schema: BinanceSchemas.BinanceFapiTradesRequestSchema });
|
|
467
|
+
// GET https://fapi.binance.com/fapi/v1/aggTrades{query}
|
|
468
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Compressed-Aggregate-Trades-List
|
|
469
|
+
const fapiAggTrades = Object.assign(async (req, signal) => {
|
|
470
|
+
const query = buildQuery({
|
|
471
|
+
symbol: req.symbol,
|
|
472
|
+
fromId: req.fromId,
|
|
473
|
+
startTime: req.startTime,
|
|
474
|
+
endTime: req.endTime,
|
|
475
|
+
limit: req.limit,
|
|
476
|
+
});
|
|
477
|
+
return makeJsonRequest("GET", `/fapi/v1/aggTrades${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
478
|
+
}, { schema: BinanceSchemas.BinanceFapiAggTradesRequestSchema });
|
|
479
|
+
// GET https://fapi.binance.com/fapi/v1/klines{query}
|
|
480
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Kline-Candlestick-Data
|
|
481
|
+
const fapiKlines = Object.assign(async (req, signal) => {
|
|
482
|
+
const query = buildQuery({
|
|
483
|
+
symbol: req.symbol,
|
|
484
|
+
interval: req.interval,
|
|
485
|
+
startTime: req.startTime,
|
|
486
|
+
endTime: req.endTime,
|
|
487
|
+
limit: req.limit,
|
|
488
|
+
});
|
|
489
|
+
return makeJsonRequest("GET", `/fapi/v1/klines${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
490
|
+
}, { schema: BinanceSchemas.BinanceFapiKlinesRequestSchema });
|
|
491
|
+
// GET https://fapi.binance.com/fapi/v1/continuousKlines{query}
|
|
492
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Continuous-Contract-Kline-Candlestick-Data
|
|
493
|
+
const fapiContinuousKlines = Object.assign(async (req, signal) => {
|
|
494
|
+
const query = buildQuery({
|
|
495
|
+
pair: req.pair,
|
|
496
|
+
contractType: req.contractType,
|
|
497
|
+
interval: req.interval,
|
|
498
|
+
startTime: req.startTime,
|
|
499
|
+
endTime: req.endTime,
|
|
500
|
+
limit: req.limit,
|
|
501
|
+
});
|
|
502
|
+
return makeJsonRequest("GET", `/fapi/v1/continuousKlines${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
503
|
+
}, { schema: BinanceSchemas.BinanceFapiContinuousKlinesRequestSchema });
|
|
504
|
+
// GET https://fapi.binance.com/fapi/v1/indexPriceKlines{query}
|
|
505
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Index-Price-Kline-Candlestick-Data
|
|
506
|
+
const fapiIndexPriceKlines = Object.assign(async (req, signal) => {
|
|
507
|
+
const query = buildQuery({
|
|
508
|
+
pair: req.pair,
|
|
509
|
+
interval: req.interval,
|
|
510
|
+
startTime: req.startTime,
|
|
511
|
+
endTime: req.endTime,
|
|
512
|
+
limit: req.limit,
|
|
513
|
+
});
|
|
514
|
+
return makeJsonRequest("GET", `/fapi/v1/indexPriceKlines${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
515
|
+
}, { schema: BinanceSchemas.BinanceFapiIndexPriceKlinesRequestSchema });
|
|
516
|
+
// GET https://fapi.binance.com/fapi/v1/markPriceKlines{query}
|
|
517
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price-Kline-Candlestick-Data
|
|
518
|
+
const fapiMarkPriceKlines = Object.assign(async (req, signal) => {
|
|
519
|
+
const query = buildQuery({
|
|
520
|
+
symbol: req.symbol,
|
|
521
|
+
interval: req.interval,
|
|
522
|
+
startTime: req.startTime,
|
|
523
|
+
endTime: req.endTime,
|
|
524
|
+
limit: req.limit,
|
|
525
|
+
});
|
|
526
|
+
return makeJsonRequest("GET", `/fapi/v1/markPriceKlines${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
527
|
+
}, { schema: BinanceSchemas.BinanceFapiMarkPriceKlinesRequestSchema });
|
|
528
|
+
// GET https://fapi.binance.com/fapi/v1/premiumIndexKlines{query}
|
|
529
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Premium-Index-Kline-Data
|
|
530
|
+
const fapiPremiumIndexKlines = Object.assign(async (req, signal) => {
|
|
531
|
+
const query = buildQuery({
|
|
532
|
+
symbol: req.symbol,
|
|
533
|
+
interval: req.interval,
|
|
534
|
+
startTime: req.startTime,
|
|
535
|
+
endTime: req.endTime,
|
|
536
|
+
limit: req.limit,
|
|
537
|
+
});
|
|
538
|
+
return makeJsonRequest("GET", `/fapi/v1/premiumIndexKlines${query}`, undefined, signal, {
|
|
539
|
+
baseOverride: fapiBaseURL,
|
|
540
|
+
});
|
|
541
|
+
}, { schema: BinanceSchemas.BinanceFapiPremiumIndexKlinesRequestSchema });
|
|
542
|
+
// GET https://fapi.binance.com/fapi/v1/premiumIndex{query}
|
|
543
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
|
|
544
|
+
const fapiPremiumIndex = Object.assign(async (req = {}, signal) => {
|
|
545
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
546
|
+
return makeJsonRequest("GET", `/fapi/v1/premiumIndex${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
547
|
+
}, { schema: BinanceSchemas.BinanceFapiPremiumIndexRequestSchema });
|
|
548
|
+
// GET https://fapi.binance.com/fapi/v1/fundingRate{query}
|
|
549
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Rate-History
|
|
550
|
+
const fapiFundingRate = Object.assign(async (req = {}, signal) => {
|
|
551
|
+
const query = buildQuery({
|
|
552
|
+
symbol: req.symbol,
|
|
553
|
+
startTime: req.startTime,
|
|
554
|
+
endTime: req.endTime,
|
|
555
|
+
limit: req.limit,
|
|
556
|
+
});
|
|
557
|
+
return makeJsonRequest("GET", `/fapi/v1/fundingRate${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
558
|
+
}, { schema: BinanceSchemas.BinanceFapiFundingRateRequestSchema });
|
|
559
|
+
// GET https://fapi.binance.com/fapi/v1/fundingInfo
|
|
560
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Rate-Info
|
|
561
|
+
const fapiFundingInfo = Object.assign(async (signal) => {
|
|
562
|
+
return makeJsonRequest("GET", "/fapi/v1/fundingInfo", undefined, signal, { baseOverride: fapiBaseURL });
|
|
563
|
+
}, { schema: undefined });
|
|
564
|
+
// sig-ok: upstream numeric segment exposed as a TypeScript-friendly name.
|
|
565
|
+
// GET https://fapi.binance.com/fapi/v1/ticker/24hr{query}
|
|
566
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics
|
|
567
|
+
const fapiTickerTwentyFourHr = Object.assign(async (req = {}, signal) => {
|
|
568
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
569
|
+
return makeJsonRequest("GET", `/fapi/v1/ticker/24hr${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
570
|
+
}, { schema: BinanceSchemas.BinanceFapiTicker24hrRequestSchema });
|
|
571
|
+
// GET https://fapi.binance.com/fapi/v1/ticker/bookTicker{query}
|
|
572
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Order-Book-Ticker
|
|
573
|
+
const fapiTickerBookTicker = Object.assign(async (req = {}, signal) => {
|
|
574
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
575
|
+
return makeJsonRequest("GET", `/fapi/v1/ticker/bookTicker${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
576
|
+
}, { schema: BinanceSchemas.BinanceFapiTickerBookTickerRequestSchema });
|
|
577
|
+
// GET https://fapi.binance.com/fapi/v2/ticker/price{query}
|
|
578
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Price-Ticker-v2
|
|
579
|
+
const fapiV2TickerPrice = Object.assign(async (req = {}, signal) => {
|
|
580
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
581
|
+
return makeJsonRequest("GET", `/fapi/v2/ticker/price${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
582
|
+
}, { schema: BinanceSchemas.BinanceFapiV2TickerPriceRequestSchema });
|
|
583
|
+
// GET https://fapi.binance.com/fapi/v1/openInterest{query}
|
|
584
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest
|
|
585
|
+
const fapiOpenInterest = Object.assign(async (req, signal) => {
|
|
586
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
587
|
+
return makeJsonRequest("GET", `/fapi/v1/openInterest${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
588
|
+
}, { schema: BinanceSchemas.BinanceFapiOpenInterestRequestSchema });
|
|
589
|
+
// GET https://fapi.binance.com/fapi/v1/indexInfo{query}
|
|
590
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Composite-Index-Symbol-Information
|
|
591
|
+
const fapiIndexInfo = Object.assign(async (req = {}, signal) => {
|
|
592
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
593
|
+
return makeJsonRequest("GET", `/fapi/v1/indexInfo${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
594
|
+
}, { schema: BinanceSchemas.BinanceFapiIndexInfoRequestSchema });
|
|
595
|
+
// GET https://fapi.binance.com/fapi/v1/assetIndex{query}
|
|
596
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Multi-Assets-Mode-Asset-Index
|
|
597
|
+
const fapiAssetIndex = Object.assign(async (req = {}, signal) => {
|
|
598
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
599
|
+
return makeJsonRequest("GET", `/fapi/v1/assetIndex${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
600
|
+
}, { schema: BinanceSchemas.BinanceFapiAssetIndexRequestSchema });
|
|
601
|
+
// GET https://fapi.binance.com/fapi/v1/constituents{query}
|
|
602
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Index-Constituents
|
|
603
|
+
const fapiConstituents = Object.assign(async (req, signal) => {
|
|
604
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
605
|
+
return makeJsonRequest("GET", `/fapi/v1/constituents${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
606
|
+
}, { schema: BinanceSchemas.BinanceFapiConstituentsRequestSchema });
|
|
607
|
+
// GET https://fapi.binance.com/fapi/v1/insuranceBalance{query}
|
|
608
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Insurance-Fund-Balance
|
|
609
|
+
const fapiInsuranceBalance = Object.assign(async (req = {}, signal) => {
|
|
610
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
611
|
+
return makeJsonRequest("GET", `/fapi/v1/insuranceBalance${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
612
|
+
}, { schema: BinanceSchemas.BinanceFapiInsuranceBalanceRequestSchema });
|
|
613
|
+
// GET https://fapi.binance.com/fapi/v1/symbolAdlRisk{query}
|
|
614
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/ADL-Risk
|
|
615
|
+
const fapiSymbolAdlRisk = Object.assign(async (req = {}, signal) => {
|
|
616
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
617
|
+
return makeJsonRequest("GET", `/fapi/v1/symbolAdlRisk${query}`, undefined, signal, { baseOverride: fapiBaseURL });
|
|
618
|
+
}, { schema: BinanceSchemas.BinanceFapiSymbolAdlRiskRequestSchema });
|
|
619
|
+
// GET https://fapi.binance.com/fapi/v1/tradingSchedule
|
|
620
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Trading-Schedule
|
|
621
|
+
const fapiTradingSchedule = Object.assign(async (signal) => {
|
|
622
|
+
return makeJsonRequest("GET", "/fapi/v1/tradingSchedule", undefined, signal, { baseOverride: fapiBaseURL });
|
|
623
|
+
}, { schema: undefined });
|
|
624
|
+
// GET https://fapi.binance.com/futures/data/delivery-price{query}
|
|
625
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Delivery-Price
|
|
626
|
+
const futuresDataDeliveryPrice = Object.assign(async (req, signal) => {
|
|
627
|
+
const query = buildQuery({ pair: req.pair });
|
|
628
|
+
return makeJsonRequest("GET", `/futures/data/delivery-price${query}`, undefined, signal, {
|
|
629
|
+
baseOverride: futuresDataBaseURL,
|
|
630
|
+
});
|
|
631
|
+
}, { schema: BinanceSchemas.BinanceFuturesDataDeliveryPriceRequestSchema });
|
|
632
|
+
// GET https://fapi.binance.com/futures/data/openInterestHist{query}
|
|
633
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest-Statistics
|
|
634
|
+
const futuresDataOpenInterestHist = Object.assign(async (req, signal) => {
|
|
635
|
+
const query = buildQuery({
|
|
636
|
+
symbol: req.symbol,
|
|
637
|
+
period: req.period,
|
|
638
|
+
limit: req.limit,
|
|
639
|
+
startTime: req.startTime,
|
|
640
|
+
endTime: req.endTime,
|
|
641
|
+
});
|
|
642
|
+
return makeJsonRequest("GET", `/futures/data/openInterestHist${query}`, undefined, signal, {
|
|
643
|
+
baseOverride: futuresDataBaseURL,
|
|
644
|
+
});
|
|
645
|
+
}, { schema: BinanceSchemas.BinanceFuturesDataOpenInterestHistRequestSchema });
|
|
646
|
+
// GET https://fapi.binance.com/futures/data/topLongShortPositionRatio{query}
|
|
647
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Top-Trader-Long-Short-Ratio
|
|
648
|
+
const futuresDataTopLongShortPositionRatio = Object.assign(async (req, signal) => {
|
|
649
|
+
const query = buildQuery({
|
|
650
|
+
symbol: req.symbol,
|
|
651
|
+
period: req.period,
|
|
652
|
+
limit: req.limit,
|
|
653
|
+
startTime: req.startTime,
|
|
654
|
+
endTime: req.endTime,
|
|
655
|
+
});
|
|
656
|
+
return makeJsonRequest("GET", `/futures/data/topLongShortPositionRatio${query}`, undefined, signal, { baseOverride: futuresDataBaseURL });
|
|
657
|
+
}, { schema: BinanceSchemas.BinanceFuturesDataLongShortRatioRequestSchema });
|
|
658
|
+
// GET https://fapi.binance.com/futures/data/topLongShortAccountRatio{query}
|
|
659
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Top-Long-Short-Account-Ratio
|
|
660
|
+
const futuresDataTopLongShortAccountRatio = Object.assign(async (req, signal) => {
|
|
661
|
+
const query = buildQuery({
|
|
662
|
+
symbol: req.symbol,
|
|
663
|
+
period: req.period,
|
|
664
|
+
limit: req.limit,
|
|
665
|
+
startTime: req.startTime,
|
|
666
|
+
endTime: req.endTime,
|
|
667
|
+
});
|
|
668
|
+
return makeJsonRequest("GET", `/futures/data/topLongShortAccountRatio${query}`, undefined, signal, { baseOverride: futuresDataBaseURL });
|
|
669
|
+
}, { schema: BinanceSchemas.BinanceFuturesDataLongShortRatioRequestSchema });
|
|
670
|
+
// GET https://fapi.binance.com/futures/data/globalLongShortAccountRatio{query}
|
|
671
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Long-Short-Ratio
|
|
672
|
+
const futuresDataGlobalLongShortAccountRatio = Object.assign(async (req, signal) => {
|
|
673
|
+
const query = buildQuery({
|
|
674
|
+
symbol: req.symbol,
|
|
675
|
+
period: req.period,
|
|
676
|
+
limit: req.limit,
|
|
677
|
+
startTime: req.startTime,
|
|
678
|
+
endTime: req.endTime,
|
|
679
|
+
});
|
|
680
|
+
return makeJsonRequest("GET", `/futures/data/globalLongShortAccountRatio${query}`, undefined, signal, { baseOverride: futuresDataBaseURL });
|
|
681
|
+
}, { schema: BinanceSchemas.BinanceFuturesDataLongShortRatioRequestSchema });
|
|
682
|
+
// GET https://fapi.binance.com/futures/data/takerlongshortRatio{query}
|
|
683
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Taker-BuySell-Volume
|
|
684
|
+
const futuresDataTakerlongshortRatio = Object.assign(async (req, signal) => {
|
|
685
|
+
const query = buildQuery({
|
|
686
|
+
symbol: req.symbol,
|
|
687
|
+
period: req.period,
|
|
688
|
+
limit: req.limit,
|
|
689
|
+
startTime: req.startTime,
|
|
690
|
+
endTime: req.endTime,
|
|
691
|
+
});
|
|
692
|
+
return makeJsonRequest("GET", `/futures/data/takerlongshortRatio${query}`, undefined, signal, {
|
|
693
|
+
baseOverride: futuresDataBaseURL,
|
|
694
|
+
});
|
|
695
|
+
}, {
|
|
696
|
+
schema: BinanceSchemas.BinanceFuturesDataTakerlongshortRatioRequestSchema,
|
|
697
|
+
});
|
|
698
|
+
// GET https://fapi.binance.com/futures/data/basis{query}
|
|
699
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Basis
|
|
700
|
+
const futuresDataBasis = Object.assign(async (req, signal) => {
|
|
701
|
+
const query = buildQuery({
|
|
702
|
+
pair: req.pair,
|
|
703
|
+
contractType: req.contractType,
|
|
704
|
+
period: req.period,
|
|
705
|
+
limit: req.limit,
|
|
706
|
+
startTime: req.startTime,
|
|
707
|
+
endTime: req.endTime,
|
|
708
|
+
});
|
|
709
|
+
return makeJsonRequest("GET", `/futures/data/basis${query}`, undefined, signal, { baseOverride: futuresDataBaseURL });
|
|
710
|
+
}, { schema: BinanceSchemas.BinanceFuturesDataBasisRequestSchema });
|
|
711
|
+
// sig-ok: intentional
|
|
712
|
+
// GET https://dapi.binance.com/dapi/v1/ping
|
|
713
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Test-Connectivity
|
|
714
|
+
const coinMPing = Object.assign(async (signal) => {
|
|
715
|
+
return makeJsonRequest("GET", "/dapi/v1/ping", undefined, signal, coinMBaseURL);
|
|
716
|
+
}, { schema: undefined });
|
|
717
|
+
// sig-ok: intentional
|
|
718
|
+
// GET https://dapi.binance.com/dapi/v1/time
|
|
719
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Check-Server-time
|
|
720
|
+
const coinMTime = Object.assign(async (signal) => {
|
|
721
|
+
return makeJsonRequest("GET", "/dapi/v1/time", undefined, signal, coinMBaseURL);
|
|
722
|
+
}, { schema: undefined });
|
|
723
|
+
// sig-ok: intentional
|
|
724
|
+
// GET https://dapi.binance.com/dapi/v1/exchangeInfo
|
|
725
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Exchange-Information
|
|
726
|
+
const coinMExchangeInfo = Object.assign(async (signal) => {
|
|
727
|
+
return makeJsonRequest("GET", "/dapi/v1/exchangeInfo", undefined, signal, coinMBaseURL);
|
|
728
|
+
}, { schema: undefined });
|
|
729
|
+
// sig-ok: intentional
|
|
730
|
+
// GET https://dapi.binance.com/dapi/v1/depth{query}
|
|
731
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Order-Book
|
|
732
|
+
const coinMDepth = Object.assign(async (req, signal) => {
|
|
733
|
+
const query = buildQuery({
|
|
734
|
+
symbol: req.symbol,
|
|
735
|
+
limit: req.limit,
|
|
736
|
+
});
|
|
737
|
+
return makeJsonRequest("GET", `/dapi/v1/depth${query}`, undefined, signal, coinMBaseURL);
|
|
738
|
+
}, { schema: BinanceCoinMDepthRequestSchema });
|
|
739
|
+
// sig-ok: intentional
|
|
740
|
+
// GET https://dapi.binance.com/dapi/v1/trades{query}
|
|
741
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Recent-Trades-List
|
|
742
|
+
const coinMTrades = Object.assign(async (req, signal) => {
|
|
743
|
+
const query = buildQuery({
|
|
744
|
+
symbol: req.symbol,
|
|
745
|
+
limit: req.limit,
|
|
746
|
+
});
|
|
747
|
+
return makeJsonRequest("GET", `/dapi/v1/trades${query}`, undefined, signal, coinMBaseURL);
|
|
748
|
+
}, { schema: BinanceCoinMTradesRequestSchema });
|
|
749
|
+
// sig-ok: intentional
|
|
750
|
+
// GET https://dapi.binance.com/dapi/v1/aggTrades{query}
|
|
751
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Compressed-Aggregate-Trades-List
|
|
752
|
+
const coinMAggTrades = Object.assign(async (req, signal) => {
|
|
753
|
+
const query = buildQuery({
|
|
754
|
+
symbol: req.symbol,
|
|
755
|
+
fromId: req.fromId,
|
|
756
|
+
startTime: req.startTime,
|
|
757
|
+
endTime: req.endTime,
|
|
758
|
+
limit: req.limit,
|
|
759
|
+
});
|
|
760
|
+
return makeJsonRequest("GET", `/dapi/v1/aggTrades${query}`, undefined, signal, coinMBaseURL);
|
|
761
|
+
}, { schema: BinanceCoinMAggTradesRequestSchema });
|
|
762
|
+
// sig-ok: intentional
|
|
763
|
+
// GET https://dapi.binance.com/dapi/v1/premiumIndex{query}
|
|
764
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-and-Mark-Price
|
|
765
|
+
const coinMPremiumIndex = Object.assign(async (req = {}, signal) => {
|
|
766
|
+
const query = buildQuery({
|
|
767
|
+
symbol: req.symbol,
|
|
768
|
+
pair: req.pair,
|
|
769
|
+
});
|
|
770
|
+
return makeJsonRequest("GET", `/dapi/v1/premiumIndex${query}`, undefined, signal, coinMBaseURL);
|
|
771
|
+
}, { schema: BinanceCoinMPremiumIndexRequestSchema });
|
|
772
|
+
// sig-ok: intentional
|
|
773
|
+
// GET https://dapi.binance.com/dapi/v1/fundingRate{query}
|
|
774
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Get-Funding-Rate-History-of-Perpetual-Futures
|
|
775
|
+
const coinMFundingRate = Object.assign(async (req, signal) => {
|
|
776
|
+
const query = buildQuery({
|
|
777
|
+
symbol: req.symbol,
|
|
778
|
+
startTime: req.startTime,
|
|
779
|
+
endTime: req.endTime,
|
|
780
|
+
limit: req.limit,
|
|
781
|
+
});
|
|
782
|
+
return makeJsonRequest("GET", `/dapi/v1/fundingRate${query}`, undefined, signal, coinMBaseURL);
|
|
783
|
+
}, { schema: BinanceCoinMFundingRateRequestSchema });
|
|
784
|
+
// sig-ok: intentional
|
|
785
|
+
// GET https://dapi.binance.com/dapi/v1/fundingInfo
|
|
786
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Get-Funding-Info
|
|
787
|
+
const coinMFundingInfo = Object.assign(async (signal) => {
|
|
788
|
+
return makeJsonRequest("GET", "/dapi/v1/fundingInfo", undefined, signal, coinMBaseURL);
|
|
789
|
+
}, { schema: undefined });
|
|
790
|
+
// sig-ok: intentional
|
|
791
|
+
// GET https://dapi.binance.com/dapi/v1/klines{query}
|
|
792
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Kline-Candlestick-Data
|
|
793
|
+
const coinMKlines = Object.assign(async (req, signal) => {
|
|
794
|
+
const query = buildQuery({
|
|
795
|
+
symbol: req.symbol,
|
|
796
|
+
interval: req.interval,
|
|
797
|
+
startTime: req.startTime,
|
|
798
|
+
endTime: req.endTime,
|
|
799
|
+
limit: req.limit,
|
|
800
|
+
});
|
|
801
|
+
return makeJsonRequest("GET", `/dapi/v1/klines${query}`, undefined, signal, coinMBaseURL);
|
|
802
|
+
}, { schema: BinanceCoinMKlinesRequestSchema });
|
|
803
|
+
// sig-ok: intentional
|
|
804
|
+
// GET https://dapi.binance.com/dapi/v1/continuousKlines{query}
|
|
805
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Continuous-Contract-Kline-Candlestick-Data
|
|
806
|
+
const coinMContinuousKlines = Object.assign(async (req, signal) => {
|
|
807
|
+
const query = buildQuery({
|
|
808
|
+
pair: req.pair,
|
|
809
|
+
contractType: req.contractType,
|
|
810
|
+
interval: req.interval,
|
|
811
|
+
startTime: req.startTime,
|
|
812
|
+
endTime: req.endTime,
|
|
813
|
+
limit: req.limit,
|
|
814
|
+
});
|
|
815
|
+
return makeJsonRequest("GET", `/dapi/v1/continuousKlines${query}`, undefined, signal, coinMBaseURL);
|
|
816
|
+
}, { schema: BinanceCoinMContinuousKlinesRequestSchema });
|
|
817
|
+
// sig-ok: intentional
|
|
818
|
+
// GET https://dapi.binance.com/dapi/v1/indexPriceKlines{query}
|
|
819
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-Kline-Candlestick-Data
|
|
820
|
+
const coinMIndexPriceKlines = Object.assign(async (req, signal) => {
|
|
821
|
+
const query = buildQuery({
|
|
822
|
+
pair: req.pair,
|
|
823
|
+
interval: req.interval,
|
|
824
|
+
startTime: req.startTime,
|
|
825
|
+
endTime: req.endTime,
|
|
826
|
+
limit: req.limit,
|
|
827
|
+
});
|
|
828
|
+
return makeJsonRequest("GET", `/dapi/v1/indexPriceKlines${query}`, undefined, signal, coinMBaseURL);
|
|
829
|
+
}, { schema: BinanceCoinMIndexPriceKlinesRequestSchema });
|
|
830
|
+
// sig-ok: intentional
|
|
831
|
+
// GET https://dapi.binance.com/dapi/v1/markPriceKlines{query}
|
|
832
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Mark-Price-Kline-Candlestick-Data
|
|
833
|
+
const coinMMarkPriceKlines = Object.assign(async (req, signal) => {
|
|
834
|
+
const query = buildQuery({
|
|
835
|
+
symbol: req.symbol,
|
|
836
|
+
interval: req.interval,
|
|
837
|
+
startTime: req.startTime,
|
|
838
|
+
endTime: req.endTime,
|
|
839
|
+
limit: req.limit,
|
|
840
|
+
});
|
|
841
|
+
return makeJsonRequest("GET", `/dapi/v1/markPriceKlines${query}`, undefined, signal, coinMBaseURL);
|
|
842
|
+
}, { schema: BinanceCoinMMarkPriceKlinesRequestSchema });
|
|
843
|
+
// sig-ok: intentional
|
|
844
|
+
// GET https://dapi.binance.com/dapi/v1/premiumIndexKlines{query}
|
|
845
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Premium-Index-Kline-Data
|
|
846
|
+
const coinMPremiumIndexKlines = Object.assign(async (req, signal) => {
|
|
847
|
+
const query = buildQuery({
|
|
848
|
+
symbol: req.symbol,
|
|
849
|
+
interval: req.interval,
|
|
850
|
+
startTime: req.startTime,
|
|
851
|
+
endTime: req.endTime,
|
|
852
|
+
limit: req.limit,
|
|
853
|
+
});
|
|
854
|
+
return makeJsonRequest("GET", `/dapi/v1/premiumIndexKlines${query}`, undefined, signal, coinMBaseURL);
|
|
855
|
+
}, { schema: BinanceCoinMPremiumIndexKlinesRequestSchema });
|
|
856
|
+
// sig-ok: upstream numeric segment exposed as a TypeScript-friendly name.
|
|
857
|
+
// GET https://dapi.binance.com/dapi/v1/ticker/24hr{query}
|
|
858
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics
|
|
859
|
+
const coinMTickerTwentyFourHr = Object.assign(async (req = {}, signal) => {
|
|
860
|
+
const query = buildQuery({
|
|
861
|
+
symbol: req.symbol,
|
|
862
|
+
pair: req.pair,
|
|
863
|
+
});
|
|
864
|
+
return makeJsonRequest("GET", `/dapi/v1/ticker/24hr${query}`, undefined, signal, coinMBaseURL);
|
|
865
|
+
}, { schema: BinanceCoinMTickerRequestSchema });
|
|
866
|
+
// sig-ok: intentional
|
|
867
|
+
// GET https://dapi.binance.com/dapi/v1/ticker/price{query}
|
|
868
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Symbol-Price-Ticker
|
|
869
|
+
const coinMTickerPrice = Object.assign(async (req = {}, signal) => {
|
|
870
|
+
const query = buildQuery({
|
|
871
|
+
symbol: req.symbol,
|
|
872
|
+
pair: req.pair,
|
|
873
|
+
});
|
|
874
|
+
return makeJsonRequest("GET", `/dapi/v1/ticker/price${query}`, undefined, signal, coinMBaseURL);
|
|
875
|
+
}, { schema: BinanceCoinMTickerRequestSchema });
|
|
876
|
+
// sig-ok: intentional
|
|
877
|
+
// GET https://dapi.binance.com/dapi/v1/ticker/bookTicker{query}
|
|
878
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Symbol-Order-Book-Ticker
|
|
879
|
+
const coinMTickerBookTicker = Object.assign(async (req = {}, signal) => {
|
|
880
|
+
const query = buildQuery({
|
|
881
|
+
symbol: req.symbol,
|
|
882
|
+
pair: req.pair,
|
|
883
|
+
});
|
|
884
|
+
return makeJsonRequest("GET", `/dapi/v1/ticker/bookTicker${query}`, undefined, signal, coinMBaseURL);
|
|
885
|
+
}, { schema: BinanceCoinMTickerRequestSchema });
|
|
886
|
+
// sig-ok: intentional
|
|
887
|
+
// GET https://dapi.binance.com/dapi/v1/openInterest{query}
|
|
888
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Open-Interest
|
|
889
|
+
const coinMOpenInterest = Object.assign(async (req, signal) => {
|
|
890
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
891
|
+
return makeJsonRequest("GET", `/dapi/v1/openInterest${query}`, undefined, signal, coinMBaseURL);
|
|
892
|
+
}, { schema: BinanceCoinMOpenInterestRequestSchema });
|
|
893
|
+
// sig-ok: intentional
|
|
894
|
+
// GET https://dapi.binance.com/dapi/v1/constituents{query}
|
|
895
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Constituents
|
|
896
|
+
const coinMConstituents = Object.assign(async (req, signal) => {
|
|
897
|
+
const query = buildQuery({ symbol: req.symbol });
|
|
898
|
+
return makeJsonRequest("GET", `/dapi/v1/constituents${query}`, undefined, signal, coinMBaseURL);
|
|
899
|
+
}, { schema: BinanceCoinMConstituentsRequestSchema });
|
|
900
|
+
// sig-ok: intentional
|
|
901
|
+
// GET https://dapi.binance.com/futures/data/openInterestHist{query}
|
|
902
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Open-Interest-Statistics
|
|
903
|
+
const coinMOpenInterestHist = Object.assign(async (req, signal) => {
|
|
904
|
+
const query = buildQuery({
|
|
905
|
+
pair: req.pair,
|
|
906
|
+
contractType: req.contractType,
|
|
907
|
+
period: req.period,
|
|
908
|
+
limit: req.limit,
|
|
909
|
+
startTime: req.startTime,
|
|
910
|
+
endTime: req.endTime,
|
|
911
|
+
});
|
|
912
|
+
return makeJsonRequest("GET", `/futures/data/openInterestHist${query}`, undefined, signal, coinMBaseURL);
|
|
913
|
+
}, { schema: BinanceCoinMOpenInterestHistRequestSchema });
|
|
914
|
+
// sig-ok: intentional
|
|
915
|
+
// GET https://dapi.binance.com/futures/data/topLongShortPositionRatio{query}
|
|
916
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Top-Trader-Long-Short-Ratio
|
|
917
|
+
const coinMTopLongShortPositionRatio = Object.assign(async (req, signal) => {
|
|
918
|
+
const query = buildQuery({
|
|
919
|
+
pair: req.pair,
|
|
920
|
+
period: req.period,
|
|
921
|
+
limit: req.limit,
|
|
922
|
+
startTime: req.startTime,
|
|
923
|
+
endTime: req.endTime,
|
|
924
|
+
});
|
|
925
|
+
return makeJsonRequest("GET", `/futures/data/topLongShortPositionRatio${query}`, undefined, signal, coinMBaseURL);
|
|
926
|
+
}, { schema: BinanceCoinMTopLongShortPositionRatioRequestSchema });
|
|
927
|
+
// sig-ok: intentional
|
|
928
|
+
// GET https://dapi.binance.com/futures/data/topLongShortAccountRatio{query}
|
|
929
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Top-Long-Short-Account-Ratio
|
|
930
|
+
const coinMTopLongShortAccountRatio = Object.assign(async (req, signal) => {
|
|
931
|
+
const query = buildQuery({
|
|
932
|
+
pair: req.pair,
|
|
933
|
+
period: req.period,
|
|
934
|
+
limit: req.limit,
|
|
935
|
+
startTime: req.startTime,
|
|
936
|
+
endTime: req.endTime,
|
|
937
|
+
});
|
|
938
|
+
return makeJsonRequest("GET", `/futures/data/topLongShortAccountRatio${query}`, undefined, signal, coinMBaseURL);
|
|
939
|
+
}, { schema: BinanceCoinMTopLongShortAccountRatioRequestSchema });
|
|
940
|
+
// sig-ok: intentional
|
|
941
|
+
// GET https://dapi.binance.com/futures/data/globalLongShortAccountRatio{query}
|
|
942
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Long-Short-Ratio
|
|
943
|
+
const coinMGlobalLongShortAccountRatio = Object.assign(async (req, signal) => {
|
|
944
|
+
const query = buildQuery({
|
|
945
|
+
pair: req.pair,
|
|
946
|
+
period: req.period,
|
|
947
|
+
limit: req.limit,
|
|
948
|
+
startTime: req.startTime,
|
|
949
|
+
endTime: req.endTime,
|
|
950
|
+
});
|
|
951
|
+
return makeJsonRequest("GET", `/futures/data/globalLongShortAccountRatio${query}`, undefined, signal, coinMBaseURL);
|
|
952
|
+
}, { schema: BinanceCoinMGlobalLongShortAccountRatioRequestSchema });
|
|
953
|
+
// sig-ok: intentional
|
|
954
|
+
// GET https://dapi.binance.com/futures/data/takerBuySellVol{query}
|
|
955
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Taker-Buy-Sell-Volume
|
|
956
|
+
const coinMTakerBuySellVol = Object.assign(async (req, signal) => {
|
|
957
|
+
const query = buildQuery({
|
|
958
|
+
pair: req.pair,
|
|
959
|
+
contractType: req.contractType,
|
|
960
|
+
period: req.period,
|
|
961
|
+
limit: req.limit,
|
|
962
|
+
startTime: req.startTime,
|
|
963
|
+
endTime: req.endTime,
|
|
964
|
+
});
|
|
965
|
+
return makeJsonRequest("GET", `/futures/data/takerBuySellVol${query}`, undefined, signal, coinMBaseURL);
|
|
966
|
+
}, { schema: BinanceCoinMTakerBuySellVolRequestSchema });
|
|
967
|
+
// sig-ok: shared futures-data endpoint is public on the COIN-M base URL.
|
|
968
|
+
// GET https://dapi.binance.com/futures/data/delivery-price{query}
|
|
969
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Delivery-Price
|
|
970
|
+
const coinMDeliveryPrice = Object.assign(async (req, signal) => {
|
|
971
|
+
const query = buildQuery({
|
|
972
|
+
pair: req.pair,
|
|
973
|
+
});
|
|
974
|
+
return makeJsonRequest("GET", `/futures/data/delivery-price${query}`, undefined, signal, coinMBaseURL);
|
|
975
|
+
}, { schema: BinanceCoinMDeliveryPriceRequestSchema });
|
|
976
|
+
// sig-ok: intentional
|
|
977
|
+
// GET https://dapi.binance.com/futures/data/basis{query}
|
|
978
|
+
// Docs: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Basis
|
|
979
|
+
const coinMBasis = Object.assign(async (req, signal) => {
|
|
980
|
+
const query = buildQuery({
|
|
981
|
+
pair: req.pair,
|
|
982
|
+
contractType: req.contractType,
|
|
983
|
+
period: req.period,
|
|
984
|
+
limit: req.limit,
|
|
985
|
+
startTime: req.startTime,
|
|
986
|
+
endTime: req.endTime,
|
|
987
|
+
});
|
|
988
|
+
return makeJsonRequest("GET", `/futures/data/basis${query}`, undefined, signal, coinMBaseURL);
|
|
989
|
+
}, { schema: BinanceCoinMBasisRequestSchema });
|
|
275
990
|
const api = {
|
|
276
991
|
v3: {
|
|
277
992
|
aggTrades,
|
|
278
993
|
avgPrice,
|
|
279
994
|
depth,
|
|
280
995
|
exchangeInfo,
|
|
996
|
+
executionRules,
|
|
281
997
|
historicalBlockTrades,
|
|
282
998
|
historicalTrades,
|
|
283
999
|
klines,
|
|
@@ -289,10 +1005,178 @@ export function createBinance(opts) {
|
|
|
289
1005
|
uiKlines,
|
|
290
1006
|
},
|
|
291
1007
|
};
|
|
1008
|
+
const eapi = {
|
|
1009
|
+
v1: {
|
|
1010
|
+
blockTrades: eapiBlockTrades,
|
|
1011
|
+
depth: eapiDepth,
|
|
1012
|
+
exchangeInfo: eapiExchangeInfo,
|
|
1013
|
+
exerciseHistory: eapiExerciseHistory,
|
|
1014
|
+
index: eapiIndex,
|
|
1015
|
+
klines: eapiKlines,
|
|
1016
|
+
mark: eapiMark,
|
|
1017
|
+
openInterest: eapiOpenInterest,
|
|
1018
|
+
ping: eapiPing,
|
|
1019
|
+
ticker: eapiTicker,
|
|
1020
|
+
time: eapiTime,
|
|
1021
|
+
trades: eapiTrades,
|
|
1022
|
+
},
|
|
1023
|
+
};
|
|
1024
|
+
const fapi = {
|
|
1025
|
+
v1: {
|
|
1026
|
+
aggTrades: fapiAggTrades,
|
|
1027
|
+
assetIndex: fapiAssetIndex,
|
|
1028
|
+
constituents: fapiConstituents,
|
|
1029
|
+
continuousKlines: fapiContinuousKlines,
|
|
1030
|
+
depth: fapiDepth,
|
|
1031
|
+
exchangeInfo: fapiExchangeInfo,
|
|
1032
|
+
fundingInfo: fapiFundingInfo,
|
|
1033
|
+
fundingRate: fapiFundingRate,
|
|
1034
|
+
indexInfo: fapiIndexInfo,
|
|
1035
|
+
indexPriceKlines: fapiIndexPriceKlines,
|
|
1036
|
+
insuranceBalance: fapiInsuranceBalance,
|
|
1037
|
+
klines: fapiKlines,
|
|
1038
|
+
markPriceKlines: fapiMarkPriceKlines,
|
|
1039
|
+
openInterest: fapiOpenInterest,
|
|
1040
|
+
ping: fapiPing,
|
|
1041
|
+
premiumIndex: fapiPremiumIndex,
|
|
1042
|
+
premiumIndexKlines: fapiPremiumIndexKlines,
|
|
1043
|
+
rpiDepth: fapiRpiDepth,
|
|
1044
|
+
symbolAdlRisk: fapiSymbolAdlRisk,
|
|
1045
|
+
ticker: {
|
|
1046
|
+
bookTicker: fapiTickerBookTicker,
|
|
1047
|
+
twentyFourHr: fapiTickerTwentyFourHr,
|
|
1048
|
+
},
|
|
1049
|
+
time: fapiTime,
|
|
1050
|
+
trades: fapiTrades,
|
|
1051
|
+
tradingSchedule: fapiTradingSchedule,
|
|
1052
|
+
},
|
|
1053
|
+
v2: {
|
|
1054
|
+
ticker: {
|
|
1055
|
+
price: fapiV2TickerPrice,
|
|
1056
|
+
},
|
|
1057
|
+
},
|
|
1058
|
+
};
|
|
1059
|
+
const futures = {
|
|
1060
|
+
data: {
|
|
1061
|
+
basis: futuresDataBasis,
|
|
1062
|
+
deliveryPrice: futuresDataDeliveryPrice,
|
|
1063
|
+
globalLongShortAccountRatio: futuresDataGlobalLongShortAccountRatio,
|
|
1064
|
+
openInterestHist: futuresDataOpenInterestHist,
|
|
1065
|
+
takerlongshortRatio: futuresDataTakerlongshortRatio,
|
|
1066
|
+
topLongShortAccountRatio: futuresDataTopLongShortAccountRatio,
|
|
1067
|
+
topLongShortPositionRatio: futuresDataTopLongShortPositionRatio,
|
|
1068
|
+
},
|
|
1069
|
+
};
|
|
1070
|
+
const dapi = {
|
|
1071
|
+
v1: {
|
|
1072
|
+
aggTrades: coinMAggTrades,
|
|
1073
|
+
constituents: coinMConstituents,
|
|
1074
|
+
continuousKlines: coinMContinuousKlines,
|
|
1075
|
+
depth: coinMDepth,
|
|
1076
|
+
exchangeInfo: coinMExchangeInfo,
|
|
1077
|
+
fundingInfo: coinMFundingInfo,
|
|
1078
|
+
fundingRate: coinMFundingRate,
|
|
1079
|
+
indexPriceKlines: coinMIndexPriceKlines,
|
|
1080
|
+
klines: coinMKlines,
|
|
1081
|
+
markPriceKlines: coinMMarkPriceKlines,
|
|
1082
|
+
openInterest: coinMOpenInterest,
|
|
1083
|
+
ping: coinMPing,
|
|
1084
|
+
premiumIndex: coinMPremiumIndex,
|
|
1085
|
+
premiumIndexKlines: coinMPremiumIndexKlines,
|
|
1086
|
+
ticker: {
|
|
1087
|
+
bookTicker: coinMTickerBookTicker,
|
|
1088
|
+
price: coinMTickerPrice,
|
|
1089
|
+
twentyFourHr: coinMTickerTwentyFourHr,
|
|
1090
|
+
},
|
|
1091
|
+
time: coinMTime,
|
|
1092
|
+
trades: coinMTrades,
|
|
1093
|
+
},
|
|
1094
|
+
};
|
|
1095
|
+
const coinMFutures = {
|
|
1096
|
+
data: {
|
|
1097
|
+
basis: coinMBasis,
|
|
1098
|
+
deliveryPrice: coinMDeliveryPrice,
|
|
1099
|
+
globalLongShortAccountRatio: coinMGlobalLongShortAccountRatio,
|
|
1100
|
+
openInterestHist: coinMOpenInterestHist,
|
|
1101
|
+
takerBuySellVol: coinMTakerBuySellVol,
|
|
1102
|
+
topLongShortAccountRatio: coinMTopLongShortAccountRatio,
|
|
1103
|
+
topLongShortPositionRatio: coinMTopLongShortPositionRatio,
|
|
1104
|
+
},
|
|
1105
|
+
};
|
|
1106
|
+
// sig-ok: public namespace intentionally separates no-auth Spot calls from legacy api.v3.
|
|
1107
|
+
// GET https://api.binance.com/api/v3/ping
|
|
1108
|
+
// Docs: https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#test-connectivity
|
|
1109
|
+
const publicSpotPing = Object.assign(async (signal) => {
|
|
1110
|
+
return makeJsonRequest("GET", "/api/v3/ping", undefined, signal, { auth: "none", baseOverride: baseURL });
|
|
1111
|
+
}, { schema: undefined });
|
|
1112
|
+
// sig-ok: public spotData uses Binance's market-data-only host for Spot REST.
|
|
1113
|
+
// GET https://data-api.binance.vision/api/v3/ping
|
|
1114
|
+
// Docs: https://developers.binance.com/docs/binance-spot-api-docs/faqs/market_data_only
|
|
1115
|
+
const publicSpotDataPing = Object.assign(async (signal) => {
|
|
1116
|
+
return makeJsonRequest("GET", "/api/v3/ping", undefined, signal, { auth: "none", baseOverride: spotDataBaseURL });
|
|
1117
|
+
}, { schema: undefined });
|
|
1118
|
+
// sig-ok: public namespace intentionally groups USD-M Futures before /fapi.
|
|
1119
|
+
// GET https://fapi.binance.com/fapi/v1/ping
|
|
1120
|
+
// Docs: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Test-Connectivity
|
|
1121
|
+
const publicUsdMFuturesPing = Object.assign(async (signal) => {
|
|
1122
|
+
return makeJsonRequest("GET", "/fapi/v1/ping", undefined, signal, { auth: "none", baseOverride: fapiBaseURL });
|
|
1123
|
+
}, { schema: undefined });
|
|
1124
|
+
// sig-ok: public namespace intentionally groups Options before /eapi.
|
|
1125
|
+
// GET https://eapi.binance.com/eapi/v1/ping
|
|
1126
|
+
// Docs: https://developers.binance.com/docs/derivatives/options-trading/market-data/Test-Connectivity
|
|
1127
|
+
const publicOptionsPing = Object.assign(async (signal) => {
|
|
1128
|
+
return makeJsonRequest("GET", "/eapi/v1/ping", undefined, signal, { auth: "none", baseOverride: eapiBaseURL });
|
|
1129
|
+
}, { schema: undefined });
|
|
1130
|
+
const publicApi = {
|
|
1131
|
+
spot: {
|
|
1132
|
+
api: {
|
|
1133
|
+
v3: {
|
|
1134
|
+
ping: publicSpotPing,
|
|
1135
|
+
},
|
|
1136
|
+
},
|
|
1137
|
+
},
|
|
1138
|
+
spotData: {
|
|
1139
|
+
api: {
|
|
1140
|
+
v3: {
|
|
1141
|
+
ping: publicSpotDataPing,
|
|
1142
|
+
},
|
|
1143
|
+
},
|
|
1144
|
+
},
|
|
1145
|
+
usdMFutures: {
|
|
1146
|
+
fapi: {
|
|
1147
|
+
v1: {
|
|
1148
|
+
ping: publicUsdMFuturesPing,
|
|
1149
|
+
},
|
|
1150
|
+
},
|
|
1151
|
+
},
|
|
1152
|
+
coinMFutures: {
|
|
1153
|
+
dapi,
|
|
1154
|
+
futures: coinMFutures,
|
|
1155
|
+
},
|
|
1156
|
+
options: {
|
|
1157
|
+
eapi: {
|
|
1158
|
+
v1: {
|
|
1159
|
+
ping: publicOptionsPing,
|
|
1160
|
+
},
|
|
1161
|
+
},
|
|
1162
|
+
},
|
|
1163
|
+
};
|
|
292
1164
|
return {
|
|
293
1165
|
api,
|
|
1166
|
+
eapi,
|
|
1167
|
+
fapi,
|
|
1168
|
+
dapi,
|
|
1169
|
+
futures,
|
|
1170
|
+
coinMFutures,
|
|
1171
|
+
public: publicApi,
|
|
294
1172
|
get: {
|
|
295
1173
|
api,
|
|
1174
|
+
eapi,
|
|
1175
|
+
fapi,
|
|
1176
|
+
dapi,
|
|
1177
|
+
futures,
|
|
1178
|
+
coinMFutures,
|
|
1179
|
+
public: publicApi,
|
|
296
1180
|
},
|
|
297
1181
|
};
|
|
298
1182
|
}
|