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
172 lines (161 loc) · 6.33 KB
/
rest-api.ts
File metadata and controls
172 lines (161 loc) · 6.33 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/**
* Binance NFT REST API
*
* OpenAPI Specification for the Binance NFT 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 { NFTApi } from './modules/nftapi';
import type {
GetNFTAssetRequest,
GetNFTDepositHistoryRequest,
GetNFTTransactionHistoryRequest,
GetNFTWithdrawHistoryRequest,
} from './modules/nftapi';
import type {
GetNFTAssetResponse,
GetNFTDepositHistoryResponse,
GetNFTTransactionHistoryResponse,
GetNFTWithdrawHistoryResponse,
} from './types';
export class RestAPI {
private configuration: ConfigurationRestAPI;
private nFTApi: NFTApi;
constructor(configuration: ConfigurationRestAPI) {
this.configuration = configuration;
this.nFTApi = new NFTApi(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 NFT Asset
*
* Weight: 3000
*
* @summary Get NFT Asset(USER_DATA)
* @param {GetNFTAssetRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<GetNFTAssetResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/nft/rest-api/Get-NFT-Asset Binance API Documentation}
*/
getNFTAsset(
requestParameters: GetNFTAssetRequest = {}
): Promise<RestApiResponse<GetNFTAssetResponse>> {
return this.nFTApi.getNFTAsset(requestParameters);
}
/**
* et NFT Deposit History
*
*
* The max interval between startTime and endTime is 90 days.
* If startTime and endTime are not sent, the recent 7 days' data will be returned.
*
* Weight: 3000
*
* @summary Get NFT Deposit History(USER_DATA)
* @param {GetNFTDepositHistoryRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<GetNFTDepositHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/nft/rest-api/Get-NFT-Deposit-History Binance API Documentation}
*/
getNFTDepositHistory(
requestParameters: GetNFTDepositHistoryRequest = {}
): Promise<RestApiResponse<GetNFTDepositHistoryResponse>> {
return this.nFTApi.getNFTDepositHistory(requestParameters);
}
/**
* Get NFT Transaction History
*
* The max interval between startTime and endTime is 90 days.
* If startTime and endTime are not sent, the recent 7 days' data will be returned.
*
* Weight: 3000
*
* @summary Get NFT Transaction History(USER_DATA)
* @param {GetNFTTransactionHistoryRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<GetNFTTransactionHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/nft/rest-api/Get-NFT-Transaction-History Binance API Documentation}
*/
getNFTTransactionHistory(
requestParameters: GetNFTTransactionHistoryRequest
): Promise<RestApiResponse<GetNFTTransactionHistoryResponse>> {
return this.nFTApi.getNFTTransactionHistory(requestParameters);
}
/**
* Get NFT Withdraw History
*
* The max interval between startTime and endTime is 90 days.
* If startTime and endTime are not sent, the recent 7 days' data will be returned.
*
* Weight: 3000
*
* @summary Get NFT Withdraw History(USER_DATA)
* @param {GetNFTWithdrawHistoryRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<GetNFTWithdrawHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/nft/rest-api/Get-NFT-Withdraw-History Binance API Documentation}
*/
getNFTWithdrawHistory(
requestParameters: GetNFTWithdrawHistoryRequest = {}
): Promise<RestApiResponse<GetNFTWithdrawHistoryResponse>> {
return this.nFTApi.getNFTWithdrawHistory(requestParameters);
}
}