quidax-node 3.1.1 → 3.3.3
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 +48 -22
- package/dist/index.cjs +21 -12
- package/dist/index.d.cts +61 -17
- package/dist/index.d.mts +61 -17
- package/dist/index.mjs +21 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,22 +10,24 @@ npm install quidax-node
|
|
|
10
10
|
|
|
11
11
|
## Initialization
|
|
12
12
|
|
|
13
|
-
Initialize the Quidax client with your
|
|
13
|
+
Initialize the Quidax client with your **API key**:
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
16
|
import { Quidax } from 'quidax-node';
|
|
17
17
|
|
|
18
18
|
const quidax = new Quidax({
|
|
19
|
-
|
|
19
|
+
apiKey: 'your_quidax_api_key' // Keep this secure!
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
> **Quidax 3.0:** Generate new API keys in the Quidax 3.0 web app under **My Account → API Management**. IP whitelisting is mandatory, so add your server's IP when you create the key. Pass the **API key**, not the secret key. The `secretKey` option still works but is deprecated.
|
|
24
|
+
|
|
23
25
|
### Advanced Configuration
|
|
24
26
|
You can optionally pass custom Base URLs or adjust the timeout limit (default is 30,000ms).
|
|
25
27
|
|
|
26
28
|
```typescript
|
|
27
29
|
const quidax = new Quidax({
|
|
28
|
-
|
|
30
|
+
apiKey: 'your_quidax_api_key',
|
|
29
31
|
exchangeBaseURL: 'https://openapi.quidax.io/exchange-open-api/api/v1',
|
|
30
32
|
rampBaseURL: 'https://ramp-be.quidax.io/api/v1',
|
|
31
33
|
timeout: 10000
|
|
@@ -53,11 +55,12 @@ const subAccount = await quidax.users.create({
|
|
|
53
55
|
### 2. Wallets & Addresses
|
|
54
56
|
Manage cryptocurrency wallets and generate payment addresses.
|
|
55
57
|
```typescript
|
|
56
|
-
// Fetch all wallets for a specific user
|
|
58
|
+
// Fetch all wallets for a specific user (each wallet lists its supported `networks`)
|
|
57
59
|
const wallets = await quidax.wallets.getAll('user_id');
|
|
58
60
|
|
|
59
|
-
// Generate a payment address
|
|
60
|
-
const
|
|
61
|
+
// Generate a payment address. The network is required in v3.0 and the address is returned immediately.
|
|
62
|
+
const btcAddress = await quidax.wallets.createPaymentAddress('user_id', 'btc', 'bitcoin');
|
|
63
|
+
const usdtAddress = await quidax.wallets.createPaymentAddress('user_id', 'usdt', 'trc20');
|
|
61
64
|
```
|
|
62
65
|
|
|
63
66
|
### 3. Markets & Tickers
|
|
@@ -76,27 +79,50 @@ Track deposits and process withdrawals.
|
|
|
76
79
|
// Fetch all deposits for a user
|
|
77
80
|
const deposits = await quidax.deposits.getAll('user_id');
|
|
78
81
|
|
|
79
|
-
// Process a crypto withdrawal
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
// Process a crypto withdrawal. `reference` is required in v3.0.
|
|
83
|
+
const reference = 'wd_' + Date.now();
|
|
84
|
+
try {
|
|
85
|
+
const withdrawal = await quidax.withdrawals.create('user_id', {
|
|
86
|
+
currency: 'usdt',
|
|
87
|
+
amount: '50',
|
|
88
|
+
fund_uid: 'destination_address_or_sub_user_id',
|
|
89
|
+
network: 'trc20',
|
|
90
|
+
reference,
|
|
91
|
+
});
|
|
92
|
+
} catch (error) {
|
|
93
|
+
// The withdrawal may already have been processed. Check by reference
|
|
94
|
+
// before retrying, to avoid a double debit.
|
|
95
|
+
const existing = await quidax.withdrawals.getByReference('user_id', reference);
|
|
96
|
+
}
|
|
85
97
|
```
|
|
86
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`.
|
|
100
|
+
|
|
87
101
|
### 5. Instant Swaps
|
|
88
102
|
Process crypto-to-crypto instant swaps.
|
|
89
103
|
```typescript
|
|
90
|
-
//
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
// Preview a swap (temporary quotation)
|
|
105
|
+
const preview = await quidax.swap.getQuotation('user_id', {
|
|
106
|
+
from_currency: 'btc',
|
|
107
|
+
to_currency: 'usdt',
|
|
108
|
+
from_amount: '0.01',
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Create the swap quotation (provide either from_amount or to_amount, not both)
|
|
112
|
+
const quotation = await quidax.swap.create('user_id', {
|
|
113
|
+
from_currency: 'btc',
|
|
114
|
+
to_currency: 'usdt',
|
|
115
|
+
from_amount: '0.01',
|
|
96
116
|
});
|
|
97
117
|
|
|
98
118
|
// Confirm the quotation
|
|
99
|
-
const swap = await quidax.swap.confirm('user_id',
|
|
119
|
+
const swap = await quidax.swap.confirm('user_id', quotation.data.id);
|
|
120
|
+
|
|
121
|
+
// Status is 'initiated' | 'completed' | 'failed' ('failed' is new in v3.0)
|
|
122
|
+
if (swap.data.status === 'failed') { /* handle failure */ }
|
|
123
|
+
|
|
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' });
|
|
100
126
|
```
|
|
101
127
|
|
|
102
128
|
### 6. Ramp & Custodial
|
|
@@ -122,7 +148,7 @@ import { Quidax, QuidaxError } from 'quidax-node';
|
|
|
122
148
|
|
|
123
149
|
async function processPayment() {
|
|
124
150
|
try {
|
|
125
|
-
const address = await quidax.wallets.createPaymentAddress('invalid_user', 'btc');
|
|
151
|
+
const address = await quidax.wallets.createPaymentAddress('invalid_user', 'btc', 'bitcoin');
|
|
126
152
|
} catch (error) {
|
|
127
153
|
if (error instanceof QuidaxError) {
|
|
128
154
|
console.error(`HTTP Status: ${error.statusCode}`); // e.g., 400 or 401
|
|
@@ -141,9 +167,9 @@ async function processPayment() {
|
|
|
141
167
|
|
|
142
168
|
## TypeScript Support
|
|
143
169
|
|
|
144
|
-
This project is written entirely in **TypeScript** and compiled using `
|
|
170
|
+
This project is written entirely in **TypeScript** and compiled using `tsdown`.
|
|
145
171
|
- It natively supports both **CommonJS** (`require`) and **ESModules** (`import`).
|
|
146
172
|
- It ships with comprehensive `.d.ts` type definitions out of the box, meaning you get full autocomplete for standard types like `Wallet`, `PaymentAddress`, `Trade`, `Order`, etc.
|
|
147
173
|
|
|
148
174
|
## License
|
|
149
|
-
|
|
175
|
+
ISC
|
package/dist/index.cjs
CHANGED
|
@@ -48,13 +48,14 @@ var BaseClient = class {
|
|
|
48
48
|
exchangeBaseURL;
|
|
49
49
|
rampBaseURL;
|
|
50
50
|
constructor(config) {
|
|
51
|
-
|
|
51
|
+
const apiKey = config.apiKey || config.secretKey;
|
|
52
|
+
if (!apiKey) throw new Error("Quidax apiKey is required.");
|
|
52
53
|
this.exchangeBaseURL = config.exchangeBaseURL || "https://openapi.quidax.io/exchange-open-api/api/v1";
|
|
53
54
|
this.rampBaseURL = config.rampBaseURL || "https://ramp-be.quidax.io/api/v1";
|
|
54
55
|
this.httpClient = axios.default.create({
|
|
55
56
|
timeout: config.timeout || 3e4,
|
|
56
57
|
headers: {
|
|
57
|
-
"Authorization": `Bearer ${
|
|
58
|
+
"Authorization": `Bearer ${apiKey}`,
|
|
58
59
|
"Content-Type": "application/json"
|
|
59
60
|
}
|
|
60
61
|
});
|
|
@@ -203,13 +204,16 @@ var WalletsModule = class {
|
|
|
203
204
|
}
|
|
204
205
|
/**
|
|
205
206
|
* Generates a new Payment Address for a cryptocurrency wallet.
|
|
207
|
+
* In Quidax 3.0 the network is mandatory and the address is generated immediately.
|
|
206
208
|
*
|
|
207
209
|
* @param userId - The unique ID of the user.
|
|
208
|
-
* @param currency - The cryptocurrency ticker (e.g., 'btc', '
|
|
210
|
+
* @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
|
|
211
|
+
* @param network - The blockchain network (e.g., 'bitcoin', 'bep20', 'trc20').
|
|
212
|
+
* Use `getOne`/`getAll` to see the networks a currency supports.
|
|
209
213
|
* @returns A promise resolving to the newly generated PaymentAddress object.
|
|
210
214
|
*/
|
|
211
215
|
async createPaymentAddress(userId, currency, network) {
|
|
212
|
-
return this.client.post(`/users/${userId}/wallets/${currency}/addresses
|
|
216
|
+
return this.client.post(`/users/${userId}/wallets/${currency}/addresses`, void 0, { params: { network } });
|
|
213
217
|
}
|
|
214
218
|
};
|
|
215
219
|
//#endregion
|
|
@@ -254,11 +258,14 @@ var WithdrawalsModule = class {
|
|
|
254
258
|
* @param data - The withdrawal details.
|
|
255
259
|
* @param data.currency - The cryptocurrency ticker (e.g., 'btc').
|
|
256
260
|
* @param data.amount - The amount to withdraw.
|
|
257
|
-
* @param data.fund_uid - The ID of
|
|
261
|
+
* @param data.fund_uid - The ID of a sub-user or a crypto address.
|
|
262
|
+
* @param data.fund_uid2 - Destination tag/memo (e.g. for XRP, XLM).
|
|
258
263
|
* @param data.transaction_note - Optional note for the transaction.
|
|
259
|
-
* @param data.reference -
|
|
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,
|
|
266
|
+
* as it may already have been processed.
|
|
260
267
|
* @param data.narration - Optional narration for the transaction.
|
|
261
|
-
* @param data.network -
|
|
268
|
+
* @param data.network - Blockchain network; required for on-chain withdrawals.
|
|
262
269
|
* @returns A promise resolving to the created Withdrawal object.
|
|
263
270
|
*/
|
|
264
271
|
async create(userId, data) {
|
|
@@ -477,14 +484,16 @@ var SwapModule = class {
|
|
|
477
484
|
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/confirm`);
|
|
478
485
|
}
|
|
479
486
|
/**
|
|
480
|
-
* Refreshes an
|
|
487
|
+
* Refreshes an Instant Swap quotation to get updated market rates.
|
|
488
|
+
* In Quidax 3.0 a quotation can only be refreshed if it has expired or the value changes.
|
|
481
489
|
*
|
|
482
490
|
* @param userId - The unique ID of the user.
|
|
483
|
-
* @param quotationId - The ID of the
|
|
491
|
+
* @param quotationId - The ID of the swap quotation.
|
|
492
|
+
* @param data - Optional updated quotation values.
|
|
484
493
|
* @returns A promise resolving to the refreshed SwapTransaction.
|
|
485
494
|
*/
|
|
486
|
-
async refresh(userId, quotationId) {
|
|
487
|
-
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/refresh
|
|
495
|
+
async refresh(userId, quotationId, data) {
|
|
496
|
+
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/refresh`, data);
|
|
488
497
|
}
|
|
489
498
|
/**
|
|
490
499
|
* Fetches the details of a specific Swap Transaction.
|
|
@@ -713,7 +722,7 @@ var RampModule = class {
|
|
|
713
722
|
* ```typescript
|
|
714
723
|
* import Quidax from 'quidax-node';
|
|
715
724
|
*
|
|
716
|
-
* const quidax = new Quidax({
|
|
725
|
+
* const quidax = new Quidax({ apiKey: 'your_api_key' });
|
|
717
726
|
* const me = await quidax.users.getParentAccount();
|
|
718
727
|
* ```
|
|
719
728
|
*/
|
package/dist/index.d.cts
CHANGED
|
@@ -3,9 +3,15 @@ import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
|
3
3
|
//#region src/client.d.ts
|
|
4
4
|
interface QuidaxClientConfig {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Your Quidax 3.0 API key, generated under "My Account" > "API Management" in the
|
|
7
|
+
* Quidax 3.0 web app. IP whitelisting is mandatory for these keys.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Since Quidax 3.0 you must pass the API key, not the secret key. Use `apiKey` instead.
|
|
12
|
+
* Still accepted for backwards compatibility and sent the same way as `apiKey`.
|
|
13
|
+
*/
|
|
14
|
+
secretKey?: string;
|
|
9
15
|
/**
|
|
10
16
|
* Base URL for the primary Exchange APIs (default: https://openapi.quidax.io/exchange-open-api/api/v1)
|
|
11
17
|
*/
|
|
@@ -54,7 +60,19 @@ interface PaginationMeta {
|
|
|
54
60
|
interface PaginatedResponse<T> extends QuidaxResponse<T[]> {
|
|
55
61
|
meta: PaginationMeta;
|
|
56
62
|
}
|
|
57
|
-
type Currency = 'btc' | 'ltc' | 'eth' | 'usdt' | 'xrp' | 'dash' | 'trx' | 'doge' | 'usdc' | 'ngn' | 'usd' | string;
|
|
63
|
+
type Currency = 'btc' | 'ltc' | 'eth' | 'usdt' | 'xrp' | 'dash' | 'trx' | 'doge' | 'usdc' | 'sol' | 'bnb' | 'ton' | 'xlm' | 'cngn' | 'ngn' | 'usd' | string;
|
|
64
|
+
/**
|
|
65
|
+
* Blockchain network identifier (e.g. 'bitcoin', 'bep20', 'erc20', 'trc20').
|
|
66
|
+
* Use `wallets.getOne` / `wallets.getAll` to see the networks each asset supports.
|
|
67
|
+
*/
|
|
68
|
+
type Network = string;
|
|
69
|
+
interface WalletNetwork {
|
|
70
|
+
id: Network;
|
|
71
|
+
name: string;
|
|
72
|
+
deposits_enabled: boolean;
|
|
73
|
+
withdraws_enabled: boolean;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
}
|
|
58
76
|
interface User {
|
|
59
77
|
id: string;
|
|
60
78
|
sn: string;
|
|
@@ -72,6 +90,9 @@ interface Wallet {
|
|
|
72
90
|
balance: string;
|
|
73
91
|
locked: string;
|
|
74
92
|
staked: string;
|
|
93
|
+
blockchain_enabled?: boolean;
|
|
94
|
+
default_network?: Network | null;
|
|
95
|
+
networks?: WalletNetwork[];
|
|
75
96
|
user: {
|
|
76
97
|
id: string;
|
|
77
98
|
sn: string;
|
|
@@ -84,6 +105,7 @@ interface PaymentAddress {
|
|
|
84
105
|
reference: string;
|
|
85
106
|
currency: Currency;
|
|
86
107
|
address: string;
|
|
108
|
+
network?: Network | null;
|
|
87
109
|
destination_tag: string | null;
|
|
88
110
|
total_payments: number;
|
|
89
111
|
created_at: string;
|
|
@@ -191,12 +213,15 @@ declare class WalletsModule {
|
|
|
191
213
|
getPaymentAddressById(userId: string, currency: Currency, addressId: string): Promise<QuidaxResponse<PaymentAddress>>;
|
|
192
214
|
/**
|
|
193
215
|
* Generates a new Payment Address for a cryptocurrency wallet.
|
|
216
|
+
* In Quidax 3.0 the network is mandatory and the address is generated immediately.
|
|
194
217
|
*
|
|
195
218
|
* @param userId - The unique ID of the user.
|
|
196
|
-
* @param currency - The cryptocurrency ticker (e.g., 'btc', '
|
|
219
|
+
* @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
|
|
220
|
+
* @param network - The blockchain network (e.g., 'bitcoin', 'bep20', 'trc20').
|
|
221
|
+
* Use `getOne`/`getAll` to see the networks a currency supports.
|
|
197
222
|
* @returns A promise resolving to the newly generated PaymentAddress object.
|
|
198
223
|
*/
|
|
199
|
-
createPaymentAddress(userId: string, currency: Currency, network:
|
|
224
|
+
createPaymentAddress(userId: string, currency: Currency, network: Network): Promise<QuidaxResponse<PaymentAddress>>;
|
|
200
225
|
}
|
|
201
226
|
//#endregion
|
|
202
227
|
//#region src/modules/withdrawals.d.ts
|
|
@@ -246,21 +271,25 @@ declare class WithdrawalsModule {
|
|
|
246
271
|
* @param data - The withdrawal details.
|
|
247
272
|
* @param data.currency - The cryptocurrency ticker (e.g., 'btc').
|
|
248
273
|
* @param data.amount - The amount to withdraw.
|
|
249
|
-
* @param data.fund_uid - The ID of
|
|
274
|
+
* @param data.fund_uid - The ID of a sub-user or a crypto address.
|
|
275
|
+
* @param data.fund_uid2 - Destination tag/memo (e.g. for XRP, XLM).
|
|
250
276
|
* @param data.transaction_note - Optional note for the transaction.
|
|
251
|
-
* @param data.reference -
|
|
277
|
+
* @param data.reference - Unique reference for the withdrawal (required in v3.0).
|
|
278
|
+
* If this call fails, fetch the withdrawal with `getByReference` before retrying,
|
|
279
|
+
* as it may already have been processed.
|
|
252
280
|
* @param data.narration - Optional narration for the transaction.
|
|
253
|
-
* @param data.network -
|
|
281
|
+
* @param data.network - Blockchain network; required for on-chain withdrawals.
|
|
254
282
|
* @returns A promise resolving to the created Withdrawal object.
|
|
255
283
|
*/
|
|
256
284
|
create(userId: string, data: {
|
|
257
285
|
currency: Currency;
|
|
258
286
|
amount: string;
|
|
259
287
|
fund_uid: string;
|
|
288
|
+
fund_uid2?: string;
|
|
260
289
|
transaction_note?: string;
|
|
261
|
-
reference
|
|
290
|
+
reference: string;
|
|
262
291
|
narration?: string;
|
|
263
|
-
network?:
|
|
292
|
+
network?: Network;
|
|
264
293
|
}): Promise<QuidaxResponse<Withdrawal>>;
|
|
265
294
|
/**
|
|
266
295
|
* Initiates a new ngn withdrawal to merchant.
|
|
@@ -475,10 +504,23 @@ interface SwapTransaction {
|
|
|
475
504
|
destination_amount: string;
|
|
476
505
|
exchange_rate: string;
|
|
477
506
|
fee: string;
|
|
478
|
-
status:
|
|
507
|
+
status: SwapStatus;
|
|
479
508
|
created_at: string;
|
|
480
509
|
updated_at: string;
|
|
481
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* Swap transaction status. `failed` was added in Quidax 3.0
|
|
513
|
+
* (webhook event: `swap_transaction.failed`).
|
|
514
|
+
*/
|
|
515
|
+
type SwapStatus = "initiated" | "completed" | "failed" | (string & {});
|
|
516
|
+
interface SwapRefreshParams {
|
|
517
|
+
from_currency?: Currency;
|
|
518
|
+
to_currency?: Currency;
|
|
519
|
+
/** Provide either `from_amount` or `to_amount`, not both. */
|
|
520
|
+
from_amount?: string;
|
|
521
|
+
/** Provide either `from_amount` or `to_amount`, not both. */
|
|
522
|
+
to_amount?: string;
|
|
523
|
+
}
|
|
482
524
|
declare class SwapModule {
|
|
483
525
|
private client;
|
|
484
526
|
constructor(client: BaseClient);
|
|
@@ -493,7 +535,7 @@ declare class SwapModule {
|
|
|
493
535
|
from_currency: Currency;
|
|
494
536
|
to_currency: Currency;
|
|
495
537
|
from_amount: string;
|
|
496
|
-
to_amount
|
|
538
|
+
to_amount?: string;
|
|
497
539
|
}): Promise<QuidaxResponse<any>>;
|
|
498
540
|
/**
|
|
499
541
|
* Creates an Instant Swap quotation linked to the user account.
|
|
@@ -517,13 +559,15 @@ declare class SwapModule {
|
|
|
517
559
|
*/
|
|
518
560
|
confirm(userId: string, quotationId: string): Promise<QuidaxResponse<SwapTransaction>>;
|
|
519
561
|
/**
|
|
520
|
-
* Refreshes an
|
|
562
|
+
* Refreshes an Instant Swap quotation to get updated market rates.
|
|
563
|
+
* In Quidax 3.0 a quotation can only be refreshed if it has expired or the value changes.
|
|
521
564
|
*
|
|
522
565
|
* @param userId - The unique ID of the user.
|
|
523
|
-
* @param quotationId - The ID of the
|
|
566
|
+
* @param quotationId - The ID of the swap quotation.
|
|
567
|
+
* @param data - Optional updated quotation values.
|
|
524
568
|
* @returns A promise resolving to the refreshed SwapTransaction.
|
|
525
569
|
*/
|
|
526
|
-
refresh(userId: string, quotationId: string): Promise<QuidaxResponse<SwapTransaction>>;
|
|
570
|
+
refresh(userId: string, quotationId: string, data?: SwapRefreshParams): Promise<QuidaxResponse<SwapTransaction>>;
|
|
527
571
|
/**
|
|
528
572
|
* Fetches the details of a specific Swap Transaction.
|
|
529
573
|
*
|
|
@@ -736,7 +780,7 @@ declare class QuidaxError extends Error {
|
|
|
736
780
|
* ```typescript
|
|
737
781
|
* import Quidax from 'quidax-node';
|
|
738
782
|
*
|
|
739
|
-
* const quidax = new Quidax({
|
|
783
|
+
* const quidax = new Quidax({ apiKey: 'your_api_key' });
|
|
740
784
|
* const me = await quidax.users.getParentAccount();
|
|
741
785
|
* ```
|
|
742
786
|
*/
|
|
@@ -785,4 +829,4 @@ declare class Quidax {
|
|
|
785
829
|
constructor(config: QuidaxClientConfig);
|
|
786
830
|
}
|
|
787
831
|
//#endregion
|
|
788
|
-
export { BaseClient, Currency, Deposit, DepositsModule, FeesModule, Market, MarketsModule, Order, OrderBook, OrdersModule, PaginatedResponse, PaginationMeta, PaymentAddress, Quidax, Quidax as default, QuidaxClientConfig, QuidaxError, QuidaxResponse, RampModule, SwapModule, SwapTransaction, Ticker, Trade, TradesModule, User, UsersModule, Wallet, WalletsModule, Withdrawal, WithdrawalsModule };
|
|
832
|
+
export { BaseClient, Currency, Deposit, DepositsModule, FeesModule, Market, MarketsModule, Network, Order, OrderBook, OrdersModule, PaginatedResponse, PaginationMeta, PaymentAddress, Quidax, Quidax as default, QuidaxClientConfig, QuidaxError, QuidaxResponse, RampModule, SwapModule, SwapRefreshParams, SwapStatus, SwapTransaction, Ticker, Trade, TradesModule, User, UsersModule, Wallet, WalletNetwork, WalletsModule, Withdrawal, WithdrawalsModule };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,9 +3,15 @@ import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
|
3
3
|
//#region src/client.d.ts
|
|
4
4
|
interface QuidaxClientConfig {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Your Quidax 3.0 API key, generated under "My Account" > "API Management" in the
|
|
7
|
+
* Quidax 3.0 web app. IP whitelisting is mandatory for these keys.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Since Quidax 3.0 you must pass the API key, not the secret key. Use `apiKey` instead.
|
|
12
|
+
* Still accepted for backwards compatibility and sent the same way as `apiKey`.
|
|
13
|
+
*/
|
|
14
|
+
secretKey?: string;
|
|
9
15
|
/**
|
|
10
16
|
* Base URL for the primary Exchange APIs (default: https://openapi.quidax.io/exchange-open-api/api/v1)
|
|
11
17
|
*/
|
|
@@ -54,7 +60,19 @@ interface PaginationMeta {
|
|
|
54
60
|
interface PaginatedResponse<T> extends QuidaxResponse<T[]> {
|
|
55
61
|
meta: PaginationMeta;
|
|
56
62
|
}
|
|
57
|
-
type Currency = 'btc' | 'ltc' | 'eth' | 'usdt' | 'xrp' | 'dash' | 'trx' | 'doge' | 'usdc' | 'ngn' | 'usd' | string;
|
|
63
|
+
type Currency = 'btc' | 'ltc' | 'eth' | 'usdt' | 'xrp' | 'dash' | 'trx' | 'doge' | 'usdc' | 'sol' | 'bnb' | 'ton' | 'xlm' | 'cngn' | 'ngn' | 'usd' | string;
|
|
64
|
+
/**
|
|
65
|
+
* Blockchain network identifier (e.g. 'bitcoin', 'bep20', 'erc20', 'trc20').
|
|
66
|
+
* Use `wallets.getOne` / `wallets.getAll` to see the networks each asset supports.
|
|
67
|
+
*/
|
|
68
|
+
type Network = string;
|
|
69
|
+
interface WalletNetwork {
|
|
70
|
+
id: Network;
|
|
71
|
+
name: string;
|
|
72
|
+
deposits_enabled: boolean;
|
|
73
|
+
withdraws_enabled: boolean;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
}
|
|
58
76
|
interface User {
|
|
59
77
|
id: string;
|
|
60
78
|
sn: string;
|
|
@@ -72,6 +90,9 @@ interface Wallet {
|
|
|
72
90
|
balance: string;
|
|
73
91
|
locked: string;
|
|
74
92
|
staked: string;
|
|
93
|
+
blockchain_enabled?: boolean;
|
|
94
|
+
default_network?: Network | null;
|
|
95
|
+
networks?: WalletNetwork[];
|
|
75
96
|
user: {
|
|
76
97
|
id: string;
|
|
77
98
|
sn: string;
|
|
@@ -84,6 +105,7 @@ interface PaymentAddress {
|
|
|
84
105
|
reference: string;
|
|
85
106
|
currency: Currency;
|
|
86
107
|
address: string;
|
|
108
|
+
network?: Network | null;
|
|
87
109
|
destination_tag: string | null;
|
|
88
110
|
total_payments: number;
|
|
89
111
|
created_at: string;
|
|
@@ -191,12 +213,15 @@ declare class WalletsModule {
|
|
|
191
213
|
getPaymentAddressById(userId: string, currency: Currency, addressId: string): Promise<QuidaxResponse<PaymentAddress>>;
|
|
192
214
|
/**
|
|
193
215
|
* Generates a new Payment Address for a cryptocurrency wallet.
|
|
216
|
+
* In Quidax 3.0 the network is mandatory and the address is generated immediately.
|
|
194
217
|
*
|
|
195
218
|
* @param userId - The unique ID of the user.
|
|
196
|
-
* @param currency - The cryptocurrency ticker (e.g., 'btc', '
|
|
219
|
+
* @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
|
|
220
|
+
* @param network - The blockchain network (e.g., 'bitcoin', 'bep20', 'trc20').
|
|
221
|
+
* Use `getOne`/`getAll` to see the networks a currency supports.
|
|
197
222
|
* @returns A promise resolving to the newly generated PaymentAddress object.
|
|
198
223
|
*/
|
|
199
|
-
createPaymentAddress(userId: string, currency: Currency, network:
|
|
224
|
+
createPaymentAddress(userId: string, currency: Currency, network: Network): Promise<QuidaxResponse<PaymentAddress>>;
|
|
200
225
|
}
|
|
201
226
|
//#endregion
|
|
202
227
|
//#region src/modules/withdrawals.d.ts
|
|
@@ -246,21 +271,25 @@ declare class WithdrawalsModule {
|
|
|
246
271
|
* @param data - The withdrawal details.
|
|
247
272
|
* @param data.currency - The cryptocurrency ticker (e.g., 'btc').
|
|
248
273
|
* @param data.amount - The amount to withdraw.
|
|
249
|
-
* @param data.fund_uid - The ID of
|
|
274
|
+
* @param data.fund_uid - The ID of a sub-user or a crypto address.
|
|
275
|
+
* @param data.fund_uid2 - Destination tag/memo (e.g. for XRP, XLM).
|
|
250
276
|
* @param data.transaction_note - Optional note for the transaction.
|
|
251
|
-
* @param data.reference -
|
|
277
|
+
* @param data.reference - Unique reference for the withdrawal (required in v3.0).
|
|
278
|
+
* If this call fails, fetch the withdrawal with `getByReference` before retrying,
|
|
279
|
+
* as it may already have been processed.
|
|
252
280
|
* @param data.narration - Optional narration for the transaction.
|
|
253
|
-
* @param data.network -
|
|
281
|
+
* @param data.network - Blockchain network; required for on-chain withdrawals.
|
|
254
282
|
* @returns A promise resolving to the created Withdrawal object.
|
|
255
283
|
*/
|
|
256
284
|
create(userId: string, data: {
|
|
257
285
|
currency: Currency;
|
|
258
286
|
amount: string;
|
|
259
287
|
fund_uid: string;
|
|
288
|
+
fund_uid2?: string;
|
|
260
289
|
transaction_note?: string;
|
|
261
|
-
reference
|
|
290
|
+
reference: string;
|
|
262
291
|
narration?: string;
|
|
263
|
-
network?:
|
|
292
|
+
network?: Network;
|
|
264
293
|
}): Promise<QuidaxResponse<Withdrawal>>;
|
|
265
294
|
/**
|
|
266
295
|
* Initiates a new ngn withdrawal to merchant.
|
|
@@ -475,10 +504,23 @@ interface SwapTransaction {
|
|
|
475
504
|
destination_amount: string;
|
|
476
505
|
exchange_rate: string;
|
|
477
506
|
fee: string;
|
|
478
|
-
status:
|
|
507
|
+
status: SwapStatus;
|
|
479
508
|
created_at: string;
|
|
480
509
|
updated_at: string;
|
|
481
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* Swap transaction status. `failed` was added in Quidax 3.0
|
|
513
|
+
* (webhook event: `swap_transaction.failed`).
|
|
514
|
+
*/
|
|
515
|
+
type SwapStatus = "initiated" | "completed" | "failed" | (string & {});
|
|
516
|
+
interface SwapRefreshParams {
|
|
517
|
+
from_currency?: Currency;
|
|
518
|
+
to_currency?: Currency;
|
|
519
|
+
/** Provide either `from_amount` or `to_amount`, not both. */
|
|
520
|
+
from_amount?: string;
|
|
521
|
+
/** Provide either `from_amount` or `to_amount`, not both. */
|
|
522
|
+
to_amount?: string;
|
|
523
|
+
}
|
|
482
524
|
declare class SwapModule {
|
|
483
525
|
private client;
|
|
484
526
|
constructor(client: BaseClient);
|
|
@@ -493,7 +535,7 @@ declare class SwapModule {
|
|
|
493
535
|
from_currency: Currency;
|
|
494
536
|
to_currency: Currency;
|
|
495
537
|
from_amount: string;
|
|
496
|
-
to_amount
|
|
538
|
+
to_amount?: string;
|
|
497
539
|
}): Promise<QuidaxResponse<any>>;
|
|
498
540
|
/**
|
|
499
541
|
* Creates an Instant Swap quotation linked to the user account.
|
|
@@ -517,13 +559,15 @@ declare class SwapModule {
|
|
|
517
559
|
*/
|
|
518
560
|
confirm(userId: string, quotationId: string): Promise<QuidaxResponse<SwapTransaction>>;
|
|
519
561
|
/**
|
|
520
|
-
* Refreshes an
|
|
562
|
+
* Refreshes an Instant Swap quotation to get updated market rates.
|
|
563
|
+
* In Quidax 3.0 a quotation can only be refreshed if it has expired or the value changes.
|
|
521
564
|
*
|
|
522
565
|
* @param userId - The unique ID of the user.
|
|
523
|
-
* @param quotationId - The ID of the
|
|
566
|
+
* @param quotationId - The ID of the swap quotation.
|
|
567
|
+
* @param data - Optional updated quotation values.
|
|
524
568
|
* @returns A promise resolving to the refreshed SwapTransaction.
|
|
525
569
|
*/
|
|
526
|
-
refresh(userId: string, quotationId: string): Promise<QuidaxResponse<SwapTransaction>>;
|
|
570
|
+
refresh(userId: string, quotationId: string, data?: SwapRefreshParams): Promise<QuidaxResponse<SwapTransaction>>;
|
|
527
571
|
/**
|
|
528
572
|
* Fetches the details of a specific Swap Transaction.
|
|
529
573
|
*
|
|
@@ -736,7 +780,7 @@ declare class QuidaxError extends Error {
|
|
|
736
780
|
* ```typescript
|
|
737
781
|
* import Quidax from 'quidax-node';
|
|
738
782
|
*
|
|
739
|
-
* const quidax = new Quidax({
|
|
783
|
+
* const quidax = new Quidax({ apiKey: 'your_api_key' });
|
|
740
784
|
* const me = await quidax.users.getParentAccount();
|
|
741
785
|
* ```
|
|
742
786
|
*/
|
|
@@ -785,4 +829,4 @@ declare class Quidax {
|
|
|
785
829
|
constructor(config: QuidaxClientConfig);
|
|
786
830
|
}
|
|
787
831
|
//#endregion
|
|
788
|
-
export { BaseClient, Currency, Deposit, DepositsModule, FeesModule, Market, MarketsModule, Order, OrderBook, OrdersModule, PaginatedResponse, PaginationMeta, PaymentAddress, Quidax, Quidax as default, QuidaxClientConfig, QuidaxError, QuidaxResponse, RampModule, SwapModule, SwapTransaction, Ticker, Trade, TradesModule, User, UsersModule, Wallet, WalletsModule, Withdrawal, WithdrawalsModule };
|
|
832
|
+
export { BaseClient, Currency, Deposit, DepositsModule, FeesModule, Market, MarketsModule, Network, Order, OrderBook, OrdersModule, PaginatedResponse, PaginationMeta, PaymentAddress, Quidax, Quidax as default, QuidaxClientConfig, QuidaxError, QuidaxResponse, RampModule, SwapModule, SwapRefreshParams, SwapStatus, SwapTransaction, Ticker, Trade, TradesModule, User, UsersModule, Wallet, WalletNetwork, WalletsModule, Withdrawal, WithdrawalsModule };
|
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
|
});
|
|
@@ -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 `getOne`/`getAll` 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
|
|
@@ -227,11 +231,14 @@ 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 `getByReference` 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
244
|
async create(userId, data) {
|
|
@@ -450,14 +457,16 @@ var SwapModule = class {
|
|
|
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 refresh(userId, quotationId) {
|
|
460
|
-
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/refresh
|
|
468
|
+
async refresh(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.
|
|
@@ -686,7 +695,7 @@ var RampModule = class {
|
|
|
686
695
|
* ```typescript
|
|
687
696
|
* import Quidax from 'quidax-node';
|
|
688
697
|
*
|
|
689
|
-
* const quidax = new Quidax({
|
|
698
|
+
* const quidax = new Quidax({ apiKey: 'your_api_key' });
|
|
690
699
|
* const me = await quidax.users.getParentAccount();
|
|
691
700
|
* ```
|
|
692
701
|
*/
|