forked from binance/binance-connector-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrest-api.ts
More file actions
102 lines (94 loc) · 3.53 KB
/
rest-api.ts
File metadata and controls
102 lines (94 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* 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.
*/
import { ConfigurationRestAPI, RestApiResponse, sendRequest } from '@binance/common';
import { C2CApi } from './modules/c2-capi';
import type { GetC2CTradeHistoryRequest } from './modules/c2-capi';
import type { GetC2CTradeHistoryResponse } from './types';
export class RestAPI {
private configuration: ConfigurationRestAPI;
private c2CApi: C2CApi;
constructor(configuration: ConfigurationRestAPI) {
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<T>(
endpoint: string,
method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH',
queryParams: Record<string, unknown> = {},
bodyParams: Record<string, unknown> = {}
): Promise<RestApiResponse<T>> {
return sendRequest<T>(
this.configuration,
endpoint,
method,
queryParams,
bodyParams,
undefined
);
}
/**
* 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<T>(
endpoint: string,
method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH',
queryParams: Record<string, unknown> = {},
bodyParams: Record<string, unknown> = {}
): Promise<RestApiResponse<T>> {
return sendRequest<T>(
this.configuration,
endpoint,
method,
queryParams,
bodyParams,
undefined,
{ 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: GetC2CTradeHistoryRequest = {}
): Promise<RestApiResponse<GetC2CTradeHistoryResponse>> {
return this.c2CApi.getC2CTradeHistory(requestParameters);
}
}