UNPKG

@binance/c2c

Version:

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

251 lines (244 loc) 8.62 kB
//#region rolldown:runtime var __defProp = Object.defineProperty; var __export = (all) => { let target = {}; for (var name$1 in all) __defProp(target, name$1, { get: all[name$1], enumerable: true }); return target; }; //#endregion let __binance_common = require("@binance/common"); //#region package.json var name = "@binance/c2c"; var version = "4.1.6"; //#endregion //#region src/rest-api/modules/c2-capi.ts /** * Binance C2C REST API * * OpenAPI Specification for the Binance C2C REST API * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ /** * C2CApi - axios parameter creator */ const C2CApiAxiosParamCreator = function(configuration) { return { getC2CTradeHistory: async (tradeType, startTimestamp, endTimestamp, page, rows, recvWindow) => { const localVarQueryParameter = {}; const localVarBodyParameter = {}; if (tradeType !== void 0 && tradeType !== null) localVarQueryParameter["tradeType"] = tradeType; if (startTimestamp !== void 0 && startTimestamp !== null) localVarQueryParameter["startTimestamp"] = startTimestamp; if (endTimestamp !== void 0 && endTimestamp !== null) localVarQueryParameter["endTimestamp"] = endTimestamp; if (page !== void 0 && page !== null) localVarQueryParameter["page"] = page; if (rows !== void 0 && rows !== null) localVarQueryParameter["rows"] = rows; 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", queryParams: localVarQueryParameter, bodyParams: localVarBodyParameter, timeUnit: _timeUnit }; } }; }; /** * C2CApi - object-oriented interface * @class C2CApi */ var C2CApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = C2CApiAxiosParamCreator(configuration); } /** * Get C2C Trade History * * The max interval between startTimestamp and endTimestamp is 30 days. * If startTimestamp and endTimestamp are not sent, the recent 30 days' data will be returned. * You can only view data from the past 6 months. To see all C2C orders, please check https://c2c.binance.com/en/fiatOrder * * 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?.tradeType, requestParameters?.startTimestamp, requestParameters?.endTimestamp, requestParameters?.page, requestParameters?.rows, requestParameters?.recvWindow); return (0, __binance_common.sendRequest)(this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.queryParams, localVarAxiosArgs.bodyParams, localVarAxiosArgs?.timeUnit, { isSigned: true }); } }; //#endregion //#region src/rest-api/rest-api.ts /** * Binance C2C REST API * * OpenAPI Specification for the Binance C2C REST API * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ 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 queryParams - Query parameters for the request. * @param bodyParams - Body parameters for the request. * * @returns A promise resolving to the response data object. */ sendRequest(endpoint, method, queryParams = {}, bodyParams = {}) { return (0, __binance_common.sendRequest)(this.configuration, endpoint, method, queryParams, bodyParams, 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 queryParams - Query parameters for the request. * @param bodyParams - Body parameters for the request. * * @returns A promise resolving to the response data object. */ sendSignedRequest(endpoint, method, queryParams = {}, bodyParams = {}) { return (0, __binance_common.sendRequest)(this.configuration, endpoint, method, queryParams, bodyParams, void 0, { isSigned: true }); } /** * Get C2C Trade History * * The max interval between startTimestamp and endTimestamp is 30 days. * If startTimestamp and endTimestamp are not sent, the recent 30 days' data will be returned. * You can only view data from the past 6 months. To see all C2C orders, please check https://c2c.binance.com/en/fiatOrder * * 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); } }; //#endregion //#region src/rest-api/index.ts var rest_api_exports = /* @__PURE__ */ __export({ C2CApi: () => C2CApi, RestAPI: () => RestAPI }); //#endregion //#region src/c2c.ts var C2C = class { constructor(config) { const userAgent = (0, __binance_common.buildUserAgent)(name, version); if (config?.configurationRestAPI) { const configRestAPI = new __binance_common.ConfigurationRestAPI(config.configurationRestAPI); configRestAPI.basePath = configRestAPI.basePath || __binance_common.C2C_REST_API_PROD_URL; configRestAPI.baseOptions = configRestAPI.baseOptions || {}; configRestAPI.baseOptions.headers = { ...configRestAPI.baseOptions.headers || {}, "User-Agent": userAgent }; this.restAPI = new RestAPI(configRestAPI); } } }; //#endregion Object.defineProperty(exports, 'BadRequestError', { enumerable: true, get: function () { return __binance_common.BadRequestError; } }); exports.C2C = C2C; Object.defineProperty(exports, 'C2CRestAPI', { enumerable: true, get: function () { return rest_api_exports; } }); Object.defineProperty(exports, 'C2C_REST_API_PROD_URL', { enumerable: true, get: function () { return __binance_common.C2C_REST_API_PROD_URL; } }); Object.defineProperty(exports, 'ConnectorClientError', { enumerable: true, get: function () { return __binance_common.ConnectorClientError; } }); Object.defineProperty(exports, 'ForbiddenError', { enumerable: true, get: function () { return __binance_common.ForbiddenError; } }); Object.defineProperty(exports, 'NetworkError', { enumerable: true, get: function () { return __binance_common.NetworkError; } }); Object.defineProperty(exports, 'NotFoundError', { enumerable: true, get: function () { return __binance_common.NotFoundError; } }); Object.defineProperty(exports, 'RateLimitBanError', { enumerable: true, get: function () { return __binance_common.RateLimitBanError; } }); Object.defineProperty(exports, 'RequiredError', { enumerable: true, get: function () { return __binance_common.RequiredError; } }); Object.defineProperty(exports, 'ServerError', { enumerable: true, get: function () { return __binance_common.ServerError; } }); Object.defineProperty(exports, 'TooManyRequestsError', { enumerable: true, get: function () { return __binance_common.TooManyRequestsError; } }); Object.defineProperty(exports, 'UnauthorizedError', { enumerable: true, get: function () { return __binance_common.UnauthorizedError; } }); //# sourceMappingURL=index.js.map