UNPKG

@binance/c2c

Version:

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

1 lines 16 kB
{"version":3,"sources":["../src/c2c.ts","../package.json","../src/rest-api/index.ts","../src/rest-api/modules/c2-capi.ts","../src/rest-api/rest-api.ts","../src/index.ts"],"sourcesContent":["import { buildUserAgent, ConfigurationRestAPI, C2C_REST_API_PROD_URL } from '@binance/common';\nimport { name, version } from '../package.json';\nimport { RestAPI } from './rest-api';\n\nexport interface ConfigurationC2C {\n configurationRestAPI?: ConfigurationRestAPI;\n}\n\nexport class C2C {\n public restAPI!: RestAPI;\n\n constructor(config: ConfigurationC2C) {\n const userAgent = buildUserAgent(name, version);\n\n if (config?.configurationRestAPI) {\n const configRestAPI = new ConfigurationRestAPI(\n config.configurationRestAPI\n ) as ConfigurationRestAPI & {\n baseOptions: Record<string, unknown>;\n };\n configRestAPI.basePath = configRestAPI.basePath || C2C_REST_API_PROD_URL;\n configRestAPI.baseOptions = configRestAPI.baseOptions || {};\n configRestAPI.baseOptions.headers = {\n ...(configRestAPI.baseOptions.headers || {}),\n 'User-Agent': userAgent,\n };\n this.restAPI = new RestAPI(configRestAPI);\n }\n }\n}\n","{\n \"name\": \"@binance/c2c\",\n \"description\": \"Official Binance C2C Connector - A lightweight library that provides a convenient interface to Binance's C2C REST API.\",\n \"version\": \"2.0.7\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"require\": \"./dist/index.js\",\n \"import\": \"./dist/index.mjs\"\n }\n },\n \"scripts\": {\n \"prepublishOnly\": \"npm run build\",\n \"build\": \"npm run clean && tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"npx jest --maxWorkers=4 --bail\",\n \"test:watch\": \"npx jest --watch\",\n \"format\": \"npx prettier --ignore-path .prettierignore --write .\",\n \"lint\": \"npx eslint '**/*.ts' --fix\"\n },\n \"keywords\": [\n \"Binance\",\n \"API\",\n \"C2C\",\n \"Connector\",\n \"REST\",\n \"Trading\"\n ],\n \"author\": \"Binance\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/binance/binance-connector-js.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/binance/binance-connector-js/issues\"\n },\n \"homepage\": \"https://github.com/binance/binance-connector-js#readme\",\n \"files\": [\n \"dist\"\n ],\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/node\": \"^20.17.24\",\n \"eslint\": \"8.57.0\",\n \"jest\": \"^29.6.4\",\n \"prettier\": \"^3.3.3\",\n \"ts-jest\": \"^29.1.1\",\n \"ts-node\": \"^10.9.1\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.7.2\",\n \"typescript-eslint\": \"^8.24.0\"\n },\n \"dependencies\": {\n \"@binance/common\": \"1.2.4\",\n \"axios\": \"^1.7.4\"\n }\n}\n","/**\n * Binance C2C REST API\n *\n * OpenAPI Specification for the Binance C2C REST API\n *\n * The version of the OpenAPI document: 1.0.0\n *\n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nexport * from './types';\nexport * from './modules';\nexport * from './rest-api';\n","/**\n * Binance C2C REST API\n *\n * OpenAPI Specification for the Binance C2C REST API\n *\n * The version of the OpenAPI document: 1.0.0\n *\n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nimport {\n ConfigurationRestAPI,\n TimeUnit,\n RestApiResponse,\n sendRequest,\n type RequestArgs,\n} from '@binance/common';\nimport type { GetC2CTradeHistoryResponse } from '../types';\n\n/**\n * C2CApi - axios parameter creator\n */\nconst C2CApiAxiosParamCreator = function (configuration: ConfigurationRestAPI) {\n return {\n /**\n * Get C2C Trade History\n *\n * The max interval between startTime and endTime is 30 days.\n * If startTime and endTime are not sent, the recent 7 days' data will be returned.\n * The earliest startTime is supported on June 10, 2020\n * Return up to 200 records per request.\n *\n * Weight: 1\n *\n * @summary Get C2C Trade History (USER_DATA)\n * @param {number} [startTime]\n * @param {number} [endTime]\n * @param {number} [page] Default 1\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n getC2CTradeHistory: async (\n startTime?: number,\n endTime?: number,\n page?: number,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (startTime !== undefined && startTime !== null) {\n localVarQueryParameter['startTime'] = startTime;\n }\n\n if (endTime !== undefined && endTime !== null) {\n localVarQueryParameter['endTime'] = endTime;\n }\n\n if (page !== undefined && page !== null) {\n localVarQueryParameter['page'] = page;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/c2c/orderMatch/listUserOrderHistory',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n };\n};\n\n/**\n * C2CApi - interface\n * @interface C2CApi\n */\nexport interface C2CApiInterface {\n /**\n * Get C2C Trade History\n *\n * The max interval between startTime and endTime is 30 days.\n * If startTime and endTime are not sent, the recent 7 days' data will be returned.\n * The earliest startTime is supported on June 10, 2020\n * Return up to 200 records per request.\n *\n * Weight: 1\n *\n * @summary Get C2C Trade History (USER_DATA)\n * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof C2CApiInterface\n */\n getC2CTradeHistory(\n requestParameters?: GetC2CTradeHistoryRequest\n ): Promise<RestApiResponse<GetC2CTradeHistoryResponse>>;\n}\n\n/**\n * Request parameters for getC2CTradeHistory operation in C2CApi.\n * @interface GetC2CTradeHistoryRequest\n */\nexport interface GetC2CTradeHistoryRequest {\n /**\n *\n * @type {number}\n * @memberof C2CApiGetC2CTradeHistory\n */\n readonly startTime?: number;\n\n /**\n *\n * @type {number}\n * @memberof C2CApiGetC2CTradeHistory\n */\n readonly endTime?: number;\n\n /**\n * Default 1\n * @type {number}\n * @memberof C2CApiGetC2CTradeHistory\n */\n readonly page?: number;\n\n /**\n *\n * @type {number}\n * @memberof C2CApiGetC2CTradeHistory\n */\n readonly recvWindow?: number;\n}\n\n/**\n * C2CApi - object-oriented interface\n * @class C2CApi\n */\nexport class C2CApi implements C2CApiInterface {\n private readonly configuration: ConfigurationRestAPI;\n private localVarAxiosParamCreator;\n\n constructor(configuration: ConfigurationRestAPI) {\n this.configuration = configuration;\n this.localVarAxiosParamCreator = C2CApiAxiosParamCreator(configuration);\n }\n\n /**\n * Get C2C Trade History\n *\n * The max interval between startTime and endTime is 30 days.\n * If startTime and endTime are not sent, the recent 7 days' data will be returned.\n * The earliest startTime is supported on June 10, 2020\n * Return up to 200 records per request.\n *\n * Weight: 1\n *\n * @summary Get C2C Trade History (USER_DATA)\n * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters.\n * @returns {Promise<RestApiResponse<GetC2CTradeHistoryResponse>>}\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof C2CApi\n * @see {@link https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History Binance API Documentation}\n */\n public async getC2CTradeHistory(\n requestParameters: GetC2CTradeHistoryRequest = {}\n ): Promise<RestApiResponse<GetC2CTradeHistoryResponse>> {\n const localVarAxiosArgs = await this.localVarAxiosParamCreator.getC2CTradeHistory(\n requestParameters?.startTime,\n requestParameters?.endTime,\n requestParameters?.page,\n requestParameters?.recvWindow\n );\n return sendRequest<GetC2CTradeHistoryResponse>(\n this.configuration,\n localVarAxiosArgs.endpoint,\n localVarAxiosArgs.method,\n localVarAxiosArgs.params,\n localVarAxiosArgs?.timeUnit,\n { isSigned: true }\n );\n }\n}\n","/**\n * Binance C2C REST API\n *\n * OpenAPI Specification for the Binance C2C REST API\n *\n * The version of the OpenAPI document: 1.0.0\n *\n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nimport { ConfigurationRestAPI, RestApiResponse, sendRequest } from '@binance/common';\nimport { C2CApi } from './modules/c2-capi';\n\nimport type { GetC2CTradeHistoryRequest } from './modules/c2-capi';\n\nimport type { GetC2CTradeHistoryResponse } from './types';\n\nexport class RestAPI {\n private configuration: ConfigurationRestAPI;\n private c2CApi: C2CApi;\n\n constructor(configuration: ConfigurationRestAPI) {\n this.configuration = configuration;\n this.c2CApi = new C2CApi(configuration);\n }\n\n /**\n * Generic function to send a request.\n * @param endpoint - The API endpoint to call.\n * @param method - HTTP method to use (GET, POST, DELETE, etc.).\n * @param params - Query parameters for the request.\n *\n * @returns A promise resolving to the response data object.\n */\n sendRequest<T>(\n endpoint: string,\n method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH',\n params: Record<string, unknown> = {}\n ): Promise<RestApiResponse<T>> {\n return sendRequest<T>(this.configuration, endpoint, method, params, undefined);\n }\n\n /**\n * Generic function to send a signed request.\n * @param endpoint - The API endpoint to call.\n * @param method - HTTP method to use (GET, POST, DELETE, etc.).\n * @param params - Query parameters for the request.\n *\n * @returns A promise resolving to the response data object.\n */\n sendSignedRequest<T>(\n endpoint: string,\n method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH',\n params: Record<string, unknown> = {}\n ): Promise<RestApiResponse<T>> {\n return sendRequest<T>(this.configuration, endpoint, method, params, undefined, {\n isSigned: true,\n });\n }\n\n /**\n * Get C2C Trade History\n *\n * The max interval between startTime and endTime is 30 days.\n * If startTime and endTime are not sent, the recent 7 days' data will be returned.\n * The earliest startTime is supported on June 10, 2020\n * Return up to 200 records per request.\n *\n * Weight: 1\n *\n * @summary Get C2C Trade History (USER_DATA)\n * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters.\n * @returns {Promise<RestApiResponse<GetC2CTradeHistoryResponse>>}\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @see {@link https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History Binance API Documentation}\n */\n getC2CTradeHistory(\n requestParameters: GetC2CTradeHistoryRequest = {}\n ): Promise<RestApiResponse<GetC2CTradeHistoryResponse>> {\n return this.c2CApi.getC2CTradeHistory(requestParameters);\n }\n}\n","export { C2C, ConfigurationC2C } from './c2c';\nexport * as C2CRestAPI from './rest-api';\n\nexport {\n C2C_REST_API_PROD_URL,\n ConnectorClientError,\n RequiredError,\n UnauthorizedError,\n ForbiddenError,\n TooManyRequestsError,\n RateLimitBanError,\n ServerError,\n NetworkError,\n NotFoundError,\n BadRequestError,\n} from '@binance/common';\n"],"mappings":";;;;;;;AAAA,SAAS,gBAAgB,wBAAAA,uBAAsB,6BAA6B;;;ACCxE,WAAQ;AAER,cAAW;;;ACHf;AAAA;AAAA;AAAA;AAAA;;;ACaA;AAAA,EAII;AAAA,OAEG;AAMP,IAAM,0BAA0B,SAAU,eAAqC;AAC3E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmBH,oBAAoB,OAChB,WACA,SACA,MACA,eACuB;AACvB,YAAM,yBAAkD,CAAC;AAEzD,UAAI,cAAc,UAAa,cAAc,MAAM;AAC/C,+BAAuB,WAAW,IAAI;AAAA,MAC1C;AAEA,UAAI,YAAY,UAAa,YAAY,MAAM;AAC3C,+BAAuB,SAAS,IAAI;AAAA,MACxC;AA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