UNPKG

@binance/spot

Version:

Official Binance Spot Connector - A lightweight library that provides a convenient interface to Binance's Spot REST API, WebSocket API and WebSocket Streams.

1,256 lines (1,250 loc) 434 kB
var __defProp = Object.defineProperty; var __export = (target, all) => { for (var name2 in all) __defProp(target, name2, { get: all[name2], enumerable: true }); }; // src/spot.ts import { buildUserAgent, ConfigurationRestAPI as ConfigurationRestAPI7, ConfigurationWebsocketAPI as ConfigurationWebsocketAPI2, ConfigurationWebsocketStreams as ConfigurationWebsocketStreams2, SPOT_REST_API_PROD_URL, SPOT_WS_API_PROD_URL, SPOT_WS_STREAMS_PROD_URL } from "@binance/common"; // package.json var name = "@binance/spot"; var version = "16.0.0"; // src/rest-api/index.ts var rest_api_exports = {}; __export(rest_api_exports, { AccountApi: () => AccountApi, DeleteOrderCancelRestrictionsEnum: () => DeleteOrderCancelRestrictionsEnum, ExchangeInfoSymbolStatusEnum: () => ExchangeInfoSymbolStatusEnum, GeneralApi: () => GeneralApi, KlinesIntervalEnum: () => KlinesIntervalEnum, MarketApi: () => MarketApi, NewOrderNewOrderRespTypeEnum: () => NewOrderNewOrderRespTypeEnum, NewOrderPegOffsetTypeEnum: () => NewOrderPegOffsetTypeEnum, NewOrderPegPriceTypeEnum: () => NewOrderPegPriceTypeEnum, NewOrderSelfTradePreventionModeEnum: () => NewOrderSelfTradePreventionModeEnum, NewOrderSideEnum: () => NewOrderSideEnum, NewOrderTimeInForceEnum: () => NewOrderTimeInForceEnum, NewOrderTypeEnum: () => NewOrderTypeEnum, OrderCancelReplaceCancelReplaceModeEnum: () => OrderCancelReplaceCancelReplaceModeEnum, OrderCancelReplaceCancelRestrictionsEnum: () => OrderCancelReplaceCancelRestrictionsEnum, OrderCancelReplaceNewOrderRespTypeEnum: () => OrderCancelReplaceNewOrderRespTypeEnum, OrderCancelReplaceOrderRateLimitExceededModeEnum: () => OrderCancelReplaceOrderRateLimitExceededModeEnum, OrderCancelReplacePegOffsetTypeEnum: () => OrderCancelReplacePegOffsetTypeEnum, OrderCancelReplacePegPriceTypeEnum: () => OrderCancelReplacePegPriceTypeEnum, OrderCancelReplaceSelfTradePreventionModeEnum: () => OrderCancelReplaceSelfTradePreventionModeEnum, OrderCancelReplaceSideEnum: () => OrderCancelReplaceSideEnum, OrderCancelReplaceTimeInForceEnum: () => OrderCancelReplaceTimeInForceEnum, OrderCancelReplaceTypeEnum: () => OrderCancelReplaceTypeEnum, OrderListOcoAbovePegOffsetTypeEnum: () => OrderListOcoAbovePegOffsetTypeEnum, OrderListOcoAbovePegPriceTypeEnum: () => OrderListOcoAbovePegPriceTypeEnum, OrderListOcoAboveTypeEnum: () => OrderListOcoAboveTypeEnum, OrderListOcoBelowPegOffsetTypeEnum: () => OrderListOcoBelowPegOffsetTypeEnum, OrderListOcoBelowPegPriceTypeEnum: () => OrderListOcoBelowPegPriceTypeEnum, OrderListOcoBelowTimeInForceEnum: () => OrderListOcoBelowTimeInForceEnum, OrderListOcoBelowTypeEnum: () => OrderListOcoBelowTypeEnum, OrderListOcoNewOrderRespTypeEnum: () => OrderListOcoNewOrderRespTypeEnum, OrderListOcoSelfTradePreventionModeEnum: () => OrderListOcoSelfTradePreventionModeEnum, OrderListOcoSideEnum: () => OrderListOcoSideEnum, OrderListOtoNewOrderRespTypeEnum: () => OrderListOtoNewOrderRespTypeEnum, OrderListOtoPendingPegOffsetTypeEnum: () => OrderListOtoPendingPegOffsetTypeEnum, OrderListOtoPendingPegPriceTypeEnum: () => OrderListOtoPendingPegPriceTypeEnum, OrderListOtoPendingSideEnum: () => OrderListOtoPendingSideEnum, OrderListOtoPendingTimeInForceEnum: () => OrderListOtoPendingTimeInForceEnum, OrderListOtoPendingTypeEnum: () => OrderListOtoPendingTypeEnum, OrderListOtoSelfTradePreventionModeEnum: () => OrderListOtoSelfTradePreventionModeEnum, OrderListOtoWorkingPegOffsetTypeEnum: () => OrderListOtoWorkingPegOffsetTypeEnum, OrderListOtoWorkingPegPriceTypeEnum: () => OrderListOtoWorkingPegPriceTypeEnum, OrderListOtoWorkingSideEnum: () => OrderListOtoWorkingSideEnum, OrderListOtoWorkingTimeInForceEnum: () => OrderListOtoWorkingTimeInForceEnum, OrderListOtoWorkingTypeEnum: () => OrderListOtoWorkingTypeEnum, OrderListOtocoNewOrderRespTypeEnum: () => OrderListOtocoNewOrderRespTypeEnum, OrderListOtocoPendingAbovePegOffsetTypeEnum: () => OrderListOtocoPendingAbovePegOffsetTypeEnum, OrderListOtocoPendingAbovePegPriceTypeEnum: () => OrderListOtocoPendingAbovePegPriceTypeEnum, OrderListOtocoPendingAboveTimeInForceEnum: () => OrderListOtocoPendingAboveTimeInForceEnum, OrderListOtocoPendingAboveTypeEnum: () => OrderListOtocoPendingAboveTypeEnum, OrderListOtocoPendingBelowPegOffsetTypeEnum: () => OrderListOtocoPendingBelowPegOffsetTypeEnum, OrderListOtocoPendingBelowPegPriceTypeEnum: () => OrderListOtocoPendingBelowPegPriceTypeEnum, OrderListOtocoPendingBelowTimeInForceEnum: () => OrderListOtocoPendingBelowTimeInForceEnum, OrderListOtocoPendingBelowTypeEnum: () => OrderListOtocoPendingBelowTypeEnum, OrderListOtocoPendingSideEnum: () => OrderListOtocoPendingSideEnum, OrderListOtocoSelfTradePreventionModeEnum: () => OrderListOtocoSelfTradePreventionModeEnum, OrderListOtocoWorkingPegOffsetTypeEnum: () => OrderListOtocoWorkingPegOffsetTypeEnum, OrderListOtocoWorkingPegPriceTypeEnum: () => OrderListOtocoWorkingPegPriceTypeEnum, OrderListOtocoWorkingSideEnum: () => OrderListOtocoWorkingSideEnum, OrderListOtocoWorkingTimeInForceEnum: () => OrderListOtocoWorkingTimeInForceEnum, OrderListOtocoWorkingTypeEnum: () => OrderListOtocoWorkingTypeEnum, OrderOcoNewOrderRespTypeEnum: () => OrderOcoNewOrderRespTypeEnum, OrderOcoSelfTradePreventionModeEnum: () => OrderOcoSelfTradePreventionModeEnum, OrderOcoSideEnum: () => OrderOcoSideEnum, OrderOcoStopLimitTimeInForceEnum: () => OrderOcoStopLimitTimeInForceEnum, OrderTestNewOrderRespTypeEnum: () => OrderTestNewOrderRespTypeEnum, OrderTestPegOffsetTypeEnum: () => OrderTestPegOffsetTypeEnum, OrderTestPegPriceTypeEnum: () => OrderTestPegPriceTypeEnum, OrderTestSelfTradePreventionModeEnum: () => OrderTestSelfTradePreventionModeEnum, OrderTestSideEnum: () => OrderTestSideEnum, OrderTestTimeInForceEnum: () => OrderTestTimeInForceEnum, OrderTestTypeEnum: () => OrderTestTypeEnum, RestAPI: () => RestAPI, SorOrderNewOrderRespTypeEnum: () => SorOrderNewOrderRespTypeEnum, SorOrderSelfTradePreventionModeEnum: () => SorOrderSelfTradePreventionModeEnum, SorOrderSideEnum: () => SorOrderSideEnum, SorOrderTestNewOrderRespTypeEnum: () => SorOrderTestNewOrderRespTypeEnum, SorOrderTestSelfTradePreventionModeEnum: () => SorOrderTestSelfTradePreventionModeEnum, SorOrderTestSideEnum: () => SorOrderTestSideEnum, SorOrderTestTimeInForceEnum: () => SorOrderTestTimeInForceEnum, SorOrderTestTypeEnum: () => SorOrderTestTypeEnum, SorOrderTimeInForceEnum: () => SorOrderTimeInForceEnum, SorOrderTypeEnum: () => SorOrderTypeEnum, Ticker24hrTypeEnum: () => Ticker24hrTypeEnum, TickerTradingDayTypeEnum: () => TickerTradingDayTypeEnum, TickerTypeEnum: () => TickerTypeEnum, TickerWindowSizeEnum: () => TickerWindowSizeEnum, TradeApi: () => TradeApi, UiKlinesIntervalEnum: () => UiKlinesIntervalEnum, UserDataStreamApi: () => UserDataStreamApi }); // src/rest-api/modules/account-api.ts import { assertParamExists, sendRequest } from "@binance/common"; var AccountApiAxiosParamCreator = function(configuration) { return { /** * Get current account commission rates. * Weight: 20 * * @summary Query Commission Rates * @param {string} symbol * * @throws {RequiredError} */ accountCommission: async (symbol) => { assertParamExists("accountCommission", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/account/commission", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Retrieves all order lists based on provided optional parameters. * * Note that the time between `startTime` and `endTime` can't be longer than 24 hours. * Weight: 20 * * @summary Query all Order lists * @param {number} [fromId] ID to get aggregate trades from INCLUSIVE. * @param {number} [startTime] Timestamp in ms to get aggregate trades from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get aggregate trades until INCLUSIVE. * @param {number} [limit] Default: 500; Maximum: 1000. * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ allOrderList: async (fromId, startTime, endTime, limit, recvWindow) => { const localVarQueryParameter = {}; if (fromId !== void 0 && fromId !== null) { localVarQueryParameter["fromId"] = fromId; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/allOrderList", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get all account orders; active, canceled, or filled. * Weight: 20 * * @summary All orders * @param {string} symbol * @param {number} [orderId] * @param {number} [startTime] Timestamp in ms to get aggregate trades from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get aggregate trades until INCLUSIVE. * @param {number} [limit] Default: 500; Maximum: 1000. * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ allOrders: async (symbol, orderId, startTime, endTime, limit, recvWindow) => { assertParamExists("allOrders", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (orderId !== void 0 && orderId !== null) { localVarQueryParameter["orderId"] = orderId; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/allOrders", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get current account information. * Weight: 20 * * @summary Account information * @param {boolean} [omitZeroBalances] When set to `true`, emits only the non-zero balances of an account. <br>Default value: `false` * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ getAccount: async (omitZeroBalances, recvWindow) => { const localVarQueryParameter = {}; if (omitZeroBalances !== void 0 && omitZeroBalances !== null) { localVarQueryParameter["omitZeroBalances"] = omitZeroBalances; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/account", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get all open orders on a symbol. **Careful** when accessing this with no symbol. * Weight: 6 for a single symbol; **80** when the symbol parameter is omitted * * @summary Current open orders * @param {string} [symbol] Symbol to query * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ getOpenOrders: async (symbol, recvWindow) => { const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/openOrders", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Check an order's status. * Weight: 4 * * @summary Query order * @param {string} symbol * @param {number} [orderId] * @param {string} [origClientOrderId] * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ getOrder: async (symbol, orderId, origClientOrderId, recvWindow) => { assertParamExists("getOrder", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (orderId !== void 0 && orderId !== null) { localVarQueryParameter["orderId"] = orderId; } if (origClientOrderId !== void 0 && origClientOrderId !== null) { localVarQueryParameter["origClientOrderId"] = origClientOrderId; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/order", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Retrieves a specific order list based on provided optional parameters. * Weight: 4 * * @summary Query Order list * @param {number} [orderListId] Either `orderListId` or `listClientOrderId` must be provided * @param {string} [origClientOrderId] * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ getOrderList: async (orderListId, origClientOrderId, recvWindow) => { const localVarQueryParameter = {}; if (orderListId !== void 0 && orderListId !== null) { localVarQueryParameter["orderListId"] = orderListId; } if (origClientOrderId !== void 0 && origClientOrderId !== null) { localVarQueryParameter["origClientOrderId"] = origClientOrderId; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/orderList", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Retrieves allocations resulting from SOR order placement. * Weight: 20 * * @summary Query Allocations * @param {string} symbol * @param {number} [startTime] Timestamp in ms to get aggregate trades from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get aggregate trades until INCLUSIVE. * @param {number} [fromAllocationId] * @param {number} [limit] Default: 500; Maximum: 1000. * @param {number} [orderId] * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ myAllocations: async (symbol, startTime, endTime, fromAllocationId, limit, orderId, recvWindow) => { assertParamExists("myAllocations", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (fromAllocationId !== void 0 && fromAllocationId !== null) { localVarQueryParameter["fromAllocationId"] = fromAllocationId; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } if (orderId !== void 0 && orderId !== null) { localVarQueryParameter["orderId"] = orderId; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/myAllocations", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Displays the list of orders that were expired due to STP. * * These are the combinations supported: * * `symbol` + `preventedMatchId` * `symbol` + `orderId` * `symbol` + `orderId` + `fromPreventedMatchId` (`limit` will default to 500) * `symbol` + `orderId` + `fromPreventedMatchId` + `limit` * Weight: Case | Weight * ---- | ----- * If `symbol` is invalid | 2 * Querying by `preventedMatchId` | 2 * Querying by `orderId` | 20 * * @summary Query Prevented Matches * @param {string} symbol * @param {number} [preventedMatchId] * @param {number} [orderId] * @param {number} [fromPreventedMatchId] * @param {number} [limit] Default: 500; Maximum: 1000. * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ myPreventedMatches: async (symbol, preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow) => { assertParamExists("myPreventedMatches", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (preventedMatchId !== void 0 && preventedMatchId !== null) { localVarQueryParameter["preventedMatchId"] = preventedMatchId; } if (orderId !== void 0 && orderId !== null) { localVarQueryParameter["orderId"] = orderId; } if (fromPreventedMatchId !== void 0 && fromPreventedMatchId !== null) { localVarQueryParameter["fromPreventedMatchId"] = fromPreventedMatchId; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/myPreventedMatches", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get trades for a specific account and symbol. * Weight: Condition| Weight| * ---| --- * |Without orderId|20| * |With orderId|5| * * @summary Account trade list * @param {string} symbol * @param {number} [orderId] * @param {number} [startTime] Timestamp in ms to get aggregate trades from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get aggregate trades until INCLUSIVE. * @param {number} [fromId] ID to get aggregate trades from INCLUSIVE. * @param {number} [limit] Default: 500; Maximum: 1000. * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ myTrades: async (symbol, orderId, startTime, endTime, fromId, limit, recvWindow) => { assertParamExists("myTrades", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (orderId !== void 0 && orderId !== null) { localVarQueryParameter["orderId"] = orderId; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (fromId !== void 0 && fromId !== null) { localVarQueryParameter["fromId"] = fromId; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/myTrades", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * * Weight: 6 * * @summary Query Open Order lists * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ openOrderList: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/openOrderList", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Queries all amendments of a single order. * Weight: 4 * * @summary Query Order Amendments * @param {string} symbol * @param {number} orderId * @param {number} [fromExecutionId] * @param {number} [limit] Default:500; Maximum: 1000 * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ orderAmendments: async (symbol, orderId, fromExecutionId, limit, recvWindow) => { assertParamExists("orderAmendments", "symbol", symbol); assertParamExists("orderAmendments", "orderId", orderId); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (orderId !== void 0 && orderId !== null) { localVarQueryParameter["orderId"] = orderId; } if (fromExecutionId !== void 0 && fromExecutionId !== null) { localVarQueryParameter["fromExecutionId"] = fromExecutionId; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/order/amendments", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Displays the user's unfilled order count for all intervals. * Weight: 40 * * @summary Query Unfilled Order Count * @param {number} [recvWindow] The value cannot be greater than `60000` * * @throws {RequiredError} */ rateLimitOrder: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/rateLimit/order", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; var AccountApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = AccountApiAxiosParamCreator(configuration); } /** * Get current account commission rates. * Weight: 20 * * @summary Query Commission Rates * @param {AccountCommissionRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<AccountCommissionResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-commission-rates-user_data Binance API Documentation} */ async accountCommission(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.accountCommission( requestParameters?.symbol ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Retrieves all order lists based on provided optional parameters. * * Note that the time between `startTime` and `endTime` can't be longer than 24 hours. * Weight: 20 * * @summary Query all Order lists * @param {AllOrderListRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<AllOrderListResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-all-order-lists-user_data Binance API Documentation} */ async allOrderList(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.allOrderList( requestParameters?.fromId, requestParameters?.startTime, requestParameters?.endTime, requestParameters?.limit, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get all account orders; active, canceled, or filled. * Weight: 20 * * @summary All orders * @param {AllOrdersRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<AllOrdersResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#all-orders-user_data Binance API Documentation} */ async allOrders(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.allOrders( requestParameters?.symbol, requestParameters?.orderId, requestParameters?.startTime, requestParameters?.endTime, requestParameters?.limit, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get current account information. * Weight: 20 * * @summary Account information * @param {GetAccountRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetAccountResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data Binance API Documentation} */ async getAccount(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getAccount( requestParameters?.omitZeroBalances, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get all open orders on a symbol. **Careful** when accessing this with no symbol. * Weight: 6 for a single symbol; **80** when the symbol parameter is omitted * * @summary Current open orders * @param {GetOpenOrdersRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetOpenOrdersResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#current-open-orders-user_data Binance API Documentation} */ async getOpenOrders(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getOpenOrders( requestParameters?.symbol, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Check an order's status. * Weight: 4 * * @summary Query order * @param {GetOrderRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetOrderResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-order-user_data Binance API Documentation} */ async getOrder(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getOrder( requestParameters?.symbol, requestParameters?.orderId, requestParameters?.origClientOrderId, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Retrieves a specific order list based on provided optional parameters. * Weight: 4 * * @summary Query Order list * @param {GetOrderListRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetOrderListResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-order-list-user_data Binance API Documentation} */ async getOrderList(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getOrderList( requestParameters?.orderListId, requestParameters?.origClientOrderId, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Retrieves allocations resulting from SOR order placement. * Weight: 20 * * @summary Query Allocations * @param {MyAllocationsRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<MyAllocationsResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-allocations-user_data Binance API Documentation} */ async myAllocations(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.myAllocations( requestParameters?.symbol, requestParameters?.startTime, requestParameters?.endTime, requestParameters?.fromAllocationId, requestParameters?.limit, requestParameters?.orderId, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Displays the list of orders that were expired due to STP. * * These are the combinations supported: * * `symbol` + `preventedMatchId` * `symbol` + `orderId` * `symbol` + `orderId` + `fromPreventedMatchId` (`limit` will default to 500) * `symbol` + `orderId` + `fromPreventedMatchId` + `limit` * Weight: Case | Weight * ---- | ----- * If `symbol` is invalid | 2 * Querying by `preventedMatchId` | 2 * Querying by `orderId` | 20 * * @summary Query Prevented Matches * @param {MyPreventedMatchesRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<MyPreventedMatchesResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-prevented-matches-user_data Binance API Documentation} */ async myPreventedMatches(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.myPreventedMatches( requestParameters?.symbol, requestParameters?.preventedMatchId, requestParameters?.orderId, requestParameters?.fromPreventedMatchId, requestParameters?.limit, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get trades for a specific account and symbol. * Weight: Condition| Weight| * ---| --- * |Without orderId|20| * |With orderId|5| * * @summary Account trade list * @param {MyTradesRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<MyTradesResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-trade-list-user_data Binance API Documentation} */ async myTrades(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.myTrades( requestParameters?.symbol, requestParameters?.orderId, requestParameters?.startTime, requestParameters?.endTime, requestParameters?.fromId, requestParameters?.limit, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * * Weight: 6 * * @summary Query Open Order lists * @param {OpenOrderListRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<OpenOrderListResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-open-order-lists-user_data Binance API Documentation} */ async openOrderList(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.openOrderList( requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Queries all amendments of a single order. * Weight: 4 * * @summary Query Order Amendments * @param {OrderAmendmentsRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<OrderAmendmentsResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-order-amendments-user_data Binance API Documentation} */ async orderAmendments(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.orderAmendments( requestParameters?.symbol, requestParameters?.orderId, requestParameters?.fromExecutionId, requestParameters?.limit, requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Displays the user's unfilled order count for all intervals. * Weight: 40 * * @summary Query Unfilled Order Count * @param {RateLimitOrderRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<RateLimitOrderResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-unfilled-order-count-user_data Binance API Documentation} */ async rateLimitOrder(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.rateLimitOrder( requestParameters?.recvWindow ); return sendRequest( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } }; // src/rest-api/modules/general-api.ts import { sendRequest as sendRequest2 } from "@binance/common"; var GeneralApiAxiosParamCreator = function(configuration) { return { /** * Current exchange trading rules and symbol information * Weight: 20 * * @summary Exchange information * @param {string} [symbol] Symbol to query * @param {Array<string>} [symbols] List of symbols to query * @param {Array<string>} [permissions] List of permissions to query * @param {boolean} [showPermissionSets] Controls whether the content of the `permissionSets` field is populated or not. Defaults to `true` * @param {ExchangeInfoSymbolStatusEnum} [symbolStatus] * * @throws {RequiredError} */ exchangeInfo: async (symbol, symbols, permissions, showPermissionSets, symbolStatus) => { const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (symbols) { localVarQueryParameter["symbols"] = symbols; } if (permissions) { localVarQueryParameter["permissions"] = permissions; } if (showPermissionSets !== void 0 && showPermissionSets !== null) { localVarQueryParameter["showPermissionSets"] = showPermissionSets; } if (symbolStatus !== void 0 && symbolStatus !== null) { localVarQueryParameter["symbolStatus"] = symbolStatus; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/exchangeInfo", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Test connectivity to the Rest API. * Weight: 1 * * @summary Test connectivity * * @throws {RequiredError} */ ping: async () => { const localVarQueryParameter = {}; let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/ping", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Test connectivity to the Rest API and get the current server time. * Weight: 1 * * @summary Check server time * * @throws {RequiredError} */ time: async () => { const localVarQueryParameter = {}; let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/time", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; var GeneralApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = GeneralApiAxiosParamCreator(configuration); } /** * Current exchange trading rules and symbol information * Weight: 20 * * @summary Exchange information * @param {ExchangeInfoRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<ExchangeInfoResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof GeneralApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#exchange-information Binance API Documentation} */ async exchangeInfo(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.exchangeInfo( requestParameters?.symbol, requestParameters?.symbols, requestParameters?.permissions, requestParameters?.showPermissionSets, requestParameters?.symbolStatus ); return sendRequest2( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: false } ); } /** * Test connectivity to the Rest API. * Weight: 1 * * @summary Test connectivity * @returns {Promise<RestApiResponse<void>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof GeneralApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#test-connectivity Binance API Documentation} */ async ping() { const localVarAxiosArgs = await this.localVarAxiosParamCreator.ping(); return sendRequest2( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: false } ); } /** * Test connectivity to the Rest API and get the current server time. * Weight: 1 * * @summary Check server time * @returns {Promise<RestApiResponse<TimeResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof GeneralApi * @see {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#check-server-time Binance API Documentation} */ async time() { const localVarAxiosArgs = await this.localVarAxiosParamCreator.time(); return sendRequest2( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: false } ); } }; var ExchangeInfoSymbolStatusEnum = /* @__PURE__ */ ((ExchangeInfoSymbolStatusEnum3) => { ExchangeInfoSymbolStatusEnum3["TRADING"] = "TRADING"; ExchangeInfoSymbolStatusEnum3["END_OF_DAY"] = "END_OF_DAY"; ExchangeInfoSymbolStatusEnum3["HALT"] = "HALT"; ExchangeInfoSymbolStatusEnum3["BREAK"] = "BREAK"; ExchangeInfoSymbolStatusEnum3["NON_REPRESENTABLE"] = "NON_REPRESENTABLE"; return ExchangeInfoSymbolStatusEnum3; })(ExchangeInfoSymbolStatusEnum || {}); // src/rest-api/modules/market-api.ts import { assertParamExists as assertParamExists2, sendRequest as sendRequest3 } from "@binance/common"; var MarketApiAxiosParamCreator = function(configuration) { return { /** * Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated. * Weight: 4 * * @summary Compressed/Aggregate trades list * @param {string} symbol * @param {number} [fromId] ID to get aggregate trades from INCLUSIVE. * @param {number} [startTime] Timestamp in ms to get aggregate trades from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get aggregate trades until INCLUSIVE. * @param {number} [limit] Default: 500; Maximum: 1000. * * @throws {RequiredError} */ aggTrades: async (symbol, fromId, startTime, endTime, limit) => { assertParamExists2("aggTrades", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (fromId !== void 0 && fromId !== null) { localVarQueryParameter["fromId"] = fromId; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/aggTrades", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Current average price for a symbol. * Weight: 2 * * @summary Current average price * @param {string} symbol * * @throws {RequiredError} */ avgPrice: async (symbol) => { assertParamExists2("avgPrice", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/avgPrice", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * * Weight: Adjusted based on the limit: * * |Limit|Request Weight * ------|------- * 1-100| 5 * 101-500| 25 * 501-1000| 50 * 1001-5000| 250 * * @summary Order book * @param {string} symbol * @param {number} [limit] Default: 500; Maximum: 1000. * * @throws {RequiredError} */ depth: async (symbol, limit) => { assertParamExists2("depth", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/api/v3/depth", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get recent trades. * Weight: 25 * * @summary Recent trades list * @param {string} symbol * @param {number} [limit] Default: 500; Maximum: 1000. * * @throws {RequiredError} */ getTrades: async (symbol, limit) => { asser