quidax-node 3.1.2 → 4.1.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.
- package/README.md +94 -27
- package/dist/index.cjs +64 -55
- package/dist/index.d.cts +100 -56
- package/dist/index.d.mts +100 -56
- package/dist/index.mjs +64 -55
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -21,13 +21,14 @@ var BaseClient = class {
|
|
|
21
21
|
exchangeBaseURL;
|
|
22
22
|
rampBaseURL;
|
|
23
23
|
constructor(config) {
|
|
24
|
-
|
|
24
|
+
const apiKey = config.apiKey || config.secretKey;
|
|
25
|
+
if (!apiKey) throw new Error("Quidax apiKey is required.");
|
|
25
26
|
this.exchangeBaseURL = config.exchangeBaseURL || "https://openapi.quidax.io/exchange-open-api/api/v1";
|
|
26
27
|
this.rampBaseURL = config.rampBaseURL || "https://ramp-be.quidax.io/api/v1";
|
|
27
28
|
this.httpClient = axios.create({
|
|
28
29
|
timeout: config.timeout || 3e4,
|
|
29
30
|
headers: {
|
|
30
|
-
"Authorization": `Bearer ${
|
|
31
|
+
"Authorization": `Bearer ${apiKey}`,
|
|
31
32
|
"Content-Type": "application/json"
|
|
32
33
|
}
|
|
33
34
|
});
|
|
@@ -78,7 +79,7 @@ var UsersModule = class {
|
|
|
78
79
|
* @returns A promise resolving to the created User object.
|
|
79
80
|
* @throws {QuidaxError} If validation fails or email already exists.
|
|
80
81
|
*/
|
|
81
|
-
async
|
|
82
|
+
async createSubAccount(data) {
|
|
82
83
|
return this.client.post("/users", data);
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
@@ -86,7 +87,7 @@ var UsersModule = class {
|
|
|
86
87
|
*
|
|
87
88
|
* @returns A promise resolving to the Parent User object.
|
|
88
89
|
*/
|
|
89
|
-
async
|
|
90
|
+
async getMe() {
|
|
90
91
|
return this.client.get("/users/me");
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
@@ -96,7 +97,7 @@ var UsersModule = class {
|
|
|
96
97
|
* @param data - The data to update.
|
|
97
98
|
* @returns A promise resolving to the updated User object.
|
|
98
99
|
*/
|
|
99
|
-
async
|
|
100
|
+
async updateSubAccount(userId, data) {
|
|
100
101
|
return this.client.put(`/users/${userId}`, data);
|
|
101
102
|
}
|
|
102
103
|
/**
|
|
@@ -104,7 +105,7 @@ var UsersModule = class {
|
|
|
104
105
|
*
|
|
105
106
|
* @returns A promise resolving to a list of User objects.
|
|
106
107
|
*/
|
|
107
|
-
async
|
|
108
|
+
async listSubAccounts() {
|
|
108
109
|
return this.client.get("/users");
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
@@ -114,7 +115,7 @@ var UsersModule = class {
|
|
|
114
115
|
* @returns A promise resolving to the User object.
|
|
115
116
|
* @throws {QuidaxError} If the user is not found.
|
|
116
117
|
*/
|
|
117
|
-
async
|
|
118
|
+
async getSubAccount(userId) {
|
|
118
119
|
return this.client.get(`/users/${userId}`);
|
|
119
120
|
}
|
|
120
121
|
};
|
|
@@ -130,7 +131,7 @@ var WalletsModule = class {
|
|
|
130
131
|
* @param userId - The unique ID of the user. 'me' can be used for the authenticated user.
|
|
131
132
|
* @returns A promise resolving to an array of Wallet objects.
|
|
132
133
|
*/
|
|
133
|
-
async
|
|
134
|
+
async listWallets(userId) {
|
|
134
135
|
return this.client.get(`/users/${userId}/wallets`);
|
|
135
136
|
}
|
|
136
137
|
/**
|
|
@@ -140,7 +141,7 @@ var WalletsModule = class {
|
|
|
140
141
|
* @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
|
|
141
142
|
* @returns A promise resolving to a single Wallet object.
|
|
142
143
|
*/
|
|
143
|
-
async
|
|
144
|
+
async getWallet(userId, currency) {
|
|
144
145
|
return this.client.get(`/users/${userId}/wallets/${currency}`);
|
|
145
146
|
}
|
|
146
147
|
/**
|
|
@@ -160,7 +161,7 @@ var WalletsModule = class {
|
|
|
160
161
|
* @param currency - The cryptocurrency ticker.
|
|
161
162
|
* @returns A promise resolving to an array of PaymentAddress objects.
|
|
162
163
|
*/
|
|
163
|
-
async
|
|
164
|
+
async listPaymentAddresses(userId, currency) {
|
|
164
165
|
return this.client.get(`/users/${userId}/wallets/${currency}/addresses`);
|
|
165
166
|
}
|
|
166
167
|
/**
|
|
@@ -176,13 +177,16 @@ var WalletsModule = class {
|
|
|
176
177
|
}
|
|
177
178
|
/**
|
|
178
179
|
* Generates a new Payment Address for a cryptocurrency wallet.
|
|
180
|
+
* In Quidax 3.0 the network is mandatory and the address is generated immediately.
|
|
179
181
|
*
|
|
180
182
|
* @param userId - The unique ID of the user.
|
|
181
|
-
* @param currency - The cryptocurrency ticker (e.g., 'btc', '
|
|
183
|
+
* @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
|
|
184
|
+
* @param network - The blockchain network (e.g., 'bitcoin', 'bep20', 'trc20').
|
|
185
|
+
* Use `getWallet`/`listWallets` to see the networks a currency supports.
|
|
182
186
|
* @returns A promise resolving to the newly generated PaymentAddress object.
|
|
183
187
|
*/
|
|
184
188
|
async createPaymentAddress(userId, currency, network) {
|
|
185
|
-
return this.client.post(`/users/${userId}/wallets/${currency}/addresses
|
|
189
|
+
return this.client.post(`/users/${userId}/wallets/${currency}/addresses`, void 0, { params: { network } });
|
|
186
190
|
}
|
|
187
191
|
};
|
|
188
192
|
//#endregion
|
|
@@ -197,7 +201,7 @@ var WithdrawalsModule = class {
|
|
|
197
201
|
* @param userId - The unique ID of the user.
|
|
198
202
|
* @returns A promise resolving to a paginated list of Withdrawal objects.
|
|
199
203
|
*/
|
|
200
|
-
async
|
|
204
|
+
async listWithdrawals(userId) {
|
|
201
205
|
return this.client.get(`/users/${userId}/withdraws`);
|
|
202
206
|
}
|
|
203
207
|
/**
|
|
@@ -207,7 +211,7 @@ var WithdrawalsModule = class {
|
|
|
207
211
|
* @param withdrawalId - The ID of the withdrawal to retrieve.
|
|
208
212
|
* @returns A promise resolving to a single Withdrawal object.
|
|
209
213
|
*/
|
|
210
|
-
async
|
|
214
|
+
async getWithdrawal(userId, withdrawalId) {
|
|
211
215
|
return this.client.get(`/users/${userId}/withdraws/${withdrawalId}`);
|
|
212
216
|
}
|
|
213
217
|
/**
|
|
@@ -217,7 +221,7 @@ var WithdrawalsModule = class {
|
|
|
217
221
|
* @param reference - The withdrawal reference string.
|
|
218
222
|
* @returns A promise resolving to a single Withdrawal object.
|
|
219
223
|
*/
|
|
220
|
-
async
|
|
224
|
+
async getWithdrawalByReference(userId, reference) {
|
|
221
225
|
return this.client.get(`/users/${userId}/withdraws/reference/${reference}`);
|
|
222
226
|
}
|
|
223
227
|
/**
|
|
@@ -227,14 +231,17 @@ var WithdrawalsModule = class {
|
|
|
227
231
|
* @param data - The withdrawal details.
|
|
228
232
|
* @param data.currency - The cryptocurrency ticker (e.g., 'btc').
|
|
229
233
|
* @param data.amount - The amount to withdraw.
|
|
230
|
-
* @param data.fund_uid - The ID of
|
|
234
|
+
* @param data.fund_uid - The ID of a sub-user or a crypto address.
|
|
235
|
+
* @param data.fund_uid2 - Destination tag/memo (e.g. for XRP, XLM).
|
|
231
236
|
* @param data.transaction_note - Optional note for the transaction.
|
|
232
|
-
* @param data.reference -
|
|
237
|
+
* @param data.reference - Unique reference for the withdrawal (required in v3.0).
|
|
238
|
+
* If this call fails, fetch the withdrawal with `getWithdrawalByReference` before retrying,
|
|
239
|
+
* as it may already have been processed.
|
|
233
240
|
* @param data.narration - Optional narration for the transaction.
|
|
234
|
-
* @param data.network -
|
|
241
|
+
* @param data.network - Blockchain network; required for on-chain withdrawals.
|
|
235
242
|
* @returns A promise resolving to the created Withdrawal object.
|
|
236
243
|
*/
|
|
237
|
-
async
|
|
244
|
+
async createWithdrawal(userId, data) {
|
|
238
245
|
return this.client.post(`/users/${userId}/withdraws`, data);
|
|
239
246
|
}
|
|
240
247
|
/**
|
|
@@ -246,7 +253,7 @@ var WithdrawalsModule = class {
|
|
|
246
253
|
* @param reference - The withdrawal reference string.
|
|
247
254
|
* @returns A promise resolving to the created Withdrawal object.
|
|
248
255
|
*/
|
|
249
|
-
async
|
|
256
|
+
async createNgnMerchantWithdrawal(userId, amount, merchantId, reference) {
|
|
250
257
|
const payload = {
|
|
251
258
|
currency: "ngn",
|
|
252
259
|
amount,
|
|
@@ -264,7 +271,7 @@ var WithdrawalsModule = class {
|
|
|
264
271
|
* @param withdrawalId - The ID of the withdrawal to cancel.
|
|
265
272
|
* @returns A promise resolving to the canceled Withdrawal object.
|
|
266
273
|
*/
|
|
267
|
-
async
|
|
274
|
+
async cancelWithdrawal(userId, withdrawalId) {
|
|
268
275
|
return this.client.post(`/users/${userId}/withdraws/${withdrawalId}/cancel`);
|
|
269
276
|
}
|
|
270
277
|
};
|
|
@@ -279,7 +286,7 @@ var MarketsModule = class {
|
|
|
279
286
|
*
|
|
280
287
|
* @returns A promise resolving to an array of Market objects.
|
|
281
288
|
*/
|
|
282
|
-
async
|
|
289
|
+
async listMarkets() {
|
|
283
290
|
return this.client.get("/markets");
|
|
284
291
|
}
|
|
285
292
|
/**
|
|
@@ -293,11 +300,11 @@ var MarketsModule = class {
|
|
|
293
300
|
/**
|
|
294
301
|
* Retrieves the current ticker data for a specific market.
|
|
295
302
|
*
|
|
296
|
-
* @param
|
|
303
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
297
304
|
* @returns A promise resolving to the Ticker data.
|
|
298
305
|
*/
|
|
299
|
-
async getTicker(
|
|
300
|
-
return this.client.get(`/markets/tickers/${
|
|
306
|
+
async getTicker(market) {
|
|
307
|
+
return this.client.get(`/markets/tickers/${market}`);
|
|
301
308
|
}
|
|
302
309
|
/**
|
|
303
310
|
* Retrieves candlestick (k-line) data for a specific market.
|
|
@@ -309,39 +316,39 @@ var MarketsModule = class {
|
|
|
309
316
|
* @param params.timestamp - Starting timestamp.
|
|
310
317
|
* @returns A promise resolving to an array of k-line data points.
|
|
311
318
|
*/
|
|
312
|
-
async
|
|
319
|
+
async getCandles(market, params) {
|
|
313
320
|
return this.client.get(`/markets/${market}/k`, { params });
|
|
314
321
|
}
|
|
315
322
|
/**
|
|
316
323
|
* Retrieves candlestick data including pending trades for a market.
|
|
317
324
|
*
|
|
318
|
-
* @param
|
|
325
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
319
326
|
* @param tradeId - The ID of the pending trade reference.
|
|
320
327
|
* @param params - Optional query parameters.
|
|
321
328
|
* @returns A promise resolving to an array of k-line data points.
|
|
322
329
|
*/
|
|
323
|
-
async
|
|
324
|
-
return this.client.get(`/markets/${
|
|
330
|
+
async getCandlesWithPendingTrades(market, tradeId, params) {
|
|
331
|
+
return this.client.get(`/markets/${market}/k_with_pending_trades/${tradeId}`, { params });
|
|
325
332
|
}
|
|
326
333
|
/**
|
|
327
334
|
* Retrieves the order book (asks and bids) for a specific market.
|
|
328
335
|
*
|
|
329
|
-
* @param
|
|
336
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
330
337
|
* @param params - Optional query parameters to limit asks and bids.
|
|
331
338
|
* @returns A promise resolving to the OrderBook object.
|
|
332
339
|
*/
|
|
333
|
-
async getOrderBook(
|
|
334
|
-
return this.client.get(`/markets/${
|
|
340
|
+
async getOrderBook(market, params) {
|
|
341
|
+
return this.client.get(`/markets/${market}/order_book`, { params });
|
|
335
342
|
}
|
|
336
343
|
/**
|
|
337
344
|
* Retrieves market depth data.
|
|
338
345
|
*
|
|
339
|
-
* @param
|
|
346
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
340
347
|
* @param params - Optional limit parameter.
|
|
341
348
|
* @returns A promise resolving to depth data.
|
|
342
349
|
*/
|
|
343
|
-
async getDepth(
|
|
344
|
-
return this.client.get(`/markets/${
|
|
350
|
+
async getDepth(market, params) {
|
|
351
|
+
return this.client.get(`/markets/${market}/depth`, { params });
|
|
345
352
|
}
|
|
346
353
|
/**
|
|
347
354
|
* Retrieves a high-level summary of all markets.
|
|
@@ -364,7 +371,7 @@ var TradesModule = class {
|
|
|
364
371
|
* @param userId - The unique ID of the user.
|
|
365
372
|
* @returns A promise resolving to a paginated list of Trade objects.
|
|
366
373
|
*/
|
|
367
|
-
async
|
|
374
|
+
async listUserTrades(userId) {
|
|
368
375
|
return this.client.get(`/users/${userId}/trades`);
|
|
369
376
|
}
|
|
370
377
|
/**
|
|
@@ -373,7 +380,7 @@ var TradesModule = class {
|
|
|
373
380
|
* @param marketPair - The market pair (e.g., 'btcngn').
|
|
374
381
|
* @returns A promise resolving to an array of Trade objects.
|
|
375
382
|
*/
|
|
376
|
-
async
|
|
383
|
+
async listMarketTrades(marketPair) {
|
|
377
384
|
return this.client.get(`/trades/${marketPair}`);
|
|
378
385
|
}
|
|
379
386
|
};
|
|
@@ -390,7 +397,7 @@ var DepositsModule = class {
|
|
|
390
397
|
* @param params - Optional filters (state, currency).
|
|
391
398
|
* @returns A promise resolving to a paginated list of Deposit objects.
|
|
392
399
|
*/
|
|
393
|
-
async
|
|
400
|
+
async listDeposits(userId, params) {
|
|
394
401
|
return this.client.get(`/users/${userId}/deposits`, { params });
|
|
395
402
|
}
|
|
396
403
|
/**
|
|
@@ -400,7 +407,7 @@ var DepositsModule = class {
|
|
|
400
407
|
* @param depositId - The unique ID of the deposit.
|
|
401
408
|
* @returns A promise resolving to a single Deposit object.
|
|
402
409
|
*/
|
|
403
|
-
async
|
|
410
|
+
async getDeposit(userId, depositId) {
|
|
404
411
|
return this.client.get(`/users/${userId}/deposits/${depositId}`);
|
|
405
412
|
}
|
|
406
413
|
/**
|
|
@@ -409,7 +416,7 @@ var DepositsModule = class {
|
|
|
409
416
|
* @param params - Optional filters (state, currency).
|
|
410
417
|
* @returns A promise resolving to a paginated list of Deposit objects.
|
|
411
418
|
*/
|
|
412
|
-
async
|
|
419
|
+
async listSubAccountDeposits(params) {
|
|
413
420
|
return this.client.get("/users/deposits/all", { params });
|
|
414
421
|
}
|
|
415
422
|
};
|
|
@@ -426,7 +433,7 @@ var SwapModule = class {
|
|
|
426
433
|
* @param data - The swap quotation parameters.
|
|
427
434
|
* @returns A promise resolving to the temporary swap quotation details.
|
|
428
435
|
*/
|
|
429
|
-
async
|
|
436
|
+
async previewQuotation(userId, data) {
|
|
430
437
|
return this.client.post(`/users/${userId}/temporary_swap_quotation`, data);
|
|
431
438
|
}
|
|
432
439
|
/**
|
|
@@ -436,7 +443,7 @@ var SwapModule = class {
|
|
|
436
443
|
* @param data - The swap creation payload.
|
|
437
444
|
* @returns A promise resolving to a SwapTransaction object in an unconfirmed state.
|
|
438
445
|
*/
|
|
439
|
-
async
|
|
446
|
+
async createQuotation(userId, data) {
|
|
440
447
|
return this.client.post(`/users/${userId}/swap_quotation`, data);
|
|
441
448
|
}
|
|
442
449
|
/**
|
|
@@ -446,18 +453,20 @@ var SwapModule = class {
|
|
|
446
453
|
* @param quotationId - The ID of the swap quotation to confirm.
|
|
447
454
|
* @returns A promise resolving to the confirmed SwapTransaction.
|
|
448
455
|
*/
|
|
449
|
-
async
|
|
456
|
+
async confirmQuotation(userId, quotationId) {
|
|
450
457
|
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/confirm`);
|
|
451
458
|
}
|
|
452
459
|
/**
|
|
453
|
-
* Refreshes an
|
|
460
|
+
* Refreshes an Instant Swap quotation to get updated market rates.
|
|
461
|
+
* In Quidax 3.0 a quotation can only be refreshed if it has expired or the value changes.
|
|
454
462
|
*
|
|
455
463
|
* @param userId - The unique ID of the user.
|
|
456
|
-
* @param quotationId - The ID of the
|
|
464
|
+
* @param quotationId - The ID of the swap quotation.
|
|
465
|
+
* @param data - Optional updated quotation values.
|
|
457
466
|
* @returns A promise resolving to the refreshed SwapTransaction.
|
|
458
467
|
*/
|
|
459
|
-
async
|
|
460
|
-
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/refresh
|
|
468
|
+
async refreshQuotation(userId, quotationId, data) {
|
|
469
|
+
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/refresh`, data);
|
|
461
470
|
}
|
|
462
471
|
/**
|
|
463
472
|
* Fetches the details of a specific Swap Transaction.
|
|
@@ -466,7 +475,7 @@ var SwapModule = class {
|
|
|
466
475
|
* @param swapTransactionId - The ID of the swap transaction.
|
|
467
476
|
* @returns A promise resolving to the SwapTransaction details.
|
|
468
477
|
*/
|
|
469
|
-
async
|
|
478
|
+
async getSwapTransaction(userId, swapTransactionId) {
|
|
470
479
|
return this.client.get(`/users/${userId}/swap_transactions/${swapTransactionId}`);
|
|
471
480
|
}
|
|
472
481
|
/**
|
|
@@ -475,7 +484,7 @@ var SwapModule = class {
|
|
|
475
484
|
* @param userId - The unique ID of the user.
|
|
476
485
|
* @returns A promise resolving to a paginated list of SwapTransactions.
|
|
477
486
|
*/
|
|
478
|
-
async
|
|
487
|
+
async listSwapTransactions(userId) {
|
|
479
488
|
return this.client.get(`/users/${userId}/swap_transactions`);
|
|
480
489
|
}
|
|
481
490
|
};
|
|
@@ -497,7 +506,7 @@ var OrdersModule = class {
|
|
|
497
506
|
* @param data.volume - The amount of cryptocurrency to buy or sell.
|
|
498
507
|
* @returns A promise resolving to the created Order object.
|
|
499
508
|
*/
|
|
500
|
-
async
|
|
509
|
+
async createOrder(userId, data) {
|
|
501
510
|
return this.client.post(`/users/${userId}/orders`, data);
|
|
502
511
|
}
|
|
503
512
|
/**
|
|
@@ -507,7 +516,7 @@ var OrdersModule = class {
|
|
|
507
516
|
* @param params - Optional filters (market, state, order_by).
|
|
508
517
|
* @returns A promise resolving to a paginated list of Order objects.
|
|
509
518
|
*/
|
|
510
|
-
async
|
|
519
|
+
async listOrders(userId, params) {
|
|
511
520
|
return this.client.get(`/users/${userId}/orders`, { params });
|
|
512
521
|
}
|
|
513
522
|
/**
|
|
@@ -517,7 +526,7 @@ var OrdersModule = class {
|
|
|
517
526
|
* @param orderId - The unique ID of the order.
|
|
518
527
|
* @returns A promise resolving to a single Order object.
|
|
519
528
|
*/
|
|
520
|
-
async
|
|
529
|
+
async getOrder(userId, orderId) {
|
|
521
530
|
return this.client.get(`/users/${userId}/orders/${orderId}`);
|
|
522
531
|
}
|
|
523
532
|
/**
|
|
@@ -527,7 +536,7 @@ var OrdersModule = class {
|
|
|
527
536
|
* @param orderId - The unique ID of the order to cancel.
|
|
528
537
|
* @returns A promise resolving to the canceled Order object.
|
|
529
538
|
*/
|
|
530
|
-
async
|
|
539
|
+
async cancelOrder(userId, orderId) {
|
|
531
540
|
return this.client.post(`/users/${userId}/orders/${orderId}/cancel`);
|
|
532
541
|
}
|
|
533
542
|
};
|
|
@@ -686,8 +695,8 @@ var RampModule = class {
|
|
|
686
695
|
* ```typescript
|
|
687
696
|
* import Quidax from 'quidax-node';
|
|
688
697
|
*
|
|
689
|
-
* const quidax = new Quidax({
|
|
690
|
-
* const me = await quidax.users.
|
|
698
|
+
* const quidax = new Quidax({ apiKey: 'your_api_key' });
|
|
699
|
+
* const me = await quidax.users.getMe();
|
|
691
700
|
* ```
|
|
692
701
|
*/
|
|
693
702
|
var Quidax = class {
|