UNPKG

@binance/c2c

Version:

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

168 lines (162 loc) 7.06 kB
import { t as __export } from "./chunk.mjs"; import { BadRequestError, C2C_REST_API_PROD_URL, C2C_REST_API_PROD_URL as C2C_REST_API_PROD_URL$1, ConfigurationRestAPI, ConnectorClientError, ForbiddenError, NetworkError, NotFoundError, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError, buildUserAgent, sendRequest } from "@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 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 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 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 = buildUserAgent(name, version); if (config?.configurationRestAPI) { const configRestAPI = new ConfigurationRestAPI(config.configurationRestAPI); configRestAPI.basePath = configRestAPI.basePath || C2C_REST_API_PROD_URL$1; configRestAPI.baseOptions = configRestAPI.baseOptions || {}; configRestAPI.baseOptions.headers = { ...configRestAPI.baseOptions.headers || {}, "User-Agent": userAgent }; this.restAPI = new RestAPI(configRestAPI); } } }; //#endregion export { BadRequestError, C2C, rest_api_exports as C2CRestAPI, C2C_REST_API_PROD_URL, ConnectorClientError, ForbiddenError, NetworkError, NotFoundError, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError }; //# sourceMappingURL=index.mjs.map