quidax-node 3.3.3 → 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 CHANGED
@@ -42,10 +42,10 @@ The SDK is organized into intuitive, feature-based modules.
42
42
  Manage parent and sub-accounts.
43
43
  ```typescript
44
44
  // Fetch parent account details
45
- const parentAccount = await quidax.users.getParentAccount();
45
+ const parentAccount = await quidax.users.getMe();
46
46
 
47
47
  // Create a sub-account
48
- const subAccount = await quidax.users.create({
48
+ const subAccount = await quidax.users.createSubAccount({
49
49
  email: 'user@example.com',
50
50
  first_name: 'John',
51
51
  last_name: 'Doe'
@@ -56,7 +56,7 @@ const subAccount = await quidax.users.create({
56
56
  Manage cryptocurrency wallets and generate payment addresses.
57
57
  ```typescript
58
58
  // Fetch all wallets for a specific user (each wallet lists its supported `networks`)
59
- const wallets = await quidax.wallets.getAll('user_id');
59
+ const wallets = await quidax.wallets.listWallets('user_id');
60
60
 
61
61
  // Generate a payment address. The network is required in v3.0 and the address is returned immediately.
62
62
  const btcAddress = await quidax.wallets.createPaymentAddress('user_id', 'btc', 'bitcoin');
@@ -77,12 +77,12 @@ const ticker = await quidax.markets.getTicker('btcngn');
77
77
  Track deposits and process withdrawals.
78
78
  ```typescript
79
79
  // Fetch all deposits for a user
80
- const deposits = await quidax.deposits.getAll('user_id');
80
+ const deposits = await quidax.deposits.listDeposits('user_id');
81
81
 
82
82
  // Process a crypto withdrawal. `reference` is required in v3.0.
83
83
  const reference = 'wd_' + Date.now();
84
84
  try {
85
- const withdrawal = await quidax.withdrawals.create('user_id', {
85
+ const withdrawal = await quidax.withdrawals.createWithdrawal('user_id', {
86
86
  currency: 'usdt',
87
87
  amount: '50',
88
88
  fund_uid: 'destination_address_or_sub_user_id',
@@ -92,37 +92,37 @@ try {
92
92
  } catch (error) {
93
93
  // The withdrawal may already have been processed. Check by reference
94
94
  // before retrying, to avoid a double debit.
95
- const existing = await quidax.withdrawals.getByReference('user_id', reference);
95
+ const existing = await quidax.withdrawals.getWithdrawalByReference('user_id', reference);
96
96
  }
97
97
  ```
98
98
 
99
- > **Webhooks:** Quidax recommends re-querying the transaction after you receive a webhook and treating the API response as the source of truth. Use `deposits.getOne`, `swap.getOne` and `withdrawals.getByReference`.
99
+ > **Webhooks:** Quidax recommends re-querying the transaction after you receive a webhook and treating the API response as the source of truth. Use `deposits.getDeposit`, `swap.getSwapTransaction` and `withdrawals.getWithdrawalByReference`.
100
100
 
101
101
  ### 5. Instant Swaps
102
102
  Process crypto-to-crypto instant swaps.
103
103
  ```typescript
104
104
  // Preview a swap (temporary quotation)
105
- const preview = await quidax.swap.getQuotation('user_id', {
105
+ const preview = await quidax.swap.previewQuotation('user_id', {
106
106
  from_currency: 'btc',
107
107
  to_currency: 'usdt',
108
108
  from_amount: '0.01',
109
109
  });
110
110
 
111
111
  // Create the swap quotation (provide either from_amount or to_amount, not both)
112
- const quotation = await quidax.swap.create('user_id', {
112
+ const quotation = await quidax.swap.createQuotation('user_id', {
113
113
  from_currency: 'btc',
114
114
  to_currency: 'usdt',
115
115
  from_amount: '0.01',
116
116
  });
117
117
 
118
118
  // Confirm the quotation
119
- const swap = await quidax.swap.confirm('user_id', quotation.data.id);
119
+ const swap = await quidax.swap.confirmQuotation('user_id', quotation.data.id);
120
120
 
121
121
  // Status is 'initiated' | 'completed' | 'failed' ('failed' is new in v3.0)
122
122
  if (swap.data.status === 'failed') { /* handle failure */ }
123
123
 
124
124
  // Refresh a quotation. In v3.0 this only works if it has expired or the value changed.
125
- await quidax.swap.refresh('user_id', quotation.data.id, { from_amount: '0.02' });
125
+ await quidax.swap.refreshQuotation('user_id', quotation.data.id, { from_amount: '0.02' });
126
126
  ```
127
127
 
128
128
  ### 6. Ramp & Custodial
@@ -139,6 +139,47 @@ const quote = await quidax.ramp.getBuyQuote({
139
139
  });
140
140
  ```
141
141
 
142
+ ## Migrating from 3.x to 4.0
143
+
144
+ **v4.0.0 is a breaking release.** Method names now say which resource they act on, and they all use the same verbs (`list`, `get`, `create`, `update`, `cancel`, `confirm`). The old names have been **removed**, so rename your calls using the table below.
145
+
146
+ | Module | Old name | New name |
147
+ | --- | --- | --- |
148
+ | `users` | `getParentAccount` | `getMe` |
149
+ | `users` | `getAll` | `listSubAccounts` |
150
+ | `users` | `getOne` | `getSubAccount` |
151
+ | `users` | `create` | `createSubAccount` |
152
+ | `users` | `edit` | `updateSubAccount` |
153
+ | `wallets` | `getAll` | `listWallets` |
154
+ | `wallets` | `getOne` | `getWallet` |
155
+ | `wallets` | `getAllPaymentAddresses` | `listPaymentAddresses` |
156
+ | `deposits` | `getAll` | `listDeposits` |
157
+ | `deposits` | `getOne` | `getDeposit` |
158
+ | `deposits` | `getSubUsersDeposits` | `listSubAccountDeposits` |
159
+ | `withdrawals` | `getAll` | `listWithdrawals` |
160
+ | `withdrawals` | `getOne` | `getWithdrawal` |
161
+ | `withdrawals` | `getByReference` | `getWithdrawalByReference` |
162
+ | `withdrawals` | `create` | `createWithdrawal` |
163
+ | `withdrawals` | `ngn_to_merchant` | `createNgnMerchantWithdrawal` |
164
+ | `withdrawals` | `cancel` | `cancelWithdrawal` |
165
+ | `orders` | `getAll` | `listOrders` |
166
+ | `orders` | `getOne` | `getOrder` |
167
+ | `orders` | `create` | `createOrder` |
168
+ | `orders` | `cancel` | `cancelOrder` |
169
+ | `swap` | `getQuotation` | `previewQuotation` |
170
+ | `swap` | `create` | `createQuotation` |
171
+ | `swap` | `confirm` | `confirmQuotation` |
172
+ | `swap` | `refresh` | `refreshQuotation` |
173
+ | `swap` | `getOne` | `getSwapTransaction` |
174
+ | `swap` | `getAll` | `listSwapTransactions` |
175
+ | `markets` | `getAll` | `listMarkets` |
176
+ | `markets` | `getKLine` | `getCandles` |
177
+ | `markets` | `getKLineWithPending` | `getCandlesWithPendingTrades` |
178
+ | `trades` | `getUserTrades` | `listUserTrades` |
179
+ | `trades` | `getMarketTrades` | `listMarketTrades` |
180
+
181
+ Arguments and return types have not changed. `ramp` and `fees` are unchanged.
182
+
142
183
  ## Error Handling
143
184
 
144
185
  This SDK features a gracefully integrated error handling system. Instead of fighting with raw HTTP exceptions or nested Axios errors, the SDK automatically parses the payload returned by Quidax and throws a strongly-typed `QuidaxError`.
package/dist/index.cjs CHANGED
@@ -106,7 +106,7 @@ var UsersModule = class {
106
106
  * @returns A promise resolving to the created User object.
107
107
  * @throws {QuidaxError} If validation fails or email already exists.
108
108
  */
109
- async create(data) {
109
+ async createSubAccount(data) {
110
110
  return this.client.post("/users", data);
111
111
  }
112
112
  /**
@@ -114,7 +114,7 @@ var UsersModule = class {
114
114
  *
115
115
  * @returns A promise resolving to the Parent User object.
116
116
  */
117
- async getParentAccount() {
117
+ async getMe() {
118
118
  return this.client.get("/users/me");
119
119
  }
120
120
  /**
@@ -124,7 +124,7 @@ var UsersModule = class {
124
124
  * @param data - The data to update.
125
125
  * @returns A promise resolving to the updated User object.
126
126
  */
127
- async edit(userId, data) {
127
+ async updateSubAccount(userId, data) {
128
128
  return this.client.put(`/users/${userId}`, data);
129
129
  }
130
130
  /**
@@ -132,7 +132,7 @@ var UsersModule = class {
132
132
  *
133
133
  * @returns A promise resolving to a list of User objects.
134
134
  */
135
- async getAll() {
135
+ async listSubAccounts() {
136
136
  return this.client.get("/users");
137
137
  }
138
138
  /**
@@ -142,7 +142,7 @@ var UsersModule = class {
142
142
  * @returns A promise resolving to the User object.
143
143
  * @throws {QuidaxError} If the user is not found.
144
144
  */
145
- async getOne(userId) {
145
+ async getSubAccount(userId) {
146
146
  return this.client.get(`/users/${userId}`);
147
147
  }
148
148
  };
@@ -158,7 +158,7 @@ var WalletsModule = class {
158
158
  * @param userId - The unique ID of the user. 'me' can be used for the authenticated user.
159
159
  * @returns A promise resolving to an array of Wallet objects.
160
160
  */
161
- async getAll(userId) {
161
+ async listWallets(userId) {
162
162
  return this.client.get(`/users/${userId}/wallets`);
163
163
  }
164
164
  /**
@@ -168,7 +168,7 @@ var WalletsModule = class {
168
168
  * @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
169
169
  * @returns A promise resolving to a single Wallet object.
170
170
  */
171
- async getOne(userId, currency) {
171
+ async getWallet(userId, currency) {
172
172
  return this.client.get(`/users/${userId}/wallets/${currency}`);
173
173
  }
174
174
  /**
@@ -188,7 +188,7 @@ var WalletsModule = class {
188
188
  * @param currency - The cryptocurrency ticker.
189
189
  * @returns A promise resolving to an array of PaymentAddress objects.
190
190
  */
191
- async getAllPaymentAddresses(userId, currency) {
191
+ async listPaymentAddresses(userId, currency) {
192
192
  return this.client.get(`/users/${userId}/wallets/${currency}/addresses`);
193
193
  }
194
194
  /**
@@ -209,7 +209,7 @@ var WalletsModule = class {
209
209
  * @param userId - The unique ID of the user.
210
210
  * @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
211
211
  * @param network - The blockchain network (e.g., 'bitcoin', 'bep20', 'trc20').
212
- * Use `getOne`/`getAll` to see the networks a currency supports.
212
+ * Use `getWallet`/`listWallets` to see the networks a currency supports.
213
213
  * @returns A promise resolving to the newly generated PaymentAddress object.
214
214
  */
215
215
  async createPaymentAddress(userId, currency, network) {
@@ -228,7 +228,7 @@ var WithdrawalsModule = class {
228
228
  * @param userId - The unique ID of the user.
229
229
  * @returns A promise resolving to a paginated list of Withdrawal objects.
230
230
  */
231
- async getAll(userId) {
231
+ async listWithdrawals(userId) {
232
232
  return this.client.get(`/users/${userId}/withdraws`);
233
233
  }
234
234
  /**
@@ -238,7 +238,7 @@ var WithdrawalsModule = class {
238
238
  * @param withdrawalId - The ID of the withdrawal to retrieve.
239
239
  * @returns A promise resolving to a single Withdrawal object.
240
240
  */
241
- async getOne(userId, withdrawalId) {
241
+ async getWithdrawal(userId, withdrawalId) {
242
242
  return this.client.get(`/users/${userId}/withdraws/${withdrawalId}`);
243
243
  }
244
244
  /**
@@ -248,7 +248,7 @@ var WithdrawalsModule = class {
248
248
  * @param reference - The withdrawal reference string.
249
249
  * @returns A promise resolving to a single Withdrawal object.
250
250
  */
251
- async getByReference(userId, reference) {
251
+ async getWithdrawalByReference(userId, reference) {
252
252
  return this.client.get(`/users/${userId}/withdraws/reference/${reference}`);
253
253
  }
254
254
  /**
@@ -262,13 +262,13 @@ var WithdrawalsModule = class {
262
262
  * @param data.fund_uid2 - Destination tag/memo (e.g. for XRP, XLM).
263
263
  * @param data.transaction_note - Optional note for the transaction.
264
264
  * @param data.reference - Unique reference for the withdrawal (required in v3.0).
265
- * If this call fails, fetch the withdrawal with `getByReference` before retrying,
265
+ * If this call fails, fetch the withdrawal with `getWithdrawalByReference` before retrying,
266
266
  * as it may already have been processed.
267
267
  * @param data.narration - Optional narration for the transaction.
268
268
  * @param data.network - Blockchain network; required for on-chain withdrawals.
269
269
  * @returns A promise resolving to the created Withdrawal object.
270
270
  */
271
- async create(userId, data) {
271
+ async createWithdrawal(userId, data) {
272
272
  return this.client.post(`/users/${userId}/withdraws`, data);
273
273
  }
274
274
  /**
@@ -280,7 +280,7 @@ var WithdrawalsModule = class {
280
280
  * @param reference - The withdrawal reference string.
281
281
  * @returns A promise resolving to the created Withdrawal object.
282
282
  */
283
- async ngn_to_merchant(userId, amount, merchantId, reference) {
283
+ async createNgnMerchantWithdrawal(userId, amount, merchantId, reference) {
284
284
  const payload = {
285
285
  currency: "ngn",
286
286
  amount,
@@ -298,7 +298,7 @@ var WithdrawalsModule = class {
298
298
  * @param withdrawalId - The ID of the withdrawal to cancel.
299
299
  * @returns A promise resolving to the canceled Withdrawal object.
300
300
  */
301
- async cancel(userId, withdrawalId) {
301
+ async cancelWithdrawal(userId, withdrawalId) {
302
302
  return this.client.post(`/users/${userId}/withdraws/${withdrawalId}/cancel`);
303
303
  }
304
304
  };
@@ -313,7 +313,7 @@ var MarketsModule = class {
313
313
  *
314
314
  * @returns A promise resolving to an array of Market objects.
315
315
  */
316
- async getAll() {
316
+ async listMarkets() {
317
317
  return this.client.get("/markets");
318
318
  }
319
319
  /**
@@ -327,11 +327,11 @@ var MarketsModule = class {
327
327
  /**
328
328
  * Retrieves the current ticker data for a specific market.
329
329
  *
330
- * @param currency - The market pair (e.g., 'btcngn').
330
+ * @param market - The market pair (e.g., 'btcngn').
331
331
  * @returns A promise resolving to the Ticker data.
332
332
  */
333
- async getTicker(currency) {
334
- return this.client.get(`/markets/tickers/${currency}`);
333
+ async getTicker(market) {
334
+ return this.client.get(`/markets/tickers/${market}`);
335
335
  }
336
336
  /**
337
337
  * Retrieves candlestick (k-line) data for a specific market.
@@ -343,39 +343,39 @@ var MarketsModule = class {
343
343
  * @param params.timestamp - Starting timestamp.
344
344
  * @returns A promise resolving to an array of k-line data points.
345
345
  */
346
- async getKLine(market, params) {
346
+ async getCandles(market, params) {
347
347
  return this.client.get(`/markets/${market}/k`, { params });
348
348
  }
349
349
  /**
350
350
  * Retrieves candlestick data including pending trades for a market.
351
351
  *
352
- * @param currency - The market pair (e.g., 'btcngn').
352
+ * @param market - The market pair (e.g., 'btcngn').
353
353
  * @param tradeId - The ID of the pending trade reference.
354
354
  * @param params - Optional query parameters.
355
355
  * @returns A promise resolving to an array of k-line data points.
356
356
  */
357
- async getKLineWithPending(currency, tradeId, params) {
358
- return this.client.get(`/markets/${currency}/k_with_pending_trades/${tradeId}`, { params });
357
+ async getCandlesWithPendingTrades(market, tradeId, params) {
358
+ return this.client.get(`/markets/${market}/k_with_pending_trades/${tradeId}`, { params });
359
359
  }
360
360
  /**
361
361
  * Retrieves the order book (asks and bids) for a specific market.
362
362
  *
363
- * @param currency - The market pair (e.g., 'btcngn').
363
+ * @param market - The market pair (e.g., 'btcngn').
364
364
  * @param params - Optional query parameters to limit asks and bids.
365
365
  * @returns A promise resolving to the OrderBook object.
366
366
  */
367
- async getOrderBook(currency, params) {
368
- return this.client.get(`/markets/${currency}/order_book`, { params });
367
+ async getOrderBook(market, params) {
368
+ return this.client.get(`/markets/${market}/order_book`, { params });
369
369
  }
370
370
  /**
371
371
  * Retrieves market depth data.
372
372
  *
373
- * @param currency - The market pair (e.g., 'btcngn').
373
+ * @param market - The market pair (e.g., 'btcngn').
374
374
  * @param params - Optional limit parameter.
375
375
  * @returns A promise resolving to depth data.
376
376
  */
377
- async getDepth(currency, params) {
378
- return this.client.get(`/markets/${currency}/depth`, { params });
377
+ async getDepth(market, params) {
378
+ return this.client.get(`/markets/${market}/depth`, { params });
379
379
  }
380
380
  /**
381
381
  * Retrieves a high-level summary of all markets.
@@ -398,7 +398,7 @@ var TradesModule = class {
398
398
  * @param userId - The unique ID of the user.
399
399
  * @returns A promise resolving to a paginated list of Trade objects.
400
400
  */
401
- async getUserTrades(userId) {
401
+ async listUserTrades(userId) {
402
402
  return this.client.get(`/users/${userId}/trades`);
403
403
  }
404
404
  /**
@@ -407,7 +407,7 @@ var TradesModule = class {
407
407
  * @param marketPair - The market pair (e.g., 'btcngn').
408
408
  * @returns A promise resolving to an array of Trade objects.
409
409
  */
410
- async getMarketTrades(marketPair) {
410
+ async listMarketTrades(marketPair) {
411
411
  return this.client.get(`/trades/${marketPair}`);
412
412
  }
413
413
  };
@@ -424,7 +424,7 @@ var DepositsModule = class {
424
424
  * @param params - Optional filters (state, currency).
425
425
  * @returns A promise resolving to a paginated list of Deposit objects.
426
426
  */
427
- async getAll(userId, params) {
427
+ async listDeposits(userId, params) {
428
428
  return this.client.get(`/users/${userId}/deposits`, { params });
429
429
  }
430
430
  /**
@@ -434,7 +434,7 @@ var DepositsModule = class {
434
434
  * @param depositId - The unique ID of the deposit.
435
435
  * @returns A promise resolving to a single Deposit object.
436
436
  */
437
- async getOne(userId, depositId) {
437
+ async getDeposit(userId, depositId) {
438
438
  return this.client.get(`/users/${userId}/deposits/${depositId}`);
439
439
  }
440
440
  /**
@@ -443,7 +443,7 @@ var DepositsModule = class {
443
443
  * @param params - Optional filters (state, currency).
444
444
  * @returns A promise resolving to a paginated list of Deposit objects.
445
445
  */
446
- async getSubUsersDeposits(params) {
446
+ async listSubAccountDeposits(params) {
447
447
  return this.client.get("/users/deposits/all", { params });
448
448
  }
449
449
  };
@@ -460,7 +460,7 @@ var SwapModule = class {
460
460
  * @param data - The swap quotation parameters.
461
461
  * @returns A promise resolving to the temporary swap quotation details.
462
462
  */
463
- async getQuotation(userId, data) {
463
+ async previewQuotation(userId, data) {
464
464
  return this.client.post(`/users/${userId}/temporary_swap_quotation`, data);
465
465
  }
466
466
  /**
@@ -470,7 +470,7 @@ var SwapModule = class {
470
470
  * @param data - The swap creation payload.
471
471
  * @returns A promise resolving to a SwapTransaction object in an unconfirmed state.
472
472
  */
473
- async create(userId, data) {
473
+ async createQuotation(userId, data) {
474
474
  return this.client.post(`/users/${userId}/swap_quotation`, data);
475
475
  }
476
476
  /**
@@ -480,7 +480,7 @@ var SwapModule = class {
480
480
  * @param quotationId - The ID of the swap quotation to confirm.
481
481
  * @returns A promise resolving to the confirmed SwapTransaction.
482
482
  */
483
- async confirm(userId, quotationId) {
483
+ async confirmQuotation(userId, quotationId) {
484
484
  return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/confirm`);
485
485
  }
486
486
  /**
@@ -492,7 +492,7 @@ var SwapModule = class {
492
492
  * @param data - Optional updated quotation values.
493
493
  * @returns A promise resolving to the refreshed SwapTransaction.
494
494
  */
495
- async refresh(userId, quotationId, data) {
495
+ async refreshQuotation(userId, quotationId, data) {
496
496
  return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/refresh`, data);
497
497
  }
498
498
  /**
@@ -502,7 +502,7 @@ var SwapModule = class {
502
502
  * @param swapTransactionId - The ID of the swap transaction.
503
503
  * @returns A promise resolving to the SwapTransaction details.
504
504
  */
505
- async getOne(userId, swapTransactionId) {
505
+ async getSwapTransaction(userId, swapTransactionId) {
506
506
  return this.client.get(`/users/${userId}/swap_transactions/${swapTransactionId}`);
507
507
  }
508
508
  /**
@@ -511,7 +511,7 @@ var SwapModule = class {
511
511
  * @param userId - The unique ID of the user.
512
512
  * @returns A promise resolving to a paginated list of SwapTransactions.
513
513
  */
514
- async getAll(userId) {
514
+ async listSwapTransactions(userId) {
515
515
  return this.client.get(`/users/${userId}/swap_transactions`);
516
516
  }
517
517
  };
@@ -533,7 +533,7 @@ var OrdersModule = class {
533
533
  * @param data.volume - The amount of cryptocurrency to buy or sell.
534
534
  * @returns A promise resolving to the created Order object.
535
535
  */
536
- async create(userId, data) {
536
+ async createOrder(userId, data) {
537
537
  return this.client.post(`/users/${userId}/orders`, data);
538
538
  }
539
539
  /**
@@ -543,7 +543,7 @@ var OrdersModule = class {
543
543
  * @param params - Optional filters (market, state, order_by).
544
544
  * @returns A promise resolving to a paginated list of Order objects.
545
545
  */
546
- async getAll(userId, params) {
546
+ async listOrders(userId, params) {
547
547
  return this.client.get(`/users/${userId}/orders`, { params });
548
548
  }
549
549
  /**
@@ -553,7 +553,7 @@ var OrdersModule = class {
553
553
  * @param orderId - The unique ID of the order.
554
554
  * @returns A promise resolving to a single Order object.
555
555
  */
556
- async getOne(userId, orderId) {
556
+ async getOrder(userId, orderId) {
557
557
  return this.client.get(`/users/${userId}/orders/${orderId}`);
558
558
  }
559
559
  /**
@@ -563,7 +563,7 @@ var OrdersModule = class {
563
563
  * @param orderId - The unique ID of the order to cancel.
564
564
  * @returns A promise resolving to the canceled Order object.
565
565
  */
566
- async cancel(userId, orderId) {
566
+ async cancelOrder(userId, orderId) {
567
567
  return this.client.post(`/users/${userId}/orders/${orderId}/cancel`);
568
568
  }
569
569
  };
@@ -723,7 +723,7 @@ var RampModule = class {
723
723
  * import Quidax from 'quidax-node';
724
724
  *
725
725
  * const quidax = new Quidax({ apiKey: 'your_api_key' });
726
- * const me = await quidax.users.getParentAccount();
726
+ * const me = await quidax.users.getMe();
727
727
  * ```
728
728
  */
729
729
  var Quidax = class {