quidax-node 3.0.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 +149 -0
- package/dist/index.cjs +767 -0
- package/dist/index.d.cts +772 -0
- package/dist/index.d.mts +772 -0
- package/dist/index.mjs +727 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Quidax Node.js SDK
|
|
2
|
+
|
|
3
|
+
A fully-typed, robust Node.js SDK for the [Quidax v3.0 API](https://docs.quidax.io/v3.0/reference). This SDK seamlessly integrates with both the Quidax Exchange APIs and the Quidax Ramp/Custodial APIs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install quidax-node
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Initialization
|
|
12
|
+
|
|
13
|
+
Initialize the Quidax client with your Secret Key:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Quidax } from 'quidax-node';
|
|
17
|
+
|
|
18
|
+
const quidax = new Quidax({
|
|
19
|
+
secretKey: 's_your_quidax_secret_key' // Keep this secure!
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Advanced Configuration
|
|
24
|
+
You can optionally pass custom Base URLs or adjust the timeout limit (default is 30,000ms).
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
const quidax = new Quidax({
|
|
28
|
+
secretKey: 's_your_quidax_secret_key',
|
|
29
|
+
exchangeBaseURL: 'https://openapi.quidax.io/exchange-open-api/api/v1',
|
|
30
|
+
rampBaseURL: 'https://ramp-be.quidax.io/api/v1',
|
|
31
|
+
timeout: 10000
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage Examples
|
|
36
|
+
|
|
37
|
+
The SDK is organized into intuitive, feature-based modules.
|
|
38
|
+
|
|
39
|
+
### 1. User Accounts
|
|
40
|
+
Manage parent and sub-accounts.
|
|
41
|
+
```typescript
|
|
42
|
+
// Fetch parent account details
|
|
43
|
+
const parentAccount = await quidax.users.getParentAccount();
|
|
44
|
+
|
|
45
|
+
// Create a sub-account
|
|
46
|
+
const subAccount = await quidax.users.create({
|
|
47
|
+
email: 'user@example.com',
|
|
48
|
+
first_name: 'John',
|
|
49
|
+
last_name: 'Doe'
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Wallets & Addresses
|
|
54
|
+
Manage cryptocurrency wallets and generate payment addresses.
|
|
55
|
+
```typescript
|
|
56
|
+
// Fetch all wallets for a specific user
|
|
57
|
+
const wallets = await quidax.wallets.getAll('user_id');
|
|
58
|
+
|
|
59
|
+
// Generate a payment address for a specific currency
|
|
60
|
+
const address = await quidax.wallets.createPaymentAddress('user_id', 'btc');
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. Markets & Tickers
|
|
64
|
+
Get real-time market data.
|
|
65
|
+
```typescript
|
|
66
|
+
// Get order book for a specific market pair (e.g. BTC to NGN)
|
|
67
|
+
const orderBook = await quidax.markets.getOrderBook('btcngn');
|
|
68
|
+
|
|
69
|
+
// Get a specific market ticker
|
|
70
|
+
const ticker = await quidax.markets.getTicker('btcngn');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 4. Withdrawals & Deposits
|
|
74
|
+
Track deposits and process withdrawals.
|
|
75
|
+
```typescript
|
|
76
|
+
// Fetch all deposits for a user
|
|
77
|
+
const deposits = await quidax.deposits.getAll('user_id');
|
|
78
|
+
|
|
79
|
+
// Process a crypto withdrawal
|
|
80
|
+
const withdrawal = await quidax.withdrawals.create('user_id', {
|
|
81
|
+
currency: 'btc',
|
|
82
|
+
amount: '0.5',
|
|
83
|
+
fund_uid: 'fund_id_here'
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 5. Instant Swaps
|
|
88
|
+
Process crypto-to-crypto instant swaps.
|
|
89
|
+
```typescript
|
|
90
|
+
// Generate a swap quotation
|
|
91
|
+
const quotation = await quidax.swap.getQuotation('user_id', {
|
|
92
|
+
source_currency: 'btc',
|
|
93
|
+
destination_currency: 'usdt',
|
|
94
|
+
amount: '1.5',
|
|
95
|
+
type: 'source'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Confirm the quotation
|
|
99
|
+
const swap = await quidax.swap.confirm('user_id', 'quotation_id_here');
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 6. Ramp & Custodial
|
|
103
|
+
Interact with the fiat on-ramp and off-ramp services.
|
|
104
|
+
```typescript
|
|
105
|
+
// Get available payment methods
|
|
106
|
+
const methods = await quidax.ramp.getPaymentMethods();
|
|
107
|
+
|
|
108
|
+
// Get a Buy Quote (Fiat to Crypto)
|
|
109
|
+
const quote = await quidax.ramp.getBuyQuote({
|
|
110
|
+
fiat: 'ngn',
|
|
111
|
+
crypto: 'usdt',
|
|
112
|
+
amount: '50000'
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Error Handling
|
|
117
|
+
|
|
118
|
+
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`.
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { Quidax, QuidaxError } from 'quidax-node';
|
|
122
|
+
|
|
123
|
+
async function processPayment() {
|
|
124
|
+
try {
|
|
125
|
+
const address = await quidax.wallets.createPaymentAddress('invalid_user', 'btc');
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (error instanceof QuidaxError) {
|
|
128
|
+
console.error(`HTTP Status: ${error.statusCode}`); // e.g., 400 or 401
|
|
129
|
+
console.error(`Quidax Status: ${error.status}`); // e.g., "error" or "failed"
|
|
130
|
+
console.error(`Message: ${error.message}`); // e.g., "Validation failed"
|
|
131
|
+
|
|
132
|
+
// If Quidax sends specific field validation errors, they will be here:
|
|
133
|
+
console.error(`Validation Details:`, error.data);
|
|
134
|
+
} else {
|
|
135
|
+
// Handle generic errors (e.g., network failure, timeouts)
|
|
136
|
+
console.error('An unexpected error occurred:', error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## TypeScript Support
|
|
143
|
+
|
|
144
|
+
This project is written entirely in **TypeScript** and compiled using `tsup`.
|
|
145
|
+
- It natively supports both **CommonJS** (`require`) and **ESModules** (`import`).
|
|
146
|
+
- 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
|
+
|
|
148
|
+
## License
|
|
149
|
+
MIT
|