@binance/c2c 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,381 @@
1
+ import { RestApiResponse, ConfigurationRestAPI } from '@binance/common';
2
+ export { BadRequestError, C2C_REST_API_PROD_URL, C2C_REST_API_TESTNET_URL, ConnectorClientError, ForbiddenError, NetworkError, NotFoundError, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError } from '@binance/common';
3
+
4
+ /**
5
+ * Binance Public C2C REST API
6
+ *
7
+ * OpenAPI Specification for the Binance Public C2C REST API
8
+ *
9
+ * The version of the OpenAPI document: 1.0.0
10
+ *
11
+ *
12
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
13
+ * https://openapi-generator.tech
14
+ * Do not edit the class manually.
15
+ */
16
+ /**
17
+ *
18
+ * @export
19
+ * @interface BadRequest
20
+ */
21
+ interface BadRequest {
22
+ /**
23
+ *
24
+ * @type {number}
25
+ * @memberof BadRequest
26
+ */
27
+ code: number;
28
+ /**
29
+ *
30
+ * @type {string}
31
+ * @memberof BadRequest
32
+ */
33
+ message: string;
34
+ }
35
+
36
+ /**
37
+ * Binance Public C2C REST API
38
+ *
39
+ * OpenAPI Specification for the Binance Public C2C REST API
40
+ *
41
+ * The version of the OpenAPI document: 1.0.0
42
+ *
43
+ *
44
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
45
+ * https://openapi-generator.tech
46
+ * Do not edit the class manually.
47
+ */
48
+ /**
49
+ *
50
+ * @export
51
+ * @interface GetC2CTradeHistoryResponseDataInner
52
+ */
53
+ interface GetC2CTradeHistoryResponseDataInner {
54
+ /**
55
+ *
56
+ * @type {string}
57
+ * @memberof GetC2CTradeHistoryResponseDataInner
58
+ */
59
+ orderNumber?: string;
60
+ /**
61
+ *
62
+ * @type {string}
63
+ * @memberof GetC2CTradeHistoryResponseDataInner
64
+ */
65
+ advNo?: string;
66
+ /**
67
+ *
68
+ * @type {string}
69
+ * @memberof GetC2CTradeHistoryResponseDataInner
70
+ */
71
+ tradeType?: string;
72
+ /**
73
+ *
74
+ * @type {string}
75
+ * @memberof GetC2CTradeHistoryResponseDataInner
76
+ */
77
+ asset?: string;
78
+ /**
79
+ *
80
+ * @type {string}
81
+ * @memberof GetC2CTradeHistoryResponseDataInner
82
+ */
83
+ fiat?: string;
84
+ /**
85
+ *
86
+ * @type {string}
87
+ * @memberof GetC2CTradeHistoryResponseDataInner
88
+ */
89
+ fiatSymbol?: string;
90
+ /**
91
+ *
92
+ * @type {string}
93
+ * @memberof GetC2CTradeHistoryResponseDataInner
94
+ */
95
+ amount?: string;
96
+ /**
97
+ *
98
+ * @type {string}
99
+ * @memberof GetC2CTradeHistoryResponseDataInner
100
+ */
101
+ totalPrice?: string;
102
+ /**
103
+ *
104
+ * @type {string}
105
+ * @memberof GetC2CTradeHistoryResponseDataInner
106
+ */
107
+ unitPrice?: string;
108
+ /**
109
+ *
110
+ * @type {string}
111
+ * @memberof GetC2CTradeHistoryResponseDataInner
112
+ */
113
+ orderStatus?: string;
114
+ /**
115
+ *
116
+ * @type {number}
117
+ * @memberof GetC2CTradeHistoryResponseDataInner
118
+ */
119
+ createTime?: number;
120
+ /**
121
+ *
122
+ * @type {string}
123
+ * @memberof GetC2CTradeHistoryResponseDataInner
124
+ */
125
+ commission?: string;
126
+ /**
127
+ *
128
+ * @type {string}
129
+ * @memberof GetC2CTradeHistoryResponseDataInner
130
+ */
131
+ counterPartNickName?: string;
132
+ /**
133
+ *
134
+ * @type {string}
135
+ * @memberof GetC2CTradeHistoryResponseDataInner
136
+ */
137
+ advertisementRole?: string;
138
+ }
139
+
140
+ /**
141
+ * Binance Public C2C REST API
142
+ *
143
+ * OpenAPI Specification for the Binance Public C2C REST API
144
+ *
145
+ * The version of the OpenAPI document: 1.0.0
146
+ *
147
+ *
148
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
149
+ * https://openapi-generator.tech
150
+ * Do not edit the class manually.
151
+ */
152
+
153
+ /**
154
+ *
155
+ * @export
156
+ * @interface GetC2CTradeHistoryResponse
157
+ */
158
+ interface GetC2CTradeHistoryResponse {
159
+ /**
160
+ *
161
+ * @type {string}
162
+ * @memberof GetC2CTradeHistoryResponse
163
+ */
164
+ code?: string;
165
+ /**
166
+ *
167
+ * @type {string}
168
+ * @memberof GetC2CTradeHistoryResponse
169
+ */
170
+ message?: string;
171
+ /**
172
+ *
173
+ * @type {Array<GetC2CTradeHistoryResponseDataInner>}
174
+ * @memberof GetC2CTradeHistoryResponse
175
+ */
176
+ data?: Array<GetC2CTradeHistoryResponseDataInner>;
177
+ /**
178
+ *
179
+ * @type {number}
180
+ * @memberof GetC2CTradeHistoryResponse
181
+ */
182
+ total?: number;
183
+ /**
184
+ *
185
+ * @type {boolean}
186
+ * @memberof GetC2CTradeHistoryResponse
187
+ */
188
+ success?: boolean;
189
+ }
190
+
191
+ /**
192
+ * Binance Public C2C REST API
193
+ *
194
+ * OpenAPI Specification for the Binance Public C2C REST API
195
+ *
196
+ * The version of the OpenAPI document: 1.0.0
197
+ *
198
+ *
199
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
200
+ * https://openapi-generator.tech
201
+ * Do not edit the class manually.
202
+ */
203
+
204
+ /**
205
+ * C2cApi - interface
206
+ * @interface C2cApi
207
+ */
208
+ interface C2cApiInterface {
209
+ /**
210
+ * Get C2C Trade History
211
+ *
212
+ * The max interval between startTime and endTime is 30 days.
213
+ * If startTime and endTime are not sent, the recent 7 days' data will be returned.
214
+ * The earliest startTime is supported on June 10, 2020
215
+ * Return up to 200 records per request.
216
+ *
217
+ * Weight: 1
218
+ *
219
+ * @summary Get C2C Trade History (USER_DATA)
220
+ * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters.
221
+ *
222
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
223
+ * @memberof C2cApiInterface
224
+ */
225
+ getC2CTradeHistory(requestParameters?: GetC2CTradeHistoryRequest): Promise<RestApiResponse<GetC2CTradeHistoryResponse>>;
226
+ }
227
+ /**
228
+ * Request parameters for getC2CTradeHistory operation in C2cApi.
229
+ * @interface GetC2CTradeHistoryRequest
230
+ */
231
+ interface GetC2CTradeHistoryRequest {
232
+ /**
233
+ *
234
+ * @type {number}
235
+ * @memberof C2cApiGetC2CTradeHistory
236
+ */
237
+ readonly startTime?: number;
238
+ /**
239
+ *
240
+ * @type {number}
241
+ * @memberof C2cApiGetC2CTradeHistory
242
+ */
243
+ readonly endTime?: number;
244
+ /**
245
+ * Default 1
246
+ * @type {number}
247
+ * @memberof C2cApiGetC2CTradeHistory
248
+ */
249
+ readonly page?: number;
250
+ /**
251
+ *
252
+ * @type {number}
253
+ * @memberof C2cApiGetC2CTradeHistory
254
+ */
255
+ readonly recvWindow?: number;
256
+ }
257
+ /**
258
+ * C2cApi - object-oriented interface
259
+ * @class C2cApi
260
+ */
261
+ declare class C2cApi implements C2cApiInterface {
262
+ private readonly configuration;
263
+ private localVarAxiosParamCreator;
264
+ constructor(configuration: ConfigurationRestAPI);
265
+ /**
266
+ * Get C2C Trade History
267
+ *
268
+ * The max interval between startTime and endTime is 30 days.
269
+ * If startTime and endTime are not sent, the recent 7 days' data will be returned.
270
+ * The earliest startTime is supported on June 10, 2020
271
+ * Return up to 200 records per request.
272
+ *
273
+ * Weight: 1
274
+ *
275
+ * @summary Get C2C Trade History (USER_DATA)
276
+ * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters.
277
+ * @returns {Promise<RestApiResponse<GetC2CTradeHistoryResponse>>}
278
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
279
+ * @memberof C2cApi
280
+ * @see {@link https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History Binance API Documentation}
281
+ */
282
+ getC2CTradeHistory(requestParameters?: GetC2CTradeHistoryRequest): Promise<RestApiResponse<GetC2CTradeHistoryResponse>>;
283
+ }
284
+
285
+ /**
286
+ * Binance Public C2C REST API
287
+ *
288
+ * OpenAPI Specification for the Binance Public C2C REST API
289
+ *
290
+ * The version of the OpenAPI document: 1.0.0
291
+ *
292
+ *
293
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
294
+ * https://openapi-generator.tech
295
+ * Do not edit the class manually.
296
+ */
297
+
298
+ declare class RestAPI {
299
+ private configuration;
300
+ private c2cApi;
301
+ constructor(configuration: ConfigurationRestAPI);
302
+ /**
303
+ * Generic function to send a request.
304
+ * @param endpoint - The API endpoint to call.
305
+ * @param method - HTTP method to use (GET, POST, DELETE, etc.).
306
+ * @param params - Query parameters for the request.
307
+ *
308
+ * @returns A promise resolving to the response data object.
309
+ */
310
+ sendRequest<T>(endpoint: string, method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH', params?: Record<string, unknown>): Promise<RestApiResponse<T>>;
311
+ /**
312
+ * Generic function to send a signed request.
313
+ * @param endpoint - The API endpoint to call.
314
+ * @param method - HTTP method to use (GET, POST, DELETE, etc.).
315
+ * @param params - Query parameters for the request.
316
+ *
317
+ * @returns A promise resolving to the response data object.
318
+ */
319
+ sendSignedRequest<T>(endpoint: string, method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH', params?: Record<string, unknown>): Promise<RestApiResponse<T>>;
320
+ /**
321
+ * Get C2C Trade History
322
+ *
323
+ * The max interval between startTime and endTime is 30 days.
324
+ * If startTime and endTime are not sent, the recent 7 days' data will be returned.
325
+ * The earliest startTime is supported on June 10, 2020
326
+ * Return up to 200 records per request.
327
+ *
328
+ * Weight: 1
329
+ *
330
+ * @summary Get C2C Trade History (USER_DATA)
331
+ * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters.
332
+ * @returns {Promise<RestApiResponse<GetC2CTradeHistoryResponse>>}
333
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
334
+ * @see {@link https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History Binance API Documentation}
335
+ */
336
+ getC2CTradeHistory(requestParameters?: GetC2CTradeHistoryRequest): Promise<RestApiResponse<GetC2CTradeHistoryResponse>>;
337
+ }
338
+
339
+ /**
340
+ * Binance Public C2C REST API
341
+ *
342
+ * OpenAPI Specification for the Binance Public C2C REST API
343
+ *
344
+ * The version of the OpenAPI document: 1.0.0
345
+ *
346
+ *
347
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
348
+ * https://openapi-generator.tech
349
+ * Do not edit the class manually.
350
+ */
351
+
352
+ type index_BadRequest = BadRequest;
353
+ type index_C2cApi = C2cApi;
354
+ declare const index_C2cApi: typeof C2cApi;
355
+ type index_C2cApiInterface = C2cApiInterface;
356
+ type index_GetC2CTradeHistoryRequest = GetC2CTradeHistoryRequest;
357
+ type index_GetC2CTradeHistoryResponse = GetC2CTradeHistoryResponse;
358
+ type index_GetC2CTradeHistoryResponseDataInner = GetC2CTradeHistoryResponseDataInner;
359
+ type index_RestAPI = RestAPI;
360
+ declare const index_RestAPI: typeof RestAPI;
361
+ declare namespace index {
362
+ export {
363
+ index_BadRequest as BadRequest,
364
+ index_C2cApi as C2cApi,
365
+ index_C2cApiInterface as C2cApiInterface,
366
+ index_GetC2CTradeHistoryRequest as GetC2CTradeHistoryRequest,
367
+ index_GetC2CTradeHistoryResponse as GetC2CTradeHistoryResponse,
368
+ index_GetC2CTradeHistoryResponseDataInner as GetC2CTradeHistoryResponseDataInner,
369
+ index_RestAPI as RestAPI,
370
+ };
371
+ }
372
+
373
+ interface ConfigurationC2C {
374
+ configurationRestAPI?: ConfigurationRestAPI;
375
+ }
376
+ declare class C2C {
377
+ restAPI: RestAPI;
378
+ constructor(config: ConfigurationC2C);
379
+ }
380
+
381
+ export { C2C, index as C2CRestAPI, ConfigurationC2C };
package/dist/index.js ADDED
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name2 in all)
8
+ __defProp(target, name2, { get: all[name2], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ BadRequestError: () => import_common4.BadRequestError,
24
+ C2C: () => C2C,
25
+ C2CRestAPI: () => rest_api_exports,
26
+ C2C_REST_API_PROD_URL: () => import_common4.C2C_REST_API_PROD_URL,
27
+ C2C_REST_API_TESTNET_URL: () => import_common4.C2C_REST_API_TESTNET_URL,
28
+ ConnectorClientError: () => import_common4.ConnectorClientError,
29
+ ForbiddenError: () => import_common4.ForbiddenError,
30
+ NetworkError: () => import_common4.NetworkError,
31
+ NotFoundError: () => import_common4.NotFoundError,
32
+ RateLimitBanError: () => import_common4.RateLimitBanError,
33
+ RequiredError: () => import_common4.RequiredError,
34
+ ServerError: () => import_common4.ServerError,
35
+ TooManyRequestsError: () => import_common4.TooManyRequestsError,
36
+ UnauthorizedError: () => import_common4.UnauthorizedError
37
+ });
38
+ module.exports = __toCommonJS(src_exports);
39
+
40
+ // src/c2c.ts
41
+ var import_os = require("os");
42
+ var import_common3 = require("@binance/common");
43
+
44
+ // package.json
45
+ var name = "@binance/c2c";
46
+ var version = "1.0.0";
47
+
48
+ // src/rest-api/index.ts
49
+ var rest_api_exports = {};
50
+ __export(rest_api_exports, {
51
+ C2cApi: () => C2cApi,
52
+ RestAPI: () => RestAPI
53
+ });
54
+
55
+ // src/rest-api/modules/c2c-api.ts
56
+ var import_common = require("@binance/common");
57
+ var C2cApiAxiosParamCreator = function(configuration) {
58
+ return {
59
+ /**
60
+ * Get C2C Trade History
61
+ *
62
+ * The max interval between startTime and endTime is 30 days.
63
+ * If startTime and endTime are not sent, the recent 7 days' data will be returned.
64
+ * The earliest startTime is supported on June 10, 2020
65
+ * Return up to 200 records per request.
66
+ *
67
+ * Weight: 1
68
+ *
69
+ * @summary Get C2C Trade History (USER_DATA)
70
+ * @param {number} [startTime]
71
+ * @param {number} [endTime]
72
+ * @param {number} [page] Default 1
73
+ * @param {number} [recvWindow]
74
+ *
75
+ * @throws {RequiredError}
76
+ */
77
+ getC2CTradeHistory: async (startTime, endTime, page, recvWindow) => {
78
+ const localVarQueryParameter = {};
79
+ if (startTime !== void 0 && startTime !== null) {
80
+ localVarQueryParameter["startTime"] = startTime;
81
+ }
82
+ if (endTime !== void 0 && endTime !== null) {
83
+ localVarQueryParameter["endTime"] = endTime;
84
+ }
85
+ if (page !== void 0 && page !== null) {
86
+ localVarQueryParameter["page"] = page;
87
+ }
88
+ if (recvWindow !== void 0 && recvWindow !== null) {
89
+ localVarQueryParameter["recvWindow"] = recvWindow;
90
+ }
91
+ let _timeUnit;
92
+ if ("timeUnit" in configuration)
93
+ _timeUnit = configuration.timeUnit;
94
+ return {
95
+ endpoint: "/sapi/v1/c2c/orderMatch/listUserOrderHistory",
96
+ method: "GET",
97
+ params: localVarQueryParameter,
98
+ timeUnit: _timeUnit
99
+ };
100
+ }
101
+ };
102
+ };
103
+ var C2cApi = class {
104
+ constructor(configuration) {
105
+ this.configuration = configuration;
106
+ this.localVarAxiosParamCreator = C2cApiAxiosParamCreator(configuration);
107
+ }
108
+ /**
109
+ * Get C2C Trade History
110
+ *
111
+ * The max interval between startTime and endTime is 30 days.
112
+ * If startTime and endTime are not sent, the recent 7 days' data will be returned.
113
+ * The earliest startTime is supported on June 10, 2020
114
+ * Return up to 200 records per request.
115
+ *
116
+ * Weight: 1
117
+ *
118
+ * @summary Get C2C Trade History (USER_DATA)
119
+ * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters.
120
+ * @returns {Promise<RestApiResponse<GetC2CTradeHistoryResponse>>}
121
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
122
+ * @memberof C2cApi
123
+ * @see {@link https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History Binance API Documentation}
124
+ */
125
+ async getC2CTradeHistory(requestParameters = {}) {
126
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.getC2CTradeHistory(
127
+ requestParameters?.startTime,
128
+ requestParameters?.endTime,
129
+ requestParameters?.page,
130
+ requestParameters?.recvWindow
131
+ );
132
+ return (0, import_common.sendRequest)(
133
+ this.configuration,
134
+ localVarAxiosArgs.endpoint,
135
+ localVarAxiosArgs.method,
136
+ localVarAxiosArgs.params,
137
+ localVarAxiosArgs?.timeUnit,
138
+ { isSigned: true }
139
+ );
140
+ }
141
+ };
142
+
143
+ // src/rest-api/rest-api.ts
144
+ var import_common2 = require("@binance/common");
145
+ var RestAPI = class {
146
+ constructor(configuration) {
147
+ this.configuration = configuration;
148
+ this.c2cApi = new C2cApi(configuration);
149
+ }
150
+ /**
151
+ * Generic function to send a request.
152
+ * @param endpoint - The API endpoint to call.
153
+ * @param method - HTTP method to use (GET, POST, DELETE, etc.).
154
+ * @param params - Query parameters for the request.
155
+ *
156
+ * @returns A promise resolving to the response data object.
157
+ */
158
+ sendRequest(endpoint, method, params = {}) {
159
+ return (0, import_common2.sendRequest)(this.configuration, endpoint, method, params, void 0);
160
+ }
161
+ /**
162
+ * Generic function to send a signed request.
163
+ * @param endpoint - The API endpoint to call.
164
+ * @param method - HTTP method to use (GET, POST, DELETE, etc.).
165
+ * @param params - Query parameters for the request.
166
+ *
167
+ * @returns A promise resolving to the response data object.
168
+ */
169
+ sendSignedRequest(endpoint, method, params = {}) {
170
+ return (0, import_common2.sendRequest)(this.configuration, endpoint, method, params, void 0, {
171
+ isSigned: true
172
+ });
173
+ }
174
+ /**
175
+ * Get C2C Trade History
176
+ *
177
+ * The max interval between startTime and endTime is 30 days.
178
+ * If startTime and endTime are not sent, the recent 7 days' data will be returned.
179
+ * The earliest startTime is supported on June 10, 2020
180
+ * Return up to 200 records per request.
181
+ *
182
+ * Weight: 1
183
+ *
184
+ * @summary Get C2C Trade History (USER_DATA)
185
+ * @param {GetC2CTradeHistoryRequest} requestParameters Request parameters.
186
+ * @returns {Promise<RestApiResponse<GetC2CTradeHistoryResponse>>}
187
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
188
+ * @see {@link https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History Binance API Documentation}
189
+ */
190
+ getC2CTradeHistory(requestParameters = {}) {
191
+ return this.c2cApi.getC2CTradeHistory(requestParameters);
192
+ }
193
+ };
194
+
195
+ // src/c2c.ts
196
+ var C2C = class {
197
+ constructor(config) {
198
+ if (config?.configurationRestAPI) {
199
+ const configRestAPI = new import_common3.ConfigurationRestAPI(config.configurationRestAPI);
200
+ configRestAPI.basePath = configRestAPI.basePath || import_common3.C2C_REST_API_PROD_URL;
201
+ configRestAPI.baseOptions = configRestAPI.baseOptions || {};
202
+ configRestAPI.baseOptions.headers = {
203
+ ...configRestAPI.baseOptions.headers || {},
204
+ "User-Agent": `${name}/${version} (Node.js/${process.version}; ${(0, import_os.platform)()}; ${(0, import_os.arch)()})`
205
+ };
206
+ this.restAPI = new RestAPI(configRestAPI);
207
+ }
208
+ }
209
+ };
210
+
211
+ // src/index.ts
212
+ var import_common4 = require("@binance/common");
213
+ // Annotate the CommonJS export names for ESM import in node:
214
+ 0 && (module.exports = {
215
+ BadRequestError,
216
+ C2C,
217
+ C2CRestAPI,
218
+ C2C_REST_API_PROD_URL,
219
+ C2C_REST_API_TESTNET_URL,
220
+ ConnectorClientError,
221
+ ForbiddenError,
222
+ NetworkError,
223
+ NotFoundError,
224
+ RateLimitBanError,
225
+ RequiredError,
226
+ ServerError,
227
+ TooManyRequestsError,
228
+ UnauthorizedError
229
+ });
230
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/c2c.ts","../package.json","../src/rest-api/index.ts","../src/rest-api/modules/c2c-api.ts","../src/rest-api/rest-api.ts"],"sourcesContent":["export { C2C, ConfigurationC2C } from './c2c';\nexport * as C2CRestAPI from './rest-api';\n\nexport {\n C2C_REST_API_PROD_URL,\n C2C_REST_API_TESTNET_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","import { platform, arch } from 'os';\nimport { 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 if (config?.configurationRestAPI) {\n const configRestAPI = new ConfigurationRestAPI(config.configurationRestAPI);\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': `${name}/${version} (Node.js/${process.version}; ${platform()}; ${arch()})`,\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\": \"1.0.0\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"scripts\": {\n \"prepublishOnly\": \"npm run build\",\n \"build\": \"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\": \"^7.2.0\",\n \"typescript\": \"^5.7.2\",\n \"typescript-eslint\": \"^8.24.0\"\n },\n \"dependencies\": {\n \"@binance/common\": \"1.0.0\",\n \"axios\": \"^1.7.4\"\n }\n}\n","/**\n * Binance Public C2C REST API\n *\n * OpenAPI Specification for the Binance Public 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 Public C2C REST API\n *\n * OpenAPI Specification for the Binance Public 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 Public C2C REST API\n *\n * OpenAPI Specification for the Binance Public 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/c2c-api';\n\nimport type { GetC2CTradeHistoryRequest } from './modules/c2c-api';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,gBAA+B;AAC/B,IAAAA,iBAA4D;;;ACAxD,WAAQ;AAER,cAAW;;;ACHf;AAAA;AAAA;AAAA;AAAA;;;ACaA,oBAMO;AAMP,IAAM,0BAA0B,SAAU,eAAqC;AAC3E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AA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