bybit-api 3.7.1-beta.0 → 3.7.1

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.
Files changed (69) hide show
  1. package/README.md +34 -6
  2. package/lib/rest-client-v5.d.ts +3 -3
  3. package/lib/rest-client-v5.js.map +1 -1
  4. package/lib/types/request/v5-trade.d.ts +2 -2
  5. package/package.json +1 -13
  6. package/src/account-asset-client-v3.ts +0 -310
  7. package/src/account-asset-client.ts +0 -149
  8. package/src/constants/enum.ts +0 -105
  9. package/src/contract-client.ts +0 -360
  10. package/src/copy-trading-client.ts +0 -159
  11. package/src/index.ts +0 -18
  12. package/src/inverse-client.ts +0 -337
  13. package/src/inverse-futures-client.ts +0 -403
  14. package/src/linear-client.ts +0 -387
  15. package/src/rest-client-v5.ts +0 -1638
  16. package/src/spot-client-v3.ts +0 -303
  17. package/src/spot-client.ts +0 -180
  18. package/src/types/index.ts +0 -5
  19. package/src/types/request/account-asset.ts +0 -258
  20. package/src/types/request/contract.ts +0 -139
  21. package/src/types/request/copy-trading.ts +0 -53
  22. package/src/types/request/index.ts +0 -18
  23. package/src/types/request/inverse.ts +0 -135
  24. package/src/types/request/linear.ts +0 -201
  25. package/src/types/request/spot.ts +0 -89
  26. package/src/types/request/unified-margin.ts +0 -247
  27. package/src/types/request/usdc-options.ts +0 -134
  28. package/src/types/request/usdc-perp.ts +0 -100
  29. package/src/types/request/usdc-shared.ts +0 -39
  30. package/src/types/request/v5-account.ts +0 -40
  31. package/src/types/request/v5-asset.ts +0 -133
  32. package/src/types/request/v5-market.ts +0 -127
  33. package/src/types/request/v5-position.ts +0 -107
  34. package/src/types/request/v5-pre-upgrade.ts +0 -37
  35. package/src/types/request/v5-spot-leverage-token.ts +0 -23
  36. package/src/types/request/v5-trade.ts +0 -133
  37. package/src/types/request/v5-user.ts +0 -21
  38. package/src/types/response/account-asset.ts +0 -236
  39. package/src/types/response/contract.ts +0 -74
  40. package/src/types/response/index.ts +0 -13
  41. package/src/types/response/shared.ts +0 -19
  42. package/src/types/response/spot.ts +0 -17
  43. package/src/types/response/unified-margin.ts +0 -71
  44. package/src/types/response/usdt-perp.ts +0 -58
  45. package/src/types/response/v5-account.ts +0 -122
  46. package/src/types/response/v5-asset.ts +0 -170
  47. package/src/types/response/v5-market.ts +0 -271
  48. package/src/types/response/v5-position.ts +0 -118
  49. package/src/types/response/v5-spot-leverage-token.ts +0 -70
  50. package/src/types/response/v5-trade.ts +0 -103
  51. package/src/types/response/v5-user.ts +0 -58
  52. package/src/types/shared.ts +0 -175
  53. package/src/types/v5-shared.ts +0 -213
  54. package/src/types/websockets.ts +0 -115
  55. package/src/types/ws-events/failed-topic-subscription-confirmation.ts +0 -6
  56. package/src/types/ws-events/succeeded-topic-subscription-confirmation.ts +0 -6
  57. package/src/types/ws-events/topic-subscription-confirmation.ts +0 -7
  58. package/src/unified-margin-client.ts +0 -400
  59. package/src/usdc-option-client.ts +0 -333
  60. package/src/usdc-perpetual-client.ts +0 -312
  61. package/src/util/BaseRestClient.ts +0 -502
  62. package/src/util/WsStore.ts +0 -160
  63. package/src/util/browser-support.ts +0 -29
  64. package/src/util/index.ts +0 -5
  65. package/src/util/logger.ts +0 -26
  66. package/src/util/node-support.ts +0 -9
  67. package/src/util/requestUtils.ts +0 -171
  68. package/src/util/websocket-util.ts +0 -550
  69. package/src/websocket-client.ts +0 -1262
@@ -1,303 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import {
3
- APIResponseV3,
4
- APIResponseWithTime,
5
- KlineInterval,
6
- NewSpotOrderV3,
7
- SpotBalances,
8
- SpotCancelOrderBatchRequest,
9
- SpotCrossMarginBorrowingInfoRequest,
10
- SpotCrossMarginRepaymentHistoryRequest,
11
- SpotLeveragedTokenPRHistoryRequest,
12
- SpotMyTradesRequest,
13
- SpotOrderQueryById,
14
- } from './types';
15
- import { REST_CLIENT_TYPE_ENUM } from './util';
16
- import BaseRestClient from './util/BaseRestClient';
17
-
18
- /**
19
- * REST API client for newer Spot V3 APIs.
20
- */
21
- export class SpotClientV3 extends BaseRestClient {
22
- getClientType() {
23
- // Follows the same authentication mechanism as other v3 APIs (e.g. USDC)
24
- return REST_CLIENT_TYPE_ENUM.v3;
25
- }
26
-
27
- async fetchServerTime(): Promise<number> {
28
- const res = await this.getServerTime();
29
- return Number(res.time_now);
30
- }
31
-
32
- /**
33
- *
34
- * Market Data Endpoints
35
- *
36
- */
37
-
38
- /** Get all symbols */
39
- getSymbols(): Promise<APIResponseV3<any>> {
40
- return this.get('/spot/v3/public/symbols');
41
- }
42
-
43
- /** Get orderbook for symbol */
44
- getOrderBook(symbol: string, limit?: number): Promise<APIResponseV3<any>> {
45
- return this.get('/spot/v3/public/quote/depth', { symbol, limit });
46
- }
47
-
48
- /** Get merged orderbook for symbol */
49
- getMergedOrderBook(
50
- symbol: string,
51
- scale?: number,
52
- limit?: number
53
- ): Promise<APIResponseV3<any>> {
54
- return this.get('/spot/v3/public/quote/depth/merged', {
55
- symbol,
56
- scale,
57
- limit,
58
- });
59
- }
60
-
61
- /** Get public trading records (raw trades) */
62
- getTrades(symbol: string, limit?: number): Promise<APIResponseV3<any>> {
63
- return this.get('/spot/v3/public/quote/trades', { symbol, limit });
64
- }
65
-
66
- /** Get candles/klines */
67
- getCandles(
68
- symbol: string,
69
- interval: KlineInterval,
70
- limit?: number,
71
- startTime?: number,
72
- endTime?: number
73
- ): Promise<APIResponseV3<any>> {
74
- return this.get('/spot/v3/public/quote/kline', {
75
- symbol,
76
- interval,
77
- limit,
78
- startTime,
79
- endTime,
80
- });
81
- }
82
-
83
- /** Get latest information for symbol (24hr ticker) */
84
- get24hrTicker(symbol?: string): Promise<APIResponseV3<any>> {
85
- return this.get('/spot/v3/public/quote/ticker/24hr', { symbol });
86
- }
87
-
88
- /** Get last traded price */
89
- getLastTradedPrice(symbol?: string): Promise<APIResponseV3<any>> {
90
- return this.get('/spot/v3/public/quote/ticker/price', { symbol });
91
- }
92
-
93
- /** Get best bid/ask price */
94
- getBestBidAskPrice(symbol?: string): Promise<APIResponseV3<any>> {
95
- return this.get('/spot/v3/public/quote/ticker/bookTicker', { symbol });
96
- }
97
-
98
- /**
99
- *
100
- * Account Data Endpoints
101
- *
102
- */
103
-
104
- /** -> Order API */
105
-
106
- /** Create order */
107
- submitOrder(params: NewSpotOrderV3): Promise<APIResponseV3<any>> {
108
- return this.postPrivate('/spot/v3/private/order', params);
109
- }
110
-
111
- /** Get active order state */
112
- getOrder(params: SpotOrderQueryById): Promise<APIResponseV3<any>> {
113
- return this.getPrivate('/spot/v3/private/order', params);
114
- }
115
-
116
- /** Cancel order */
117
- cancelOrder(params: SpotOrderQueryById): Promise<APIResponseV3<any>> {
118
- return this.postPrivate('/spot/v3/private/cancel-order', params);
119
- }
120
-
121
- /** Batch cancel orders */
122
- cancelOrderBatch(
123
- params: SpotCancelOrderBatchRequest
124
- ): Promise<APIResponseV3<any>> {
125
- const orderTypes = params.orderTypes
126
- ? params.orderTypes.join(',')
127
- : undefined;
128
-
129
- return this.postPrivate('/spot/v3/private/cancel-orders', {
130
- ...params,
131
- orderTypes,
132
- });
133
- }
134
-
135
- /** Batch cancel up to 100 orders by ID */
136
- cancelOrderBatchIDs(orderIds: string[]): Promise<APIResponseV3<any>> {
137
- const orderIdsCsv = orderIds.join(',');
138
- return this.postPrivate('/spot/v3/private/cancel-orders-by-ids', {
139
- orderIds: orderIdsCsv,
140
- });
141
- }
142
-
143
- /** Get open orders */
144
- getOpenOrders(
145
- symbol?: string,
146
- orderId?: string,
147
- limit?: number,
148
- orderCategory?: 0 | 1
149
- ): Promise<APIResponseV3<any>> {
150
- return this.getPrivate('/spot/v3/private/open-orders', {
151
- symbol,
152
- orderId,
153
- limit,
154
- orderCategory,
155
- });
156
- }
157
-
158
- /** Get order history */
159
- getPastOrders(
160
- symbol?: string,
161
- orderId?: string,
162
- limit?: number,
163
- orderCategory?: 0 | 1
164
- ): Promise<APIResponseV3<any>> {
165
- return this.getPrivate('/spot/v3/private/history-orders', {
166
- symbol,
167
- orderId,
168
- limit,
169
- orderCategory,
170
- });
171
- }
172
-
173
- /**
174
- * Get your trade history.
175
- * If startTime is not specified, you can only query for records in the last 7 days.
176
- * If you want to query for records older than 7 days, startTime is required.
177
- */
178
- getMyTrades(params?: SpotMyTradesRequest): Promise<APIResponseV3<any>> {
179
- return this.getPrivate('/spot/v3/private/my-trades', params);
180
- }
181
-
182
- /**
183
- *
184
- * Wallet Data Endpoints
185
- *
186
- */
187
-
188
- /** Get Wallet Balance */
189
- getBalances(): Promise<APIResponseV3<SpotBalances>> {
190
- return this.getPrivate('/spot/v3/private/account');
191
- }
192
-
193
- /**
194
- *
195
- * API Data Endpoints
196
- *
197
- */
198
-
199
- getServerTime(): Promise<APIResponseWithTime> {
200
- return this.get('/v2/public/time');
201
- }
202
-
203
- /**
204
- *
205
- * Leveraged Token Endpoints
206
- *
207
- */
208
-
209
- /** Get all asset infos */
210
- getLeveragedTokenAssetInfos(ltCode?: string): Promise<APIResponseV3<any>> {
211
- return this.get('/spot/v3/public/infos', { ltCode });
212
- }
213
-
214
- /** Get leveraged token market info */
215
- getLeveragedTokenMarketInfo(ltCode: string): Promise<APIResponseV3<any>> {
216
- return this.getPrivate('/spot/v3/private/reference', { ltCode });
217
- }
218
-
219
- /** Purchase leveraged token */
220
- purchaseLeveragedToken(
221
- ltCode: string,
222
- ltAmount: string,
223
- serialNo?: string
224
- ): Promise<APIResponseV3<any>> {
225
- return this.postPrivate('/spot/v3/private/purchase', {
226
- ltCode,
227
- ltAmount,
228
- serialNo,
229
- });
230
- }
231
-
232
- /** Redeem leveraged token */
233
- redeemLeveragedToken(
234
- ltCode: string,
235
- ltAmount: string,
236
- serialNo?: string
237
- ): Promise<APIResponseV3<any>> {
238
- return this.postPrivate('/spot/v3/private/redeem', {
239
- ltCode,
240
- ltAmount,
241
- serialNo,
242
- });
243
- }
244
-
245
- /** Get leveraged token purchase/redemption history */
246
- getLeveragedTokenPRHistory(
247
- params?: SpotLeveragedTokenPRHistoryRequest
248
- ): Promise<APIResponseV3<any>> {
249
- return this.getPrivate('/spot/v3/private/record', params);
250
- }
251
-
252
- /**
253
- *
254
- * Cross Margin Trading Endpoints
255
- *
256
- */
257
-
258
- /** Borrow margin loan */
259
- borrowCrossMarginLoan(
260
- coin: string,
261
- qty: string
262
- ): Promise<APIResponseV3<any>> {
263
- return this.postPrivate('/spot/v3/private/cross-margin-loan', {
264
- coin,
265
- qty,
266
- });
267
- }
268
-
269
- /** Repay margin loan */
270
- repayCrossMarginLoan(coin: string, qty: string): Promise<APIResponseV3<any>> {
271
- return this.postPrivate('/spot/v3/private/cross-margin-repay', {
272
- coin,
273
- qty,
274
- });
275
- }
276
-
277
- /** Query borrowing info */
278
- getCrossMarginBorrowingInfo(
279
- params?: SpotCrossMarginBorrowingInfoRequest
280
- ): Promise<APIResponseV3<any>> {
281
- return this.getPrivate('/spot/v3/private/cross-margin-orders', params);
282
- }
283
-
284
- /** Query account info */
285
- getCrossMarginAccountInfo(): Promise<APIResponseV3<any>> {
286
- return this.getPrivate('/spot/v3/private/cross-margin-account');
287
- }
288
-
289
- /** Query interest & quota */
290
- getCrossMarginInterestQuota(coin: string): Promise<APIResponseV3<any>> {
291
- return this.getPrivate('/spot/v3/private/cross-margin-loan-info', { coin });
292
- }
293
-
294
- /** Query repayment history */
295
- getCrossMarginRepaymentHistory(
296
- params?: SpotCrossMarginRepaymentHistoryRequest
297
- ): Promise<APIResponseV3<any>> {
298
- return this.getPrivate(
299
- '/spot/v3/private/cross-margin-repay-history',
300
- params
301
- );
302
- }
303
- }
@@ -1,180 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import {
3
- APIResponse,
4
- KlineInterval,
5
- NewSpotOrder,
6
- OrderSide,
7
- OrderTypeSpot,
8
- SpotBalances,
9
- SpotLastPrice,
10
- SpotOrderQueryById,
11
- SpotSymbolInfo,
12
- } from './types';
13
- import BaseRestClient from './util/BaseRestClient';
14
- import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils';
15
-
16
- /**
17
- * @deprecated Use SpotV3Client instead, which leverages the newer v3 APIs
18
- * REST API client for Spot APIs (v1)
19
- */
20
- export class SpotClient extends BaseRestClient {
21
- getClientType() {
22
- return REST_CLIENT_TYPE_ENUM.spot;
23
- }
24
-
25
- fetchServerTime(): Promise<number> {
26
- return this.getServerTime();
27
- }
28
-
29
- async getServerTime(): Promise<number> {
30
- const res = await this.get('/spot/v1/time');
31
- return res.result.serverTime;
32
- }
33
-
34
- /**
35
- *
36
- * Market Data Endpoints
37
- *
38
- **/
39
-
40
- getSymbols(): Promise<APIResponse<SpotSymbolInfo[]>> {
41
- return this.get('/spot/v1/symbols');
42
- }
43
-
44
- getOrderBook(symbol: string, limit?: number): Promise<APIResponse<any>> {
45
- return this.get('/spot/quote/v1/depth', {
46
- symbol,
47
- limit,
48
- });
49
- }
50
-
51
- getMergedOrderBook(
52
- symbol: string,
53
- scale?: number,
54
- limit?: number
55
- ): Promise<APIResponse<any>> {
56
- return this.get('/spot/quote/v1/depth/merged', {
57
- symbol,
58
- scale,
59
- limit,
60
- });
61
- }
62
-
63
- getTrades(symbol: string, limit?: number): Promise<APIResponse<any[]>> {
64
- return this.get('/spot/quote/v1/trades', {
65
- symbol,
66
- limit,
67
- });
68
- }
69
-
70
- getCandles(
71
- symbol: string,
72
- interval: KlineInterval,
73
- limit?: number,
74
- startTime?: number,
75
- endTime?: number
76
- ): Promise<APIResponse<any[]>> {
77
- return this.get('/spot/quote/v1/kline', {
78
- symbol,
79
- interval,
80
- limit,
81
- startTime,
82
- endTime,
83
- });
84
- }
85
-
86
- get24hrTicker(symbol?: string): Promise<APIResponse<any>> {
87
- return this.get('/spot/quote/v1/ticker/24hr', { symbol });
88
- }
89
-
90
- getLastTradedPrice(): Promise<APIResponse<SpotLastPrice[]>>;
91
-
92
- getLastTradedPrice(symbol: string): Promise<APIResponse<SpotLastPrice>>;
93
-
94
- getLastTradedPrice(
95
- symbol?: string
96
- ): Promise<APIResponse<SpotLastPrice | SpotLastPrice[]>> {
97
- return this.get('/spot/quote/v1/ticker/price', { symbol });
98
- }
99
-
100
- getBestBidAskPrice(symbol?: string): Promise<APIResponse<any>> {
101
- return this.get('/spot/quote/v1/ticker/book_ticker', { symbol });
102
- }
103
-
104
- /**
105
- * Account Data Endpoints
106
- */
107
-
108
- submitOrder(params: NewSpotOrder): Promise<APIResponse<any>> {
109
- return this.postPrivate('/spot/v1/order', params);
110
- }
111
-
112
- getOrder(params: SpotOrderQueryById): Promise<APIResponse<any>> {
113
- return this.getPrivate('/spot/v1/order', params);
114
- }
115
-
116
- cancelOrder(params: SpotOrderQueryById): Promise<APIResponse<any>> {
117
- return this.deletePrivate('/spot/v1/order', params);
118
- }
119
-
120
- cancelOrderBatch(params: {
121
- symbol: string;
122
- side?: OrderSide;
123
- orderTypes: OrderTypeSpot[];
124
- }): Promise<APIResponse<any>> {
125
- const orderTypes = params.orderTypes
126
- ? params.orderTypes.join(',')
127
- : undefined;
128
-
129
- return this.deletePrivate('/spot/order/batch-cancel', {
130
- ...params,
131
- orderTypes,
132
- });
133
- }
134
-
135
- getOpenOrders(
136
- symbol?: string,
137
- orderId?: string,
138
- limit?: number
139
- ): Promise<APIResponse<any>> {
140
- return this.getPrivate('/spot/v1/open-orders', {
141
- symbol,
142
- orderId,
143
- limit,
144
- });
145
- }
146
-
147
- getPastOrders(
148
- symbol?: string,
149
- orderId?: string,
150
- limit?: number
151
- ): Promise<APIResponse<any>> {
152
- return this.getPrivate('/spot/v1/history-orders', {
153
- symbol,
154
- orderId,
155
- limit,
156
- });
157
- }
158
-
159
- getMyTrades(
160
- symbol?: string,
161
- limit?: number,
162
- fromId?: number,
163
- toId?: number
164
- ): Promise<APIResponse<any>> {
165
- return this.getPrivate('/spot/v1/myTrades', {
166
- symbol,
167
- limit,
168
- fromId,
169
- toId,
170
- });
171
- }
172
-
173
- /**
174
- * Wallet Data Endpoints
175
- */
176
-
177
- getBalances(): Promise<APIResponse<SpotBalances>> {
178
- return this.getPrivate('/spot/v1/account');
179
- }
180
- }
@@ -1,5 +0,0 @@
1
- export * from './response';
2
- export * from './request';
3
- export * from './shared';
4
- export * from './v5-shared';
5
- export * from './websockets';