UNPKG

@binance/convert

Version:

Official Binance Convert Connector - A lightweight library that provides a convenient interface to Binance's Convert REST API.

870 lines (861 loc) 35.3 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name2 in all) __defProp(target, name2, { get: all[name2], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { BadRequestError: () => import_common5.BadRequestError, CONVERT_REST_API_PROD_URL: () => import_common5.CONVERT_REST_API_PROD_URL, ConnectorClientError: () => import_common5.ConnectorClientError, Convert: () => Convert, ConvertRestAPI: () => rest_api_exports, ForbiddenError: () => import_common5.ForbiddenError, NetworkError: () => import_common5.NetworkError, NotFoundError: () => import_common5.NotFoundError, RateLimitBanError: () => import_common5.RateLimitBanError, RequiredError: () => import_common5.RequiredError, ServerError: () => import_common5.ServerError, TooManyRequestsError: () => import_common5.TooManyRequestsError, UnauthorizedError: () => import_common5.UnauthorizedError }); module.exports = __toCommonJS(index_exports); // src/convert.ts var import_common4 = require("@binance/common"); // package.json var name = "@binance/convert"; var version = "2.0.7"; // src/rest-api/index.ts var rest_api_exports = {}; __export(rest_api_exports, { MarketDataApi: () => MarketDataApi, RestAPI: () => RestAPI, TradeApi: () => TradeApi }); // src/rest-api/modules/market-data-api.ts var import_common = require("@binance/common"); var MarketDataApiAxiosParamCreator = function(configuration) { return { /** * Query for all convertible token pairs and the tokens’ respective upper/lower limits * * User needs to supply either or both of the input parameter * If not defined for both fromAsset and toAsset, only partial token pairs will be returned * * Weight: 3000(IP) * * @summary List All Convert Pairs * @param {string} [fromAsset] User spends coin * @param {string} [toAsset] User receives coin * * @throws {RequiredError} */ listAllConvertPairs: async (fromAsset, toAsset) => { const localVarQueryParameter = {}; if (fromAsset !== void 0 && fromAsset !== null) { localVarQueryParameter["fromAsset"] = fromAsset; } if (toAsset !== void 0 && toAsset !== null) { localVarQueryParameter["toAsset"] = toAsset; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/convert/exchangeInfo", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query for supported asset’s precision information * * Weight: 100(IP) * * @summary Query order quantity precision per asset(USER_DATA) * @param {number} [recvWindow] The value cannot be greater than 60000 * * @throws {RequiredError} */ queryOrderQuantityPrecisionPerAsset: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/convert/assetInfo", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; var MarketDataApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = MarketDataApiAxiosParamCreator(configuration); } /** * Query for all convertible token pairs and the tokens’ respective upper/lower limits * * User needs to supply either or both of the input parameter * If not defined for both fromAsset and toAsset, only partial token pairs will be returned * * Weight: 3000(IP) * * @summary List All Convert Pairs * @param {ListAllConvertPairsRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<ListAllConvertPairsResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof MarketDataApi * @see {@link https://developers.binance.com/docs/convert/market-data/ Binance API Documentation} */ async listAllConvertPairs(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.listAllConvertPairs( requestParameters?.fromAsset, requestParameters?.toAsset ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: false } ); } /** * Query for supported asset’s precision information * * Weight: 100(IP) * * @summary Query order quantity precision per asset(USER_DATA) * @param {QueryOrderQuantityPrecisionPerAssetRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<QueryOrderQuantityPrecisionPerAssetResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof MarketDataApi * @see {@link https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset Binance API Documentation} */ async queryOrderQuantityPrecisionPerAsset(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.queryOrderQuantityPrecisionPerAsset( requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } }; // src/rest-api/modules/trade-api.ts var import_common2 = require("@binance/common"); var TradeApiAxiosParamCreator = function(configuration) { return { /** * Accept the offered quote by quote ID. * * Weight: 500(UID) * * @summary Accept Quote (TRADE) * @param {string} quoteId * @param {number} [recvWindow] The value cannot be greater than 60000 * * @throws {RequiredError} */ acceptQuote: async (quoteId, recvWindow) => { (0, import_common2.assertParamExists)("acceptQuote", "quoteId", quoteId); const localVarQueryParameter = {}; if (quoteId !== void 0 && quoteId !== null) { localVarQueryParameter["quoteId"] = quoteId; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/convert/acceptQuote", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Enable users to cancel a limit order * * Weight: 200(UID) * * @summary Cancel limit order (USER_DATA) * @param {number} orderId The orderId from `placeOrder` api * @param {number} [recvWindow] The value cannot be greater than 60000 * * @throws {RequiredError} */ cancelLimitOrder: async (orderId, recvWindow) => { (0, import_common2.assertParamExists)("cancelLimitOrder", "orderId", orderId); const localVarQueryParameter = {}; 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: "/sapi/v1/convert/limit/cancelOrder", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get Convert Trade History * * The max interval between startTime and endTime is 30 days. * * Weight: 3000 * * @summary Get Convert Trade History(USER_DATA) * @param {number} startTime * @param {number} endTime * @param {number} [limit] Default 100, Max 1000 * @param {number} [recvWindow] The value cannot be greater than 60000 * * @throws {RequiredError} */ getConvertTradeHistory: async (startTime, endTime, limit, recvWindow) => { (0, import_common2.assertParamExists)("getConvertTradeHistory", "startTime", startTime); (0, import_common2.assertParamExists)("getConvertTradeHistory", "endTime", endTime); const localVarQueryParameter = {}; 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: "/sapi/v1/convert/tradeFlow", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query order status by order ID. * * Weight: 100(UID) * * @summary Order status(USER_DATA) * @param {string} [orderId] Either orderId or quoteId is required * @param {string} [quoteId] Either orderId or quoteId is required * * @throws {RequiredError} */ orderStatus: async (orderId, quoteId) => { const localVarQueryParameter = {}; if (orderId !== void 0 && orderId !== null) { localVarQueryParameter["orderId"] = orderId; } if (quoteId !== void 0 && quoteId !== null) { localVarQueryParameter["quoteId"] = quoteId; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/convert/orderStatus", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Enable users to place a limit order * * `baseAsset` or `quoteAsset` can be determined via `exchangeInfo` endpoint. * Limit price is defined from `baseAsset` to `quoteAsset`. * Either `baseAmount` or `quoteAmount` is used. * * Weight: 500(UID) * * @summary Place limit order (USER_DATA) * @param {string} baseAsset base asset (use the response `fromIsBase` from `GET /sapi/v1/convert/exchangeInfo` api to check which one is baseAsset ) * @param {string} quoteAsset quote asset * @param {number} limitPrice Symbol limit price (from baseAsset to quoteAsset) * @param {string} side `BUY` or `SELL` * @param {string} expiredType 1_D, 3_D, 7_D, 30_D (D means day) * @param {number} [baseAmount] Base asset amount. (One of `baseAmount` or `quoteAmount` is required) * @param {number} [quoteAmount] Quote asset amount. (One of `baseAmount` or `quoteAmount` is required) * @param {string} [walletType] It is to choose which wallet of assets. The wallet selection is `SPOT`, `FUNDING` and `EARN`. Combination of wallet is supported i.e. `SPOT_FUNDING`, `FUNDING_EARN`, `SPOT_FUNDING_EARN` or `SPOT_EARN` Default is `SPOT`. * @param {number} [recvWindow] The value cannot be greater than 60000 * * @throws {RequiredError} */ placeLimitOrder: async (baseAsset, quoteAsset, limitPrice, side, expiredType, baseAmount, quoteAmount, walletType, recvWindow) => { (0, import_common2.assertParamExists)("placeLimitOrder", "baseAsset", baseAsset); (0, import_common2.assertParamExists)("placeLimitOrder", "quoteAsset", quoteAsset); (0, import_common2.assertParamExists)("placeLimitOrder", "limitPrice", limitPrice); (0, import_common2.assertParamExists)("placeLimitOrder", "side", side); (0, import_common2.assertParamExists)("placeLimitOrder", "expiredType", expiredType); const localVarQueryParameter = {}; if (baseAsset !== void 0 && baseAsset !== null) { localVarQueryParameter["baseAsset"] = baseAsset; } if (quoteAsset !== void 0 && quoteAsset !== null) { localVarQueryParameter["quoteAsset"] = quoteAsset; } if (limitPrice !== void 0 && limitPrice !== null) { localVarQueryParameter["limitPrice"] = limitPrice; } if (baseAmount !== void 0 && baseAmount !== null) { localVarQueryParameter["baseAmount"] = baseAmount; } if (quoteAmount !== void 0 && quoteAmount !== null) { localVarQueryParameter["quoteAmount"] = quoteAmount; } if (side !== void 0 && side !== null) { localVarQueryParameter["side"] = side; } if (walletType !== void 0 && walletType !== null) { localVarQueryParameter["walletType"] = walletType; } if (expiredType !== void 0 && expiredType !== null) { localVarQueryParameter["expiredType"] = expiredType; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/convert/limit/placeOrder", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Request a quote for the requested token pairs * * Weight: 3000(UID) * * @summary Query limit open orders (USER_DATA) * @param {number} [recvWindow] The value cannot be greater than 60000 * * @throws {RequiredError} */ queryLimitOpenOrders: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/convert/limit/queryOpenOrders", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Request a quote for the requested token pairs * * Either fromAmount or toAmount should be sent * `quoteId` will be returned only if you have enough funds to convert * * Weight: 200(UID) * * @summary Send Quote Request(USER_DATA) * @param {string} fromAsset * @param {string} toAsset * @param {number} [fromAmount] When specified, it is the amount you will be debited after the conversion * @param {number} [toAmount] When specified, it is the amount you will be credited after the conversion * @param {string} [walletType] It is to choose which wallet of assets. The wallet selection is `SPOT`, `FUNDING` and `EARN`. Combination of wallet is supported i.e. `SPOT_FUNDING`, `FUNDING_EARN`, `SPOT_FUNDING_EARN` or `SPOT_EARN` Default is `SPOT`. * @param {string} [validTime] 10s, 30s, 1m, default 10s * @param {number} [recvWindow] The value cannot be greater than 60000 * * @throws {RequiredError} */ sendQuoteRequest: async (fromAsset, toAsset, fromAmount, toAmount, walletType, validTime, recvWindow) => { (0, import_common2.assertParamExists)("sendQuoteRequest", "fromAsset", fromAsset); (0, import_common2.assertParamExists)("sendQuoteRequest", "toAsset", toAsset); const localVarQueryParameter = {}; if (fromAsset !== void 0 && fromAsset !== null) { localVarQueryParameter["fromAsset"] = fromAsset; } if (toAsset !== void 0 && toAsset !== null) { localVarQueryParameter["toAsset"] = toAsset; } if (fromAmount !== void 0 && fromAmount !== null) { localVarQueryParameter["fromAmount"] = fromAmount; } if (toAmount !== void 0 && toAmount !== null) { localVarQueryParameter["toAmount"] = toAmount; } if (walletType !== void 0 && walletType !== null) { localVarQueryParameter["walletType"] = walletType; } if (validTime !== void 0 && validTime !== null) { localVarQueryParameter["validTime"] = validTime; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/convert/getQuote", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; var TradeApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = TradeApiAxiosParamCreator(configuration); } /** * Accept the offered quote by quote ID. * * Weight: 500(UID) * * @summary Accept Quote (TRADE) * @param {AcceptQuoteRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<AcceptQuoteResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof TradeApi * @see {@link https://developers.binance.com/docs/convert/trade/Accept-Quote Binance API Documentation} */ async acceptQuote(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.acceptQuote( requestParameters?.quoteId, requestParameters?.recvWindow ); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Enable users to cancel a limit order * * Weight: 200(UID) * * @summary Cancel limit order (USER_DATA) * @param {CancelLimitOrderRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<CancelLimitOrderResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof TradeApi * @see {@link https://developers.binance.com/docs/convert/trade/Cancel-Order Binance API Documentation} */ async cancelLimitOrder(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.cancelLimitOrder( requestParameters?.orderId, requestParameters?.recvWindow ); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get Convert Trade History * * The max interval between startTime and endTime is 30 days. * * Weight: 3000 * * @summary Get Convert Trade History(USER_DATA) * @param {GetConvertTradeHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetConvertTradeHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof TradeApi * @see {@link https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History Binance API Documentation} */ async getConvertTradeHistory(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getConvertTradeHistory( requestParameters?.startTime, requestParameters?.endTime, requestParameters?.limit, requestParameters?.recvWindow ); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Query order status by order ID. * * Weight: 100(UID) * * @summary Order status(USER_DATA) * @param {OrderStatusRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<OrderStatusResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof TradeApi * @see {@link https://developers.binance.com/docs/convert/trade/Order-Status Binance API Documentation} */ async orderStatus(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.orderStatus( requestParameters?.orderId, requestParameters?.quoteId ); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Enable users to place a limit order * * `baseAsset` or `quoteAsset` can be determined via `exchangeInfo` endpoint. * Limit price is defined from `baseAsset` to `quoteAsset`. * Either `baseAmount` or `quoteAmount` is used. * * Weight: 500(UID) * * @summary Place limit order (USER_DATA) * @param {PlaceLimitOrderRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<PlaceLimitOrderResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof TradeApi * @see {@link https://developers.binance.com/docs/convert/trade/Place-Order Binance API Documentation} */ async placeLimitOrder(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.placeLimitOrder( requestParameters?.baseAsset, requestParameters?.quoteAsset, requestParameters?.limitPrice, requestParameters?.side, requestParameters?.expiredType, requestParameters?.baseAmount, requestParameters?.quoteAmount, requestParameters?.walletType, requestParameters?.recvWindow ); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Request a quote for the requested token pairs * * Weight: 3000(UID) * * @summary Query limit open orders (USER_DATA) * @param {QueryLimitOpenOrdersRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<QueryLimitOpenOrdersResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof TradeApi * @see {@link https://developers.binance.com/docs/convert/trade/Query-Order Binance API Documentation} */ async queryLimitOpenOrders(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.queryLimitOpenOrders( requestParameters?.recvWindow ); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Request a quote for the requested token pairs * * Either fromAmount or toAmount should be sent * `quoteId` will be returned only if you have enough funds to convert * * Weight: 200(UID) * * @summary Send Quote Request(USER_DATA) * @param {SendQuoteRequestRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<SendQuoteRequestResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof TradeApi * @see {@link https://developers.binance.com/docs/convert/trade/Send-quote-request Binance API Documentation} */ async sendQuoteRequest(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.sendQuoteRequest( requestParameters?.fromAsset, requestParameters?.toAsset, requestParameters?.fromAmount, requestParameters?.toAmount, requestParameters?.walletType, requestParameters?.validTime, requestParameters?.recvWindow ); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } }; // src/rest-api/rest-api.ts var import_common3 = require("@binance/common"); var RestAPI = class { constructor(configuration) { this.configuration = configuration; this.marketDataApi = new MarketDataApi(configuration); this.tradeApi = new TradeApi(configuration); } /** * Generic function to send a request. * @param endpoint - The API endpoint to call. * @param method - HTTP method to use (GET, POST, DELETE, etc.). * @param params - Query parameters for the request. * * @returns A promise resolving to the response data object. */ sendRequest(endpoint, method, params = {}) { return (0, import_common3.sendRequest)(this.configuration, endpoint, method, params, void 0); } /** * Generic function to send a signed request. * @param endpoint - The API endpoint to call. * @param method - HTTP method to use (GET, POST, DELETE, etc.). * @param params - Query parameters for the request. * * @returns A promise resolving to the response data object. */ sendSignedRequest(endpoint, method, params = {}) { return (0, import_common3.sendRequest)(this.configuration, endpoint, method, params, void 0, { isSigned: true }); } /** * Query for all convertible token pairs and the tokens’ respective upper/lower limits * * User needs to supply either or both of the input parameter * If not defined for both fromAsset and toAsset, only partial token pairs will be returned * * Weight: 3000(IP) * * @summary List All Convert Pairs * @param {ListAllConvertPairsRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<ListAllConvertPairsResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/market-data/ Binance API Documentation} */ listAllConvertPairs(requestParameters = {}) { return this.marketDataApi.listAllConvertPairs(requestParameters); } /** * Query for supported asset’s precision information * * Weight: 100(IP) * * @summary Query order quantity precision per asset(USER_DATA) * @param {QueryOrderQuantityPrecisionPerAssetRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<QueryOrderQuantityPrecisionPerAssetResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset Binance API Documentation} */ queryOrderQuantityPrecisionPerAsset(requestParameters = {}) { return this.marketDataApi.queryOrderQuantityPrecisionPerAsset(requestParameters); } /** * Accept the offered quote by quote ID. * * Weight: 500(UID) * * @summary Accept Quote (TRADE) * @param {AcceptQuoteRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<AcceptQuoteResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/trade/Accept-Quote Binance API Documentation} */ acceptQuote(requestParameters) { return this.tradeApi.acceptQuote(requestParameters); } /** * Enable users to cancel a limit order * * Weight: 200(UID) * * @summary Cancel limit order (USER_DATA) * @param {CancelLimitOrderRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<CancelLimitOrderResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/trade/Cancel-Order Binance API Documentation} */ cancelLimitOrder(requestParameters) { return this.tradeApi.cancelLimitOrder(requestParameters); } /** * Get Convert Trade History * * The max interval between startTime and endTime is 30 days. * * Weight: 3000 * * @summary Get Convert Trade History(USER_DATA) * @param {GetConvertTradeHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetConvertTradeHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History Binance API Documentation} */ getConvertTradeHistory(requestParameters) { return this.tradeApi.getConvertTradeHistory(requestParameters); } /** * Query order status by order ID. * * Weight: 100(UID) * * @summary Order status(USER_DATA) * @param {OrderStatusRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<OrderStatusResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/trade/Order-Status Binance API Documentation} */ orderStatus(requestParameters = {}) { return this.tradeApi.orderStatus(requestParameters); } /** * Enable users to place a limit order * * `baseAsset` or `quoteAsset` can be determined via `exchangeInfo` endpoint. * Limit price is defined from `baseAsset` to `quoteAsset`. * Either `baseAmount` or `quoteAmount` is used. * * Weight: 500(UID) * * @summary Place limit order (USER_DATA) * @param {PlaceLimitOrderRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<PlaceLimitOrderResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/trade/Place-Order Binance API Documentation} */ placeLimitOrder(requestParameters) { return this.tradeApi.placeLimitOrder(requestParameters); } /** * Request a quote for the requested token pairs * * Weight: 3000(UID) * * @summary Query limit open orders (USER_DATA) * @param {QueryLimitOpenOrdersRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<QueryLimitOpenOrdersResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/trade/Query-Order Binance API Documentation} */ queryLimitOpenOrders(requestParameters = {}) { return this.tradeApi.queryLimitOpenOrders(requestParameters); } /** * Request a quote for the requested token pairs * * Either fromAmount or toAmount should be sent * `quoteId` will be returned only if you have enough funds to convert * * Weight: 200(UID) * * @summary Send Quote Request(USER_DATA) * @param {SendQuoteRequestRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<SendQuoteRequestResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/convert/trade/Send-quote-request Binance API Documentation} */ sendQuoteRequest(requestParameters) { return this.tradeApi.sendQuoteRequest(requestParameters); } }; // src/convert.ts var Convert = class { constructor(config) { const userAgent = (0, import_common4.buildUserAgent)(name, version); if (config?.configurationRestAPI) { const configRestAPI = new import_common4.ConfigurationRestAPI( config.configurationRestAPI ); configRestAPI.basePath = configRestAPI.basePath || import_common4.CONVERT_REST_API_PROD_URL; configRestAPI.baseOptions = configRestAPI.baseOptions || {}; configRestAPI.baseOptions.headers = { ...configRestAPI.baseOptions.headers || {}, "User-Agent": userAgent }; this.restAPI = new RestAPI(configRestAPI); } } }; // src/index.ts var import_common5 = require("@binance/common"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { BadRequestError, CONVERT_REST_API_PROD_URL, ConnectorClientError, Convert, ConvertRestAPI, ForbiddenError, NetworkError, NotFoundError, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError }); //# sourceMappingURL=index.js.map