UNPKG

@binance/c2c

Version:

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

229 lines (221 loc) 8.18 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_common4.BadRequestError, C2C: () => C2C, C2CRestAPI: () => rest_api_exports, C2C_REST_API_PROD_URL: () => import_common4.C2C_REST_API_PROD_URL, ConnectorClientError: () => import_common4.ConnectorClientError, ForbiddenError: () => import_common4.ForbiddenError, NetworkError: () => import_common4.NetworkError, NotFoundError: () => import_common4.NotFoundError, RateLimitBanError: () => import_common4.RateLimitBanError, RequiredError: () => import_common4.RequiredError, ServerError: () => import_common4.ServerError, TooManyRequestsError: () => import_common4.TooManyRequestsError, UnauthorizedError: () => import_common4.UnauthorizedError }); module.exports = __toCommonJS(index_exports); // src/c2c.ts var import_common3 = require("@binance/common"); // package.json var name = "@binance/c2c"; var version = "2.0.7"; // src/rest-api/index.ts var rest_api_exports = {}; __export(rest_api_exports, { C2CApi: () => C2CApi, RestAPI: () => RestAPI }); // src/rest-api/modules/c2-capi.ts var import_common = require("@binance/common"); var C2CApiAxiosParamCreator = function(configuration) { return { /** * Get C2C Trade History * * The max interval between startTime and endTime is 30 days. * If startTime and endTime are not sent, the recent 7 days' data will be returned. * The earliest startTime is supported on June 10, 2020 * Return up to 200 records per request. * * Weight: 1 * * @summary Get C2C Trade History (USER_DATA) * @param {number} [startTime] * @param {number} [endTime] * @param {number} [page] Default 1 * @param {number} [recvWindow] * * @throws {RequiredError} */ getC2CTradeHistory: async (startTime, endTime, page, recvWindow) => { const localVarQueryParameter = {}; if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (page !== void 0 && page !== null) { localVarQueryParameter["page"] = page; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/c2c/orderMatch/listUserOrderHistory", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; var C2CApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = C2CApiAxiosParamCreator(configuration); } /** * Get C2C Trade History * * The max interval between startTime and endTime is 30 days. * If startTime and endTime are not sent, the recent 7 days' data will be returned. * The earliest startTime is supported on June 10, 2020 * Return up to 200 records per request. * * Weight: 1 * * @summary Get C2C Trade History (USER_DATA) * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetC2CTradeHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof C2CApi * @see {@link https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History Binance API Documentation} */ async getC2CTradeHistory(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getC2CTradeHistory( requestParameters?.startTime, requestParameters?.endTime, requestParameters?.page, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } }; // src/rest-api/rest-api.ts var import_common2 = require("@binance/common"); var RestAPI = class { constructor(configuration) { this.configuration = configuration; this.c2CApi = new C2CApi(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_common2.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_common2.sendRequest)(this.configuration, endpoint, method, params, void 0, { isSigned: true }); } /** * Get C2C Trade History * * The max interval between startTime and endTime is 30 days. * If startTime and endTime are not sent, the recent 7 days' data will be returned. * The earliest startTime is supported on June 10, 2020 * Return up to 200 records per request. * * Weight: 1 * * @summary Get C2C Trade History (USER_DATA) * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetC2CTradeHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History Binance API Documentation} */ getC2CTradeHistory(requestParameters = {}) { return this.c2CApi.getC2CTradeHistory(requestParameters); } }; // src/c2c.ts var C2C = class { constructor(config) { const userAgent = (0, import_common3.buildUserAgent)(name, version); if (config?.configurationRestAPI) { const configRestAPI = new import_common3.ConfigurationRestAPI( config.configurationRestAPI ); configRestAPI.basePath = configRestAPI.basePath || import_common3.C2C_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_common4 = require("@binance/common"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { BadRequestError, C2C, C2CRestAPI, C2C_REST_API_PROD_URL, ConnectorClientError, ForbiddenError, NetworkError, NotFoundError, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError }); //# sourceMappingURL=index.js.map