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/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
|
|
@@ -40,10 +42,10 @@ The SDK is organized into intuitive, feature-based modules.
|
|
|
40
42
|
Manage parent and sub-accounts.
|
|
41
43
|
```typescript
|
|
42
44
|
// Fetch parent account details
|
|
43
|
-
const parentAccount = await quidax.users.
|
|
45
|
+
const parentAccount = await quidax.users.getMe();
|
|
44
46
|
|
|
45
47
|
// Create a sub-account
|
|
46
|
-
const subAccount = await quidax.users.
|
|
48
|
+
const subAccount = await quidax.users.createSubAccount({
|
|
47
49
|
email: 'user@example.com',
|
|
48
50
|
first_name: 'John',
|
|
49
51
|
last_name: 'Doe'
|
|
@@ -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
|
|
57
|
-
const wallets = await quidax.wallets.
|
|
58
|
+
// Fetch all wallets for a specific user (each wallet lists its supported `networks`)
|
|
59
|
+
const wallets = await quidax.wallets.listWallets('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
|
|
@@ -74,29 +77,52 @@ const ticker = await quidax.markets.getTicker('btcngn');
|
|
|
74
77
|
Track deposits and process withdrawals.
|
|
75
78
|
```typescript
|
|
76
79
|
// Fetch all deposits for a user
|
|
77
|
-
const deposits = await quidax.deposits.
|
|
78
|
-
|
|
79
|
-
// Process a crypto withdrawal
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
const deposits = await quidax.deposits.listDeposits('user_id');
|
|
81
|
+
|
|
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.createWithdrawal('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.getWithdrawalByReference('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.getDeposit`, `swap.getSwapTransaction` and `withdrawals.getWithdrawalByReference`.
|
|
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.previewQuotation('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.createQuotation('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.
|
|
119
|
+
const swap = await quidax.swap.confirmQuotation('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.refreshQuotation('user_id', quotation.data.id, { from_amount: '0.02' });
|
|
100
126
|
```
|
|
101
127
|
|
|
102
128
|
### 6. Ramp & Custodial
|
|
@@ -113,6 +139,47 @@ const quote = await quidax.ramp.getBuyQuote({
|
|
|
113
139
|
});
|
|
114
140
|
```
|
|
115
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
|
+
|
|
116
183
|
## Error Handling
|
|
117
184
|
|
|
118
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`.
|
|
@@ -122,7 +189,7 @@ import { Quidax, QuidaxError } from 'quidax-node';
|
|
|
122
189
|
|
|
123
190
|
async function processPayment() {
|
|
124
191
|
try {
|
|
125
|
-
const address = await quidax.wallets.createPaymentAddress('invalid_user', 'btc');
|
|
192
|
+
const address = await quidax.wallets.createPaymentAddress('invalid_user', 'btc', 'bitcoin');
|
|
126
193
|
} catch (error) {
|
|
127
194
|
if (error instanceof QuidaxError) {
|
|
128
195
|
console.error(`HTTP Status: ${error.statusCode}`); // e.g., 400 or 401
|
|
@@ -141,9 +208,9 @@ async function processPayment() {
|
|
|
141
208
|
|
|
142
209
|
## TypeScript Support
|
|
143
210
|
|
|
144
|
-
This project is written entirely in **TypeScript** and compiled using `
|
|
211
|
+
This project is written entirely in **TypeScript** and compiled using `tsdown`.
|
|
145
212
|
- It natively supports both **CommonJS** (`require`) and **ESModules** (`import`).
|
|
146
213
|
- 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
214
|
|
|
148
215
|
## License
|
|
149
|
-
|
|
216
|
+
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
|
});
|
|
@@ -105,7 +106,7 @@ var UsersModule = class {
|
|
|
105
106
|
* @returns A promise resolving to the created User object.
|
|
106
107
|
* @throws {QuidaxError} If validation fails or email already exists.
|
|
107
108
|
*/
|
|
108
|
-
async
|
|
109
|
+
async createSubAccount(data) {
|
|
109
110
|
return this.client.post("/users", data);
|
|
110
111
|
}
|
|
111
112
|
/**
|
|
@@ -113,7 +114,7 @@ var UsersModule = class {
|
|
|
113
114
|
*
|
|
114
115
|
* @returns A promise resolving to the Parent User object.
|
|
115
116
|
*/
|
|
116
|
-
async
|
|
117
|
+
async getMe() {
|
|
117
118
|
return this.client.get("/users/me");
|
|
118
119
|
}
|
|
119
120
|
/**
|
|
@@ -123,7 +124,7 @@ var UsersModule = class {
|
|
|
123
124
|
* @param data - The data to update.
|
|
124
125
|
* @returns A promise resolving to the updated User object.
|
|
125
126
|
*/
|
|
126
|
-
async
|
|
127
|
+
async updateSubAccount(userId, data) {
|
|
127
128
|
return this.client.put(`/users/${userId}`, data);
|
|
128
129
|
}
|
|
129
130
|
/**
|
|
@@ -131,7 +132,7 @@ var UsersModule = class {
|
|
|
131
132
|
*
|
|
132
133
|
* @returns A promise resolving to a list of User objects.
|
|
133
134
|
*/
|
|
134
|
-
async
|
|
135
|
+
async listSubAccounts() {
|
|
135
136
|
return this.client.get("/users");
|
|
136
137
|
}
|
|
137
138
|
/**
|
|
@@ -141,7 +142,7 @@ var UsersModule = class {
|
|
|
141
142
|
* @returns A promise resolving to the User object.
|
|
142
143
|
* @throws {QuidaxError} If the user is not found.
|
|
143
144
|
*/
|
|
144
|
-
async
|
|
145
|
+
async getSubAccount(userId) {
|
|
145
146
|
return this.client.get(`/users/${userId}`);
|
|
146
147
|
}
|
|
147
148
|
};
|
|
@@ -157,7 +158,7 @@ var WalletsModule = class {
|
|
|
157
158
|
* @param userId - The unique ID of the user. 'me' can be used for the authenticated user.
|
|
158
159
|
* @returns A promise resolving to an array of Wallet objects.
|
|
159
160
|
*/
|
|
160
|
-
async
|
|
161
|
+
async listWallets(userId) {
|
|
161
162
|
return this.client.get(`/users/${userId}/wallets`);
|
|
162
163
|
}
|
|
163
164
|
/**
|
|
@@ -167,7 +168,7 @@ var WalletsModule = class {
|
|
|
167
168
|
* @param currency - The cryptocurrency ticker (e.g., 'btc', 'usdt').
|
|
168
169
|
* @returns A promise resolving to a single Wallet object.
|
|
169
170
|
*/
|
|
170
|
-
async
|
|
171
|
+
async getWallet(userId, currency) {
|
|
171
172
|
return this.client.get(`/users/${userId}/wallets/${currency}`);
|
|
172
173
|
}
|
|
173
174
|
/**
|
|
@@ -187,7 +188,7 @@ var WalletsModule = class {
|
|
|
187
188
|
* @param currency - The cryptocurrency ticker.
|
|
188
189
|
* @returns A promise resolving to an array of PaymentAddress objects.
|
|
189
190
|
*/
|
|
190
|
-
async
|
|
191
|
+
async listPaymentAddresses(userId, currency) {
|
|
191
192
|
return this.client.get(`/users/${userId}/wallets/${currency}/addresses`);
|
|
192
193
|
}
|
|
193
194
|
/**
|
|
@@ -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 `getWallet`/`listWallets` 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
|
|
@@ -224,7 +228,7 @@ var WithdrawalsModule = class {
|
|
|
224
228
|
* @param userId - The unique ID of the user.
|
|
225
229
|
* @returns A promise resolving to a paginated list of Withdrawal objects.
|
|
226
230
|
*/
|
|
227
|
-
async
|
|
231
|
+
async listWithdrawals(userId) {
|
|
228
232
|
return this.client.get(`/users/${userId}/withdraws`);
|
|
229
233
|
}
|
|
230
234
|
/**
|
|
@@ -234,7 +238,7 @@ var WithdrawalsModule = class {
|
|
|
234
238
|
* @param withdrawalId - The ID of the withdrawal to retrieve.
|
|
235
239
|
* @returns A promise resolving to a single Withdrawal object.
|
|
236
240
|
*/
|
|
237
|
-
async
|
|
241
|
+
async getWithdrawal(userId, withdrawalId) {
|
|
238
242
|
return this.client.get(`/users/${userId}/withdraws/${withdrawalId}`);
|
|
239
243
|
}
|
|
240
244
|
/**
|
|
@@ -244,7 +248,7 @@ var WithdrawalsModule = class {
|
|
|
244
248
|
* @param reference - The withdrawal reference string.
|
|
245
249
|
* @returns A promise resolving to a single Withdrawal object.
|
|
246
250
|
*/
|
|
247
|
-
async
|
|
251
|
+
async getWithdrawalByReference(userId, reference) {
|
|
248
252
|
return this.client.get(`/users/${userId}/withdraws/reference/${reference}`);
|
|
249
253
|
}
|
|
250
254
|
/**
|
|
@@ -254,14 +258,17 @@ 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 `getWithdrawalByReference` 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
|
-
async
|
|
271
|
+
async createWithdrawal(userId, data) {
|
|
265
272
|
return this.client.post(`/users/${userId}/withdraws`, data);
|
|
266
273
|
}
|
|
267
274
|
/**
|
|
@@ -273,7 +280,7 @@ var WithdrawalsModule = class {
|
|
|
273
280
|
* @param reference - The withdrawal reference string.
|
|
274
281
|
* @returns A promise resolving to the created Withdrawal object.
|
|
275
282
|
*/
|
|
276
|
-
async
|
|
283
|
+
async createNgnMerchantWithdrawal(userId, amount, merchantId, reference) {
|
|
277
284
|
const payload = {
|
|
278
285
|
currency: "ngn",
|
|
279
286
|
amount,
|
|
@@ -291,7 +298,7 @@ var WithdrawalsModule = class {
|
|
|
291
298
|
* @param withdrawalId - The ID of the withdrawal to cancel.
|
|
292
299
|
* @returns A promise resolving to the canceled Withdrawal object.
|
|
293
300
|
*/
|
|
294
|
-
async
|
|
301
|
+
async cancelWithdrawal(userId, withdrawalId) {
|
|
295
302
|
return this.client.post(`/users/${userId}/withdraws/${withdrawalId}/cancel`);
|
|
296
303
|
}
|
|
297
304
|
};
|
|
@@ -306,7 +313,7 @@ var MarketsModule = class {
|
|
|
306
313
|
*
|
|
307
314
|
* @returns A promise resolving to an array of Market objects.
|
|
308
315
|
*/
|
|
309
|
-
async
|
|
316
|
+
async listMarkets() {
|
|
310
317
|
return this.client.get("/markets");
|
|
311
318
|
}
|
|
312
319
|
/**
|
|
@@ -320,11 +327,11 @@ var MarketsModule = class {
|
|
|
320
327
|
/**
|
|
321
328
|
* Retrieves the current ticker data for a specific market.
|
|
322
329
|
*
|
|
323
|
-
* @param
|
|
330
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
324
331
|
* @returns A promise resolving to the Ticker data.
|
|
325
332
|
*/
|
|
326
|
-
async getTicker(
|
|
327
|
-
return this.client.get(`/markets/tickers/${
|
|
333
|
+
async getTicker(market) {
|
|
334
|
+
return this.client.get(`/markets/tickers/${market}`);
|
|
328
335
|
}
|
|
329
336
|
/**
|
|
330
337
|
* Retrieves candlestick (k-line) data for a specific market.
|
|
@@ -336,39 +343,39 @@ var MarketsModule = class {
|
|
|
336
343
|
* @param params.timestamp - Starting timestamp.
|
|
337
344
|
* @returns A promise resolving to an array of k-line data points.
|
|
338
345
|
*/
|
|
339
|
-
async
|
|
346
|
+
async getCandles(market, params) {
|
|
340
347
|
return this.client.get(`/markets/${market}/k`, { params });
|
|
341
348
|
}
|
|
342
349
|
/**
|
|
343
350
|
* Retrieves candlestick data including pending trades for a market.
|
|
344
351
|
*
|
|
345
|
-
* @param
|
|
352
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
346
353
|
* @param tradeId - The ID of the pending trade reference.
|
|
347
354
|
* @param params - Optional query parameters.
|
|
348
355
|
* @returns A promise resolving to an array of k-line data points.
|
|
349
356
|
*/
|
|
350
|
-
async
|
|
351
|
-
return this.client.get(`/markets/${
|
|
357
|
+
async getCandlesWithPendingTrades(market, tradeId, params) {
|
|
358
|
+
return this.client.get(`/markets/${market}/k_with_pending_trades/${tradeId}`, { params });
|
|
352
359
|
}
|
|
353
360
|
/**
|
|
354
361
|
* Retrieves the order book (asks and bids) for a specific market.
|
|
355
362
|
*
|
|
356
|
-
* @param
|
|
363
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
357
364
|
* @param params - Optional query parameters to limit asks and bids.
|
|
358
365
|
* @returns A promise resolving to the OrderBook object.
|
|
359
366
|
*/
|
|
360
|
-
async getOrderBook(
|
|
361
|
-
return this.client.get(`/markets/${
|
|
367
|
+
async getOrderBook(market, params) {
|
|
368
|
+
return this.client.get(`/markets/${market}/order_book`, { params });
|
|
362
369
|
}
|
|
363
370
|
/**
|
|
364
371
|
* Retrieves market depth data.
|
|
365
372
|
*
|
|
366
|
-
* @param
|
|
373
|
+
* @param market - The market pair (e.g., 'btcngn').
|
|
367
374
|
* @param params - Optional limit parameter.
|
|
368
375
|
* @returns A promise resolving to depth data.
|
|
369
376
|
*/
|
|
370
|
-
async getDepth(
|
|
371
|
-
return this.client.get(`/markets/${
|
|
377
|
+
async getDepth(market, params) {
|
|
378
|
+
return this.client.get(`/markets/${market}/depth`, { params });
|
|
372
379
|
}
|
|
373
380
|
/**
|
|
374
381
|
* Retrieves a high-level summary of all markets.
|
|
@@ -391,7 +398,7 @@ var TradesModule = class {
|
|
|
391
398
|
* @param userId - The unique ID of the user.
|
|
392
399
|
* @returns A promise resolving to a paginated list of Trade objects.
|
|
393
400
|
*/
|
|
394
|
-
async
|
|
401
|
+
async listUserTrades(userId) {
|
|
395
402
|
return this.client.get(`/users/${userId}/trades`);
|
|
396
403
|
}
|
|
397
404
|
/**
|
|
@@ -400,7 +407,7 @@ var TradesModule = class {
|
|
|
400
407
|
* @param marketPair - The market pair (e.g., 'btcngn').
|
|
401
408
|
* @returns A promise resolving to an array of Trade objects.
|
|
402
409
|
*/
|
|
403
|
-
async
|
|
410
|
+
async listMarketTrades(marketPair) {
|
|
404
411
|
return this.client.get(`/trades/${marketPair}`);
|
|
405
412
|
}
|
|
406
413
|
};
|
|
@@ -417,7 +424,7 @@ var DepositsModule = class {
|
|
|
417
424
|
* @param params - Optional filters (state, currency).
|
|
418
425
|
* @returns A promise resolving to a paginated list of Deposit objects.
|
|
419
426
|
*/
|
|
420
|
-
async
|
|
427
|
+
async listDeposits(userId, params) {
|
|
421
428
|
return this.client.get(`/users/${userId}/deposits`, { params });
|
|
422
429
|
}
|
|
423
430
|
/**
|
|
@@ -427,7 +434,7 @@ var DepositsModule = class {
|
|
|
427
434
|
* @param depositId - The unique ID of the deposit.
|
|
428
435
|
* @returns A promise resolving to a single Deposit object.
|
|
429
436
|
*/
|
|
430
|
-
async
|
|
437
|
+
async getDeposit(userId, depositId) {
|
|
431
438
|
return this.client.get(`/users/${userId}/deposits/${depositId}`);
|
|
432
439
|
}
|
|
433
440
|
/**
|
|
@@ -436,7 +443,7 @@ var DepositsModule = class {
|
|
|
436
443
|
* @param params - Optional filters (state, currency).
|
|
437
444
|
* @returns A promise resolving to a paginated list of Deposit objects.
|
|
438
445
|
*/
|
|
439
|
-
async
|
|
446
|
+
async listSubAccountDeposits(params) {
|
|
440
447
|
return this.client.get("/users/deposits/all", { params });
|
|
441
448
|
}
|
|
442
449
|
};
|
|
@@ -453,7 +460,7 @@ var SwapModule = class {
|
|
|
453
460
|
* @param data - The swap quotation parameters.
|
|
454
461
|
* @returns A promise resolving to the temporary swap quotation details.
|
|
455
462
|
*/
|
|
456
|
-
async
|
|
463
|
+
async previewQuotation(userId, data) {
|
|
457
464
|
return this.client.post(`/users/${userId}/temporary_swap_quotation`, data);
|
|
458
465
|
}
|
|
459
466
|
/**
|
|
@@ -463,7 +470,7 @@ var SwapModule = class {
|
|
|
463
470
|
* @param data - The swap creation payload.
|
|
464
471
|
* @returns A promise resolving to a SwapTransaction object in an unconfirmed state.
|
|
465
472
|
*/
|
|
466
|
-
async
|
|
473
|
+
async createQuotation(userId, data) {
|
|
467
474
|
return this.client.post(`/users/${userId}/swap_quotation`, data);
|
|
468
475
|
}
|
|
469
476
|
/**
|
|
@@ -473,18 +480,20 @@ var SwapModule = class {
|
|
|
473
480
|
* @param quotationId - The ID of the swap quotation to confirm.
|
|
474
481
|
* @returns A promise resolving to the confirmed SwapTransaction.
|
|
475
482
|
*/
|
|
476
|
-
async
|
|
483
|
+
async confirmQuotation(userId, quotationId) {
|
|
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
|
|
487
|
-
return this.client.post(`/users/${userId}/swap_quotation/${quotationId}/refresh
|
|
495
|
+
async refreshQuotation(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.
|
|
@@ -493,7 +502,7 @@ var SwapModule = class {
|
|
|
493
502
|
* @param swapTransactionId - The ID of the swap transaction.
|
|
494
503
|
* @returns A promise resolving to the SwapTransaction details.
|
|
495
504
|
*/
|
|
496
|
-
async
|
|
505
|
+
async getSwapTransaction(userId, swapTransactionId) {
|
|
497
506
|
return this.client.get(`/users/${userId}/swap_transactions/${swapTransactionId}`);
|
|
498
507
|
}
|
|
499
508
|
/**
|
|
@@ -502,7 +511,7 @@ var SwapModule = class {
|
|
|
502
511
|
* @param userId - The unique ID of the user.
|
|
503
512
|
* @returns A promise resolving to a paginated list of SwapTransactions.
|
|
504
513
|
*/
|
|
505
|
-
async
|
|
514
|
+
async listSwapTransactions(userId) {
|
|
506
515
|
return this.client.get(`/users/${userId}/swap_transactions`);
|
|
507
516
|
}
|
|
508
517
|
};
|
|
@@ -524,7 +533,7 @@ var OrdersModule = class {
|
|
|
524
533
|
* @param data.volume - The amount of cryptocurrency to buy or sell.
|
|
525
534
|
* @returns A promise resolving to the created Order object.
|
|
526
535
|
*/
|
|
527
|
-
async
|
|
536
|
+
async createOrder(userId, data) {
|
|
528
537
|
return this.client.post(`/users/${userId}/orders`, data);
|
|
529
538
|
}
|
|
530
539
|
/**
|
|
@@ -534,7 +543,7 @@ var OrdersModule = class {
|
|
|
534
543
|
* @param params - Optional filters (market, state, order_by).
|
|
535
544
|
* @returns A promise resolving to a paginated list of Order objects.
|
|
536
545
|
*/
|
|
537
|
-
async
|
|
546
|
+
async listOrders(userId, params) {
|
|
538
547
|
return this.client.get(`/users/${userId}/orders`, { params });
|
|
539
548
|
}
|
|
540
549
|
/**
|
|
@@ -544,7 +553,7 @@ var OrdersModule = class {
|
|
|
544
553
|
* @param orderId - The unique ID of the order.
|
|
545
554
|
* @returns A promise resolving to a single Order object.
|
|
546
555
|
*/
|
|
547
|
-
async
|
|
556
|
+
async getOrder(userId, orderId) {
|
|
548
557
|
return this.client.get(`/users/${userId}/orders/${orderId}`);
|
|
549
558
|
}
|
|
550
559
|
/**
|
|
@@ -554,7 +563,7 @@ var OrdersModule = class {
|
|
|
554
563
|
* @param orderId - The unique ID of the order to cancel.
|
|
555
564
|
* @returns A promise resolving to the canceled Order object.
|
|
556
565
|
*/
|
|
557
|
-
async
|
|
566
|
+
async cancelOrder(userId, orderId) {
|
|
558
567
|
return this.client.post(`/users/${userId}/orders/${orderId}/cancel`);
|
|
559
568
|
}
|
|
560
569
|
};
|
|
@@ -713,8 +722,8 @@ var RampModule = class {
|
|
|
713
722
|
* ```typescript
|
|
714
723
|
* import Quidax from 'quidax-node';
|
|
715
724
|
*
|
|
716
|
-
* const quidax = new Quidax({
|
|
717
|
-
* const me = await quidax.users.
|
|
725
|
+
* const quidax = new Quidax({ apiKey: 'your_api_key' });
|
|
726
|
+
* const me = await quidax.users.getMe();
|
|
718
727
|
* ```
|
|
719
728
|
*/
|
|
720
729
|
var Quidax = class {
|