3xui-api-client 2.0.0 → 2.1.1
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/CHANGELOG.md +155 -118
- package/LICENSE +20 -20
- package/README.md +374 -317
- package/index.d.ts +26 -6
- package/index.js +361 -3
- package/index.mjs +4 -4
- package/package.json +1 -1
- package/src/builders/ProtocolBuilders.js +689 -685
- package/src/generators/CredentialGenerator.js +361 -361
- package/src/middleware/WebMiddleware.js +310 -310
- package/src/security/SecurityEnhancer.js +325 -1
- package/src/session/SessionManager.js +492 -492
package/README.md
CHANGED
|
@@ -1,317 +1,374 @@
|
|
|
1
|
-
# 3xui-api-client
|
|
2
|
-
|
|
3
|
-
A Node.js client library for 3x-ui panel API that provides easy-to-use methods for managing your 3x-ui server.
|
|
4
|
-
|
|
5
|
-
[](https://badge.fury.io/js/3xui-api-client)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
|
|
8
|
-
## Features
|
|
9
|
-
|
|
10
|
-
- ✅ **Authentication** - Secure login with automatic session management
|
|
11
|
-
- ✅ **
|
|
12
|
-
- ✅ **
|
|
13
|
-
- ✅ **
|
|
14
|
-
- ✅ **
|
|
15
|
-
- ✅ **
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const result = await client.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const result = await client.
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
####
|
|
220
|
-
```javascript
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
#### Get
|
|
237
|
-
```javascript
|
|
238
|
-
const
|
|
239
|
-
console.log('
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
####
|
|
243
|
-
```javascript
|
|
244
|
-
const
|
|
245
|
-
console.log('
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
##
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
**
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
1
|
+
# 3xui-api-client
|
|
2
|
+
|
|
3
|
+
A Node.js client library for 3x-ui panel API that provides easy-to-use methods for managing your 3x-ui server.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/3xui-api-client)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- ✅ **Authentication** - Secure login with automatic session management and cookie handling
|
|
11
|
+
- ✅ **Security** - Built-in input validation, secure headers, and rate limiting
|
|
12
|
+
- ✅ **Inbound Management** - Get, add, update, and delete inbounds
|
|
13
|
+
- ✅ **Client Management** - Add, update, delete clients and monitor traffic
|
|
14
|
+
- ✅ **Traffic Management** - Monitor, reset, and manage traffic limits
|
|
15
|
+
- ✅ **System Operations** - Backup creation and online client monitoring
|
|
16
|
+
- ✅ **Complete API Coverage** - All 19 API routes fully tested and working
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install 3xui-api-client
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Context7 MCP Integration
|
|
25
|
+
|
|
26
|
+
This library can be implemented with the help of [Context7 MCP](https://context7.com/iamhelitha/3xui-api-client). Use the package name `3xui-api-client` to get context and documentation through Context7's Model Context Protocol integration.
|
|
27
|
+
|
|
28
|
+
Learn more about [Context7 MCP](https://context7.com) for enhanced development experience.
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
const ThreeXUI = require('3xui-api-client');
|
|
34
|
+
|
|
35
|
+
const client = new ThreeXUI('https://your-3xui-server.com', 'username', 'password');
|
|
36
|
+
|
|
37
|
+
// Get all inbounds
|
|
38
|
+
client.getInbounds()
|
|
39
|
+
.then(inbounds => {
|
|
40
|
+
console.log('Inbounds:', inbounds);
|
|
41
|
+
})
|
|
42
|
+
.catch(error => {
|
|
43
|
+
console.error('Error:', error.message);
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Configuration & Best Practices
|
|
48
|
+
|
|
49
|
+
### Using Environment Variables (Recommended)
|
|
50
|
+
Never hardcode your credentials in your code. Use environment variables to store sensitive information.
|
|
51
|
+
|
|
52
|
+
> **IMPORTANT NOTE**: The `PANEL_URL` should be the root URL of your server **WITHOUT** the `/panel` suffix.
|
|
53
|
+
> - ✅ Correct: `https://your-domain.com:2053` or `https://your-domain.com/secret-path`
|
|
54
|
+
> - ❌ Incorrect: `https://your-domain.com:2053/panel`
|
|
55
|
+
>
|
|
56
|
+
> The library automatically appends `/panel` and other necessary paths. Including it in your configuration will cause 404 errors.
|
|
57
|
+
|
|
58
|
+
1. Create a `.env` file in your project root:
|
|
59
|
+
```env
|
|
60
|
+
PANEL_URL=http://your-server-ip:2053
|
|
61
|
+
PANEL_USERNAME=admin
|
|
62
|
+
PANEL_PASSWORD=your_secure_password
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2. Install `dotenv`:
|
|
66
|
+
```bash
|
|
67
|
+
npm install dotenv
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
3. Initialize the client:
|
|
71
|
+
```javascript
|
|
72
|
+
require('dotenv').config();
|
|
73
|
+
const ThreeXUI = require('3xui-api-client');
|
|
74
|
+
|
|
75
|
+
const client = new ThreeXUI(
|
|
76
|
+
process.env.PANEL_URL,
|
|
77
|
+
process.env.PANEL_USERNAME,
|
|
78
|
+
process.env.PANEL_PASSWORD
|
|
79
|
+
);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Authentication & Security
|
|
83
|
+
|
|
84
|
+
### Automatic Login
|
|
85
|
+
The client automatically handles authentication. When you make your first API call, it will:
|
|
86
|
+
1. Login with your credentials
|
|
87
|
+
2. Store the session cookie
|
|
88
|
+
3. Use the cookie for subsequent requests
|
|
89
|
+
4. Automatically re-login if the session expires
|
|
90
|
+
|
|
91
|
+
### Server-Side Cookie Storage (Recommended)
|
|
92
|
+
For production applications, store the session cookie securely on your server. The `login()` method returns the cookie for this purpose:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
const ThreeXUI = require('3xui-api-client');
|
|
96
|
+
|
|
97
|
+
class SecureThreeXUIManager {
|
|
98
|
+
constructor(baseURL, username, password) {
|
|
99
|
+
this.client = new ThreeXUI(baseURL, username, password);
|
|
100
|
+
this.sessionCookie = null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async ensureAuthenticated() {
|
|
104
|
+
if (!this.sessionCookie) {
|
|
105
|
+
const loginResult = await this.client.login();
|
|
106
|
+
|
|
107
|
+
// The cookie is returned in the login result
|
|
108
|
+
this.sessionCookie = loginResult.cookie;
|
|
109
|
+
|
|
110
|
+
// Store in secure session storage (Redis, database, etc.)
|
|
111
|
+
await this.storeSessionSecurely(this.sessionCookie);
|
|
112
|
+
} else {
|
|
113
|
+
// Restore from secure storage
|
|
114
|
+
this.client.cookie = this.sessionCookie;
|
|
115
|
+
this.client.api.defaults.headers.Cookie = this.sessionCookie;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async storeSessionSecurely(cookie) {
|
|
120
|
+
// Example: Store in Redis with expiration
|
|
121
|
+
// await redis.setex('3xui_session', 3600, cookie);
|
|
122
|
+
|
|
123
|
+
// Example: Store in database
|
|
124
|
+
// await db.sessions.upsert({ service: '3xui', cookie, expires_at: new Date(Date.now() + 3600000) });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async getInbounds() {
|
|
128
|
+
await this.ensureAuthenticated();
|
|
129
|
+
return this.client.getInbounds();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Security Features
|
|
135
|
+
The library includes several security enhancements:
|
|
136
|
+
- **Input Validation**: Validates URLs, usernames, and passwords to prevent injection attacks.
|
|
137
|
+
- **Secure Headers**: Automatically adds security headers to requests.
|
|
138
|
+
- **Rate Limiting**: Prevents abuse by limiting request rates (configurable).
|
|
139
|
+
- **Error Sanitization**: Hides sensitive details in production errors.
|
|
140
|
+
|
|
141
|
+
## API Reference
|
|
142
|
+
|
|
143
|
+
### Constructor
|
|
144
|
+
```javascript
|
|
145
|
+
new ThreeXUI(baseURL, username, password)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- `baseURL` (string): Your 3x-ui server URL (e.g., 'https://your-server.com')
|
|
149
|
+
- `username` (string): Admin username
|
|
150
|
+
- `password` (string): Admin password
|
|
151
|
+
|
|
152
|
+
### Inbound Management (✅ Tested & Working)
|
|
153
|
+
|
|
154
|
+
#### Get All Inbounds
|
|
155
|
+
```javascript
|
|
156
|
+
const inbounds = await client.getInbounds();
|
|
157
|
+
console.log(inbounds);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### Get Specific Inbound
|
|
161
|
+
```javascript
|
|
162
|
+
const inbound = await client.getInbound(inboundId);
|
|
163
|
+
console.log(inbound);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
#### Add New Inbound
|
|
167
|
+
```javascript
|
|
168
|
+
const inboundConfig = {
|
|
169
|
+
remark: "My VPN Server",
|
|
170
|
+
port: 443,
|
|
171
|
+
protocol: "vless",
|
|
172
|
+
settings: {
|
|
173
|
+
// Your inbound settings
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const result = await client.addInbound(inboundConfig);
|
|
178
|
+
console.log('Inbound added:', result);
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### Update Inbound
|
|
182
|
+
```javascript
|
|
183
|
+
const updatedConfig = {
|
|
184
|
+
remark: "Updated VPN Server",
|
|
185
|
+
// Other updated settings
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const result = await client.updateInbound(inboundId, updatedConfig);
|
|
189
|
+
console.log('Inbound updated:', result);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Delete Inbound
|
|
193
|
+
```javascript
|
|
194
|
+
const result = await client.deleteInbound(inboundId);
|
|
195
|
+
console.log('Inbound deleted:', result);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Client Management (✅ Tested & Working)
|
|
199
|
+
|
|
200
|
+
#### Add Client to Inbound
|
|
201
|
+
```javascript
|
|
202
|
+
const clientConfig = {
|
|
203
|
+
id: inboundId,
|
|
204
|
+
settings: JSON.stringify({
|
|
205
|
+
clients: [{
|
|
206
|
+
id: "client-uuid-here",
|
|
207
|
+
email: "user23c5n7",
|
|
208
|
+
limitIp: 0,
|
|
209
|
+
totalGB: 0,
|
|
210
|
+
expiryTime: 0,
|
|
211
|
+
enable: true
|
|
212
|
+
}]
|
|
213
|
+
})
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const result = await client.addClient(clientConfig);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### Update Client
|
|
220
|
+
```javascript
|
|
221
|
+
const updateConfig = {
|
|
222
|
+
id: inboundId,
|
|
223
|
+
settings: JSON.stringify({
|
|
224
|
+
clients: [/* updated client settings */]
|
|
225
|
+
})
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const result = await client.updateClient(clientUUID, updateConfig);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### Delete Client
|
|
232
|
+
```javascript
|
|
233
|
+
const result = await client.deleteClient(inboundId, clientUUID);
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### Get Client Traffic by Email
|
|
237
|
+
```javascript
|
|
238
|
+
const traffic = await client.getClientTrafficsByEmail("user23c5n7");
|
|
239
|
+
console.log('Client traffic:', traffic);
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### Get Client Traffic by UUID
|
|
243
|
+
```javascript
|
|
244
|
+
const traffic = await client.getClientTrafficsById("client-uuid");
|
|
245
|
+
console.log('Client traffic:', traffic);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### Manage Client IPs
|
|
249
|
+
```javascript
|
|
250
|
+
// Get client IPs
|
|
251
|
+
const ips = await client.getClientIps("user23c5n7");
|
|
252
|
+
|
|
253
|
+
// Clear client IPs
|
|
254
|
+
const result = await client.clearClientIps("user23c5n7");
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Traffic Management (✅ Tested & Working)
|
|
258
|
+
|
|
259
|
+
#### Reset Individual Client Traffic
|
|
260
|
+
```javascript
|
|
261
|
+
const result = await client.resetClientTraffic(inboundId, "user23c5n7");
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### Reset All Traffic (Global)
|
|
265
|
+
```javascript
|
|
266
|
+
const result = await client.resetAllTraffics();
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### Reset All Client Traffic in Inbound
|
|
270
|
+
```javascript
|
|
271
|
+
const result = await client.resetAllClientTraffics(inboundId);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### Delete Depleted Clients
|
|
275
|
+
```javascript
|
|
276
|
+
const result = await client.deleteDepletedClients(inboundId);
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### System Operations (✅ Tested & Working)
|
|
280
|
+
|
|
281
|
+
#### Get Online Clients
|
|
282
|
+
```javascript
|
|
283
|
+
const onlineClients = await client.getOnlineClients();
|
|
284
|
+
console.log('Currently online:', onlineClients);
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
#### Create System Backup
|
|
288
|
+
```javascript
|
|
289
|
+
const result = await client.createBackup();
|
|
290
|
+
console.log('Backup created:', result);
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
#### Send Backup to Telegram Bot
|
|
294
|
+
```javascript
|
|
295
|
+
const tgResult = await client.backupToTgBot();
|
|
296
|
+
console.log('Backup sent to Telegram:', tgResult);
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
#### Get Server Status
|
|
300
|
+
```javascript
|
|
301
|
+
const status = await client.getServerStatus();
|
|
302
|
+
console.log('Server status:', status);
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Documentation
|
|
306
|
+
|
|
307
|
+
For comprehensive guides, examples, and implementation patterns, visit our [Wiki](https://github.com/iamhelitha/3xui-api-client/wiki):
|
|
308
|
+
|
|
309
|
+
- 📚 [**Use Cases & Examples**](https://github.com/iamhelitha/3xui-api-client/wiki/Use-Cases) - VPN service provider, server administration, monitoring dashboards
|
|
310
|
+
- 🔐 [**Authentication Guide**](https://github.com/iamhelitha/3xui-api-client/wiki/Authentication-Guide) - Secure login and session management
|
|
311
|
+
- 🌐 [**Inbound Management**](https://github.com/iamhelitha/3xui-api-client/wiki/Inbound-Management) - Server configuration and setup
|
|
312
|
+
- 👥 [**Client Management**](https://github.com/iamhelitha/3xui-api-client/wiki/Client-Management) - User account operations
|
|
313
|
+
- 📊 [**Traffic Management**](https://github.com/iamhelitha/3xui-api-client/wiki/Traffic-Management) - Usage monitoring and billing
|
|
314
|
+
- ⚙️ [**System Operations**](https://github.com/iamhelitha/3xui-api-client/wiki/System-Operations) - Backup and maintenance
|
|
315
|
+
|
|
316
|
+
## Error Handling
|
|
317
|
+
|
|
318
|
+
```javascript
|
|
319
|
+
try {
|
|
320
|
+
const inbounds = await client.getInbounds();
|
|
321
|
+
console.log(inbounds);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
if (error.message.includes('Login failed')) {
|
|
324
|
+
console.error('Authentication error:', error.message);
|
|
325
|
+
} else if (error.response?.status === 401) {
|
|
326
|
+
console.error('Unauthorized - check your credentials');
|
|
327
|
+
} else {
|
|
328
|
+
console.error('API error:', error.message);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Requirements
|
|
334
|
+
|
|
335
|
+
- Node.js >= 14.0.0
|
|
336
|
+
- 3x-ui panel with API access enabled
|
|
337
|
+
|
|
338
|
+
## Contributing
|
|
339
|
+
|
|
340
|
+
1. Fork the repository
|
|
341
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
342
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
343
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
344
|
+
5. Open a Pull Request
|
|
345
|
+
|
|
346
|
+
## Testing
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
# Run login test
|
|
350
|
+
npm run test:login
|
|
351
|
+
|
|
352
|
+
# Run all tests
|
|
353
|
+
npm test
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
## License
|
|
359
|
+
|
|
360
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
361
|
+
|
|
362
|
+
## Support
|
|
363
|
+
|
|
364
|
+
- 📖 [Wiki & Documentation](https://github.com/iamhelitha/3xui-api-client/wiki)
|
|
365
|
+
- 🐛 [Report Issues](https://github.com/iamhelitha/3xui-api-client/issues)
|
|
366
|
+
- 💬 [Discussions](https://github.com/iamhelitha/3xui-api-client/discussions)
|
|
367
|
+
|
|
368
|
+
## Author
|
|
369
|
+
|
|
370
|
+
**Helitha Guruge** - [@iamhelitha](https://github.com/iamhelitha)
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
⚠️ **Security Notice**: Always store credentials and session cookies securely. Never expose them in client-side code or commit them to version control.
|