├── .github
└── workflows
│ └── publish.yml
├── .gitignore
├── .npmignore
├── README.md
├── classes
├── Admin.js
├── Core.js
├── MarzbanAPI.js
├── Node.js
├── System.js
├── Template.js
├── User.js
└── WebSocketClient.js
├── index.js
├── package-lock.json
├── package.json
└── schemas
├── AdminSchemas.js
├── ConfigSchemas.js
├── NodeSchema.js
├── TemplateSchemas.js
└── UserSchemas.js
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish to npm
2 |
3 | on:
4 | workflow_dispatch
5 |
6 | jobs:
7 | publish:
8 | runs-on: ubuntu-latest
9 | steps:
10 |
11 | - name: Checkout code
12 | uses: actions/checkout@v3
13 |
14 | - name: Setup Node.js
15 | uses: actions/setup-node@v3
16 | with:
17 | node-version: '18'
18 |
19 | - name: Authenticate with npm
20 | run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
21 |
22 | - name: Install dependencies
23 | run: npm install
24 |
25 | - name: Publish package
26 | run: npm publish --access public
27 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | main.js
4 | *.log
5 | npm-debug.log*
6 | yarn-debug.log*
7 | yarn-error.log*
8 | lerna-debug.log*
9 | .pnpm-debug.log*
10 |
11 | # Diagnostic reports (https://nodejs.org/api/report.html)
12 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
13 |
14 | # Runtime data
15 | pids
16 | *.pid
17 | *.seed
18 | *.pid.lock
19 |
20 | # Directory for instrumented libs generated by jscoverage/JSCover
21 | lib-cov
22 |
23 | # Coverage directory used by tools like istanbul
24 | coverage
25 | *.lcov
26 |
27 | # nyc test coverage
28 | .nyc_output
29 |
30 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
31 | .grunt
32 |
33 | # Bower dependency directory (https://bower.io/)
34 | bower_components
35 |
36 | # node-waf configuration
37 | .lock-wscript
38 |
39 | # Compiled binary addons (https://nodejs.org/api/addons.html)
40 | build/Release
41 |
42 | # Dependency directories
43 | node_modules/
44 | jspm_packages/
45 |
46 | # Snowpack dependency directory (https://snowpack.dev/)
47 | web_modules/
48 |
49 | # TypeScript cache
50 | *.tsbuildinfo
51 |
52 | # Optional npm cache directory
53 | .npm
54 |
55 | # Optional eslint cache
56 | .eslintcache
57 |
58 | # Optional stylelint cache
59 | .stylelintcache
60 |
61 | # Microbundle cache
62 | .rpt2_cache/
63 | .rts2_cache_cjs/
64 | .rts2_cache_es/
65 | .rts2_cache_umd/
66 |
67 | # Optional REPL history
68 | .node_repl_history
69 |
70 | # Output of 'npm pack'
71 | *.tgz
72 |
73 | # Yarn Integrity file
74 | .yarn-integrity
75 |
76 | # dotenv environment variable files
77 | .env
78 | .env.development.local
79 | .env.test.local
80 | .env.production.local
81 | .env.local
82 |
83 | # parcel-bundler cache (https://parceljs.org/)
84 | .cache
85 | .parcel-cache
86 |
87 | # Next.js build output
88 | .next
89 | out
90 |
91 | # Nuxt.js build / generate output
92 | .nuxt
93 | dist
94 |
95 | # Gatsby files
96 | .cache/
97 | # Comment in the public line in if your project uses Gatsby and not Next.js
98 | # https://nextjs.org/blog/next-9-1#public-directory-support
99 | # public
100 |
101 | # vuepress build output
102 | .vuepress/dist
103 |
104 | # vuepress v2.x temp and cache directory
105 | .temp
106 | .cache
107 |
108 | # Docusaurus cache and generated files
109 | .docusaurus
110 |
111 | # Serverless directories
112 | .serverless/
113 |
114 | # FuseBox cache
115 | .fusebox/
116 |
117 | # DynamoDB Local files
118 | .dynamodb/
119 |
120 | # TernJS port file
121 | .tern-port
122 |
123 | # Stores VSCode versions used for testing VSCode extensions
124 | .vscode-test
125 |
126 | # yarn v2
127 | .yarn/cache
128 | .yarn/unplugged
129 | .yarn/build-state.yml
130 | .yarn/install-state.gz
131 | .pnp.*
132 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .github
2 | node_modules
3 | *.log
4 |
5 | # Logs
6 | logs
7 | main.js
8 | *.log
9 | npm-debug.log*
10 | yarn-debug.log*
11 | yarn-error.log*
12 | lerna-debug.log*
13 | .pnpm-debug.log*
14 |
15 | # Diagnostic reports (https://nodejs.org/api/report.html)
16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17 |
18 | # Runtime data
19 | pids
20 | *.pid
21 | *.seed
22 | *.pid.lock
23 |
24 | # Directory for instrumented libs generated by jscoverage/JSCover
25 | lib-cov
26 |
27 | # Coverage directory used by tools like istanbul
28 | coverage
29 | *.lcov
30 |
31 | # nyc test coverage
32 | .nyc_output
33 |
34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35 | .grunt
36 |
37 | # Bower dependency directory (https://bower.io/)
38 | bower_components
39 |
40 | # node-waf configuration
41 | .lock-wscript
42 |
43 | # Compiled binary addons (https://nodejs.org/api/addons.html)
44 | build/Release
45 |
46 | # Dependency directories
47 | node_modules/
48 | jspm_packages/
49 |
50 | # Snowpack dependency directory (https://snowpack.dev/)
51 | web_modules/
52 |
53 | # TypeScript cache
54 | *.tsbuildinfo
55 |
56 | # Optional npm cache directory
57 | .npm
58 |
59 | # Optional eslint cache
60 | .eslintcache
61 |
62 | # Optional stylelint cache
63 | .stylelintcache
64 |
65 | # Microbundle cache
66 | .rpt2_cache/
67 | .rts2_cache_cjs/
68 | .rts2_cache_es/
69 | .rts2_cache_umd/
70 |
71 | # Optional REPL history
72 | .node_repl_history
73 |
74 | # Output of 'npm pack'
75 | *.tgz
76 |
77 | # Yarn Integrity file
78 | .yarn-integrity
79 |
80 | # dotenv environment variable files
81 | .env
82 | .env.development.local
83 | .env.test.local
84 | .env.production.local
85 | .env.local
86 |
87 | # parcel-bundler cache (https://parceljs.org/)
88 | .cache
89 | .parcel-cache
90 |
91 | # Next.js build output
92 | .next
93 | out
94 |
95 | # Nuxt.js build / generate output
96 | .nuxt
97 | dist
98 |
99 | # Gatsby files
100 | .cache/
101 | # Comment in the public line in if your project uses Gatsby and not Next.js
102 | # https://nextjs.org/blog/next-9-1#public-directory-support
103 | # public
104 |
105 | # vuepress build output
106 | .vuepress/dist
107 |
108 | # vuepress v2.x temp and cache directory
109 | .temp
110 | .cache
111 |
112 | # Docusaurus cache and generated files
113 | .docusaurus
114 |
115 | # Serverless directories
116 | .serverless/
117 |
118 | # FuseBox cache
119 | .fusebox/
120 |
121 | # DynamoDB Local files
122 | .dynamodb/
123 |
124 | # TernJS port file
125 | .tern-port
126 |
127 | # Stores VSCode versions used for testing VSCode extensions
128 | .vscode-test
129 |
130 | # yarn v2
131 | .yarn/cache
132 | .yarn/unplugged
133 | .yarn/build-state.yml
134 | .yarn/install-state.gz
135 | .pnp.*
136 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 🌐 MarzJS
2 |
3 | A powerful and easy-to-use Node.js client for interacting with the Marzban Panel API.
4 |
5 | ## 🚀 Features
6 |
7 | - 💡 Full API coverage for Marzban
8 | - 🔒 Secure authentication (token-based and credentials-based)
9 | - 🔄 Comprehensive method support
10 | - 🧩 Easy-to-use interface
11 | - 📊 WebSocket log streaming
12 | - ♻️ Automatic retry mechanism for network requests
13 |
14 | ## 📦 Installation
15 |
16 | ```bash
17 | npm install @maniwrld/marzjs
18 | ```
19 |
20 | ## 🛠 Quick Start
21 |
22 | ### Authentication Methods
23 |
24 | ```javascript
25 | const MarzbanAPI = require('@maniwrld/marzjs');
26 |
27 | // Option 1: Authentication with username and password
28 | const client = new MarzbanAPI({
29 | domain: 'your-marzban-server.com',
30 | port: 8000,
31 | username: 'admin',
32 | password: 'your-password',
33 | ssl: true // Optional: use HTTPS/WSS
34 | });
35 |
36 | // Option 2: Authentication with token (skip credentials)
37 | const clientWithToken = new MarzbanAPI({
38 | domain: 'your-marzban-server.com',
39 | port: 8000,
40 | token: 'your-access-token',
41 | ssl: true // Optional: use HTTPS/WSS
42 | });
43 |
44 | // Option 3: Customize retry and timeout settings
45 | const robustClient = new MarzbanAPI({
46 | domain: 'your-marzban-server.com',
47 | port: 8000,
48 | username: 'admin',
49 | password: 'your-password',
50 | ssl: true,
51 | timeout: 15000, // Custom timeout (ms)
52 | retryDelay: 2000, // Delay between retries (ms)
53 | maxRetries: 5 // Maximum number of retries
54 | });
55 | ```
56 |
57 | ## 🌟 Key Methods
58 |
59 | ### 👤 Admin Operations
60 | - [`getCurrentAdmin()`](#get-current-admin): Get current admin details
61 | - [`createAdmin(adminData)`](#create-a-admin): Create a new admin
62 | - [`modifyAdmin(username, adminData)`](#modify-a-admin): Update admin information
63 | - [`removeAdmin(username)`](#remove-a-admin): Delete an admin
64 | - [`getAdmins(params)`](#get-admins): Retrieve list of admins
65 |
66 | ### 📊 User Management
67 | - [`addUser()`](#user-creation): Create a new user
68 | - [`getUser()`](#fetching-user-information): Retrieve user details
69 | - [`modifyUser()`](#modifying-user): Update user information
70 | - [`removeUser()`](#deleting-user): Delete a user
71 | - [`getUserUsage()`](#get-user-usage): Check user's data usage
72 | - [`resetUserDataUsage()`](#reset-user-data-usage): Reset a user's data usage
73 | - [`revokeUserSubscription()`](#revoke-user-subscription): Revoke user's subscription
74 | - [`getUsers()`](#get-users): Retrieve list of all users
75 | - [`resetUsersDataUsage()`](#reset-users-data-usage): Reset data usage for all users
76 | - [`setUserOwner()`](#set-user-owner): Set a user's admin parent
77 | - [`getExpiredUsers()`](#get-expired-users): Retrieve list of expired users
78 | - [`deleteExpiredUsers()`](#delete-expired-users): Delete expired users
79 |
80 | ### 🔗 Subscription Handling (Under user class)
81 | - [`getUserSubscription(token)`](#get-user-subscription): Get subscription details
82 | - [`getUserSubscriptionInfo(token)`](#get-user-subscription-information): Get detailed subscription information
83 | - [`getUserSubscriptionUsage(token)`](#get-user-subscription-usage): Check subscription usage
84 | - [`getUserSubscriptionWithClientType(token, clientType)`](#get-user-subscription-with-client-type): Get subscription for specific client type
85 |
86 | ### 📝 Template Management
87 | - [`getUserTemplates()`](#get-user-templates): Get list of user templates
88 | - [`addUserTemplate(templateData)`](#add-user-template): Create a new user template
89 | - [`getUserTemplateById(template_id)`](#get-user-template-by-id): Get template by ID
90 | - [`modifyUserTemplate(id, templateData)`](#modify-user-template): Update a user template
91 | - [`removeUserTemplate(id)`](#deleting-user-template): Delete a user template
92 |
93 | ### 🖥 Node Operations
94 | - [`getNodeSettings()`](#get-node-settings): Retrieve node settings
95 | - [`addNode(nodeData)`](#add-node): Add a new node
96 | - [`getNode(nodeId)`](#get-node): Get details of a specific node
97 | - [`modifyNode(nodeId, nodeData)`](#modify-node): Update node information
98 | - [`removeNode(nodeId)`](#remove-node): Delete a node
99 | - [`getNodes(params)`](#get-nodes): Retrieve list of nodes
100 | - [`reconnectNode(nodeId)`](#reconnect-node): Reconnect a node
101 | - [`getNodesUsage()`](#get-node-usage): Retrieve usage statistics for nodes
102 |
103 | ### 🌐 System Insights
104 | - [`getSystemStats()`](#get-system-stats): Fetch system statistics
105 | - [`getInbounds()`](#get-inbounds): Get available inbounds
106 | - [`getHosts()`](#get-hosts): Retrieve host information
107 | - [`modifyHosts(hostData)`](#modify-hosts): Update host configuration
108 |
109 | ### 💻 Core System Management
110 | - [`getCoreStats()`](#get-core-stats): Get core system statistics
111 | - [`restartCore()`](#restart-core): Restart the core system
112 | - [`getCoreConfig()`](#get-core-config): Retrieve core configuration
113 | - [`modifyCoreConfig(configData)`](#modify-core-config): Modify core configuration
114 |
115 | ### 🔌 WebSocket Logging
116 |
117 | ```javascript
118 | client.connectToLogs({
119 | interval: 1, // Log polling interval
120 | onMessage: (logData) => {
121 | console.log('Received log:', logData);
122 | },
123 | onError: (error) => {
124 | console.error('WebSocket error:', error);
125 | }
126 | });
127 |
128 | // Don't forget to disconnect when done
129 | client.disconnectFromLogs();
130 | ```
131 |
132 | ## 🔧 Configuration Options
133 |
134 | When initializing the MarzJS client, you can customize the following parameters:
135 |
136 | - `domain`: Your Marzban server domain (required)
137 | - `port`: Server port (required)
138 | - `username`: Admin username (optional if using token)
139 | - `password`: Admin password (optional if using token)
140 | - `token`: Authentication token (optional alternative to username/password)
141 | - `ssl`: Use HTTPS/WSS (default: false)
142 | - `timeout`: Request timeout in milliseconds (default: 10000)
143 | - `retryDelay`: Delay between retry attempts in milliseconds (default: 1000)
144 | - `maxRetries`: Maximum number of retry attempts (default: 3)
145 |
146 | ## 🛠 Troubleshooting
147 |
148 | ### Common Connection Issues
149 |
150 | 1. **Authentication Failures**
151 | - **Symptom**: Repeated 401 or 403 errors
152 | - **Possible Causes**:
153 | * Incorrect domain or port
154 | * Expired or invalid credentials
155 | * Network restrictions
156 | - **Solutions**:
157 | ```javascript
158 | // Double-check your connection parameters
159 | const marzban = new MarzbanAPI({
160 | domain: 'correct-domain.com',
161 | port: 8080,
162 | username: 'admin',
163 | password: 'correct-password',
164 | ssl: true
165 | });
166 | ```
167 |
168 | 2. **Network Timeout Errors**
169 | - **Symptom**: Requests timing out frequently
170 | - **Possible Causes**:
171 | * Slow network connection
172 | * Server under heavy load
173 | * Firewall restrictions
174 | - **Solutions**:
175 | ```javascript
176 | // Increase timeout and retry settings
177 | const robustClient = new MarzbanAPI({
178 | domain: 'example.com',
179 | timeout: 30000, // Increased to 30 seconds
180 | retryDelay: 3000, // 3 seconds between retries
181 | maxRetries: 5 // More retry attempts
182 | });
183 | ```
184 |
185 | 3. **WebSocket Connection Problems**
186 | - **Symptom**: Unable to establish log streaming connection
187 | - **Possible Causes**:
188 | * Incorrect SSL configuration
189 | * Firewall blocking WebSocket
190 | * Incorrect API permissions
191 | - **Solutions**:
192 | ```javascript
193 | try {
194 | client.connectToLogs({
195 | interval: 2, // Adjust polling interval
196 | onError: (error) => {
197 | console.error('Detailed WebSocket error:', error);
198 | // Implement reconnection logic if needed
199 | }
200 | });
201 | } catch (error) {
202 | console.error('Log connection initialization error:', error);
203 | }
204 | ```
205 |
206 | ### Debugging Tips
207 |
208 | - **Enable Verbose Logging**: Use Node.js debugging tools or environment variables to get more detailed error information
209 | - **Check Marzban Panel Logs**: Cross-reference with server-side logs for comprehensive troubleshooting
210 | - **Verify API Endpoint**: Ensure your Marzban Panel is running and accessible
211 |
212 | ### Getting Help
213 |
214 | - **GitHub Issues**: [Open an issue](https://github.com/maniwrld/marzjs/issues) with detailed error logs
215 | - **Community Support**: Check project discussions for known issues
216 | - **Provide Detailed Information**:
217 | * Node.js version
218 | * MarzJS version
219 | * Complete error message
220 | * Minimal reproducible example
221 |
222 | ## 💡 Examples
223 |
224 |
225 |
226 | ### 💻 Get current admin
227 |
228 | ```javascript
229 | const MarzbanAPI = require('@maniwrld/marzjs');
230 |
231 | const marzban = MarzbanAPI({
232 | domain: 'example.com',
233 | port: 8080,
234 | ssl: true,
235 | username: 'admin',
236 | password: 'securepassword'
237 | });
238 |
239 | (async () => {
240 | try {
241 | const response = await marzban.admin.getCurrentAdmin();
242 | console.log(response)
243 | } catch (error) {
244 | console.error(`Error getting current admin:`, error.message);
245 | }
246 | })();
247 | ```
248 |
249 |
250 | ### 💻 Create a admin
251 |
252 | ```javascript
253 | const MarzbanAPI = require('@maniwrld/marzjs');
254 |
255 | const marzban = MarzbanAPI({
256 | domain: 'example.com',
257 | port: 8080,
258 | ssl: true,
259 | username: 'admin',
260 | password: 'securepassword'
261 | });
262 |
263 | (async () => {
264 | try {
265 | const admin_data = {
266 | "username": "chilladmin",
267 | "is_sudo": true,
268 | "telegram_id": 0,
269 | "discord_webhook": "",
270 | "password": "securepasswordhopefully"
271 | }
272 | const response = await marzban.admin.createAdmin(admin_data);
273 | console.log(response)
274 | } catch (error) {
275 | console.error(`Error creating admin:`, error.message);
276 | }
277 | })();
278 | ```
279 |
280 |
281 | ### 💻 Modify a admin
282 |
283 | ```javascript
284 | const MarzbanAPI = require('@maniwrld/marzjs');
285 |
286 | const marzban = MarzbanAPI({
287 | domain: 'example.com',
288 | port: 8080,
289 | ssl: true,
290 | username: 'admin',
291 | password: 'securepassword'
292 | });
293 |
294 | (async () => {
295 | try {
296 | const target_admin = "chilladmin";
297 | const admin_data = {
298 | "password": "hopefullysecurethistime",
299 | "is_sudo": true,
300 | "telegram_id": 0,
301 | "discord_webhook": ""
302 | }
303 | const response = await marzban.admin.modifyAdmin(target_admin, admin_data);
304 | console.log(response)
305 | } catch (error) {
306 | console.error(`Error modifying admin:`, error.message);
307 | }
308 | })();
309 | ```
310 |
311 |
312 |
313 | ### 💻 Remove a admin
314 |
315 | ```javascript
316 | const MarzbanAPI = require('@maniwrld/marzjs');
317 |
318 | const marzban = MarzbanAPI({
319 | domain: 'example.com',
320 | port: 8080,
321 | ssl: true,
322 | username: 'admin',
323 | password: 'securepassword'
324 | });
325 |
326 | (async () => {
327 | try {
328 | const target_admin = "notchilladmin";
329 | const response = await marzban.admin.removeAdmin(target_admin);
330 | console.log(response)
331 | } catch (error) {
332 | console.error(`Error removing admin:`, error.message);
333 | }
334 | })();
335 | ```
336 |
337 |
338 |
339 | ### 💻 Get admins
340 |
341 | ```javascript
342 | const MarzbanAPI = require('@maniwrld/marzjs');
343 |
344 | const marzban = MarzbanAPI({
345 | domain: 'example.com',
346 | port: 8080,
347 | ssl: true,
348 | username: 'admin',
349 | password: 'securepassword'
350 | });
351 |
352 | (async () => {
353 | try {
354 | const response = await marzban.admin.getAdmins();
355 | console.log(response)
356 | } catch (error) {
357 | console.error(`Error listing admins:`, error.message);
358 | }
359 | })();
360 | ```
361 |
362 |
363 |
364 | ### 💻 User creation
365 |
366 | ```javascript
367 | const MarzbanAPI = require('@maniwrld/marzjs');
368 |
369 | const marzban = MarzbanAPI({
370 | domain: 'example.com',
371 | port: 8080,
372 | ssl: true,
373 | username: 'admin',
374 | password: 'securepassword'
375 | });
376 |
377 | (async () => {
378 | try {
379 | const userData = {
380 | status: "active",
381 | username: "JohnDoe",
382 | note: "Created using marzban api",
383 | proxies: {
384 | vmess: {}
385 | },
386 | data_limit: 0,
387 | expire: 0,
388 | data_limit_reset_strategy: "no_reset",
389 | inbounds: {
390 | vmess: ["VMess TCP"]
391 | }
392 | };
393 |
394 | const response = await marzban.user.addUser(userData);
395 | console.log('User added successfully:', response);
396 | } catch (error) {
397 | console.error('Error adding user:', error.message);
398 | }
399 | })();
400 |
401 | ```
402 |
403 |
404 |
405 | ### 💻 Fetching user information
406 |
407 | ```javascript
408 | const MarzbanAPI = require('@maniwrld/marzjs');
409 |
410 | const marzban = MarzbanAPI({
411 | domain: 'example.com',
412 | port: 8080,
413 | ssl: true,
414 | username: 'admin',
415 | password: 'securepassword'
416 | });
417 |
418 | (async () => {
419 | try {
420 | const username = 'user1234';
421 | const response = await marzban.user.getUser(username);
422 | console.log('User information retrieved successfully:', response);
423 | } catch (error) {
424 | console.error('Error retrieving user information:', error.message);
425 | }
426 | })();
427 | ```
428 |
429 |
430 |
431 | ### 💻 Modifying user
432 |
433 | ```javascript
434 | const MarzbanAPI = require('@maniwrld/marzjs');
435 |
436 | const marzban = MarzbanAPI({
437 | domain: 'example.com',
438 | port: 8080,
439 | ssl: true,
440 | username: 'admin',
441 | password: 'securepassword'
442 | });
443 |
444 | (async () => {
445 | try {
446 | const username = 'user1234';
447 | const userData = {
448 | proxies: {
449 | vmess: {
450 | id: '35e4e39c-7d5c-4f4b-8b71-558e4f37ff53'
451 | },
452 | vless: {}
453 | },
454 | inbounds: {
455 | vmess: ['VMess TCP', 'VMess Websocket'],
456 | vless: ['VLESS TCP REALITY', 'VLESS GRPC REALITY']
457 | },
458 | expire: 0,
459 | data_limit: 0,
460 | data_limit_reset_strategy: 'no_reset',
461 | status: 'active',
462 | note: 'Updated note',
463 | on_hold_timeout: '2023-11-03T20:30:00',
464 | on_hold_expire_duration: 0
465 | };
466 |
467 | const response = await marzban.user.modifyUser(username, userData);
468 | console.log('User modified successfully:', response);
469 | } catch (error) {
470 | console.error('Error modifying user:', error.message);
471 | }
472 | })();
473 | ```
474 |
475 |
476 |
477 | ### 💻 Deleting user
478 |
479 | ```javascript
480 | const MarzbanAPI = require('@maniwrld/marzjs');
481 |
482 | const marzban = MarzbanAPI({
483 | domain: 'example.com',
484 | port: 8080,
485 | ssl: true,
486 | username: 'admin',
487 | password: 'securepassword'
488 | });
489 |
490 | (async () => {
491 | try {
492 | const username = 'user1234';
493 | const response = await marzban.user.removeUser(username);
494 | console.log('User removed successfully:', response);
495 | } catch (error) {
496 | console.error('Error removing user:', error.message);
497 | }
498 | })();
499 | ```
500 |
501 |
502 |
503 | ### 💻 Get user usage
504 |
505 | ```javascript
506 | const MarzbanAPI = require('@maniwrld/marzjs');
507 |
508 | const marzban = MarzbanAPI({
509 | domain: 'example.com',
510 | port: 8080,
511 | ssl: true,
512 | username: 'admin',
513 | password: 'securepassword'
514 | });
515 |
516 | (async () => {
517 | try {
518 | const username = 'user1234';
519 | const response = await marzban.user.getUserUsage(username);
520 | console.log(response)
521 | } catch (error) {
522 | console.error(`Error getting user's usage:`, error.message);
523 | }
524 | })();
525 | ```
526 |
527 |
528 |
529 | ### 💻 Reset User Data Usage
530 |
531 | ```javascript
532 | const MarzbanAPI = require('@maniwrld/marzjs');
533 |
534 | const marzban = MarzbanAPI({
535 | domain: 'example.com',
536 | port: 8080,
537 | ssl: true,
538 | username: 'admin',
539 | password: 'securepassword'
540 | });
541 |
542 | (async () => {
543 | try {
544 | const username = 'user1234';
545 | const response = await marzban.user.resetUserDataUsage(username);
546 | console.log(response)
547 | } catch (error) {
548 | console.error(`Error resetting user's usage:`, error.message);
549 | }
550 | })();
551 | ```
552 |
553 |
554 |
555 | ### 💻 Revoke User Subscription
556 |
557 | ```javascript
558 | const MarzbanAPI = require('@maniwrld/marzjs');
559 |
560 | const marzban = MarzbanAPI({
561 | domain: 'example.com',
562 | port: 8080,
563 | ssl: true,
564 | username: 'admin',
565 | password: 'securepassword'
566 | });
567 |
568 | (async () => {
569 | try {
570 | const username = 'user1234';
571 | const response = await marzban.user.revokeUserSubscription(username);
572 | console.log(response)
573 | } catch (error) {
574 | console.error(`Error revoking user's subscription:`, error.message);
575 | }
576 | })();
577 | ```
578 |
579 |
580 |
581 | ### 💻 Get users
582 |
583 | ```javascript
584 | const MarzbanAPI = require('@maniwrld/marzjs');
585 |
586 | const marzban = MarzbanAPI({
587 | domain: 'example.com',
588 | port: 8080,
589 | ssl: true,
590 | username: 'admin',
591 | password: 'securepassword'
592 | });
593 |
594 | (async () => {
595 | try {
596 | const response = await marzban.user.getUsers();
597 | console.log(response)
598 | } catch (error) {
599 | console.error(`Error listing all users:`, error.message);
600 | }
601 | })();
602 | ```
603 |
604 |
605 |
606 | ### 💻 Reset all users usage
607 |
608 | ```javascript
609 | const MarzbanAPI = require('@maniwrld/marzjs');
610 |
611 | const marzban = MarzbanAPI({
612 | domain: 'example.com',
613 | port: 8080,
614 | ssl: true,
615 | username: 'admin',
616 | password: 'securepassword'
617 | });
618 |
619 | (async () => {
620 | try {
621 | const response = await marzban.user.resetUsersDataUsage();
622 | console.log(response)
623 | } catch (error) {
624 | console.error(`Error resetting usage for all users:`, error.message);
625 | }
626 | })();
627 | ```
628 |
629 |
630 |
631 | ### 💻 Set user owner
632 |
633 | ```javascript
634 | const MarzbanAPI = require('@maniwrld/marzjs');
635 |
636 | const marzban = MarzbanAPI({
637 | domain: 'example.com',
638 | port: 8080,
639 | ssl: true,
640 | username: 'admin',
641 | password: 'securepassword'
642 | });
643 |
644 | (async () => {
645 | try {
646 | const target_user = "chilluser";
647 | const target_admin = "chilladmin";
648 | const response = await marzban.user.setUserOwner(target_user, target_admin);
649 | console.log(response)
650 | } catch (error) {
651 | console.error(`Error setting ${target_admin} as admin parent for ${target_user}:`, error.message);
652 | }
653 | })();
654 | ```
655 |
656 |
657 |
658 | ### 💻 Get expired users
659 |
660 | ```javascript
661 | const MarzbanAPI = require('@maniwrld/marzjs');
662 |
663 | const marzban = MarzbanAPI({
664 | domain: 'example.com',
665 | port: 8080,
666 | ssl: true,
667 | username: 'admin',
668 | password: 'securepassword'
669 | });
670 |
671 | (async () => {
672 | try {
673 | const response = await marzban.user.getExpiredUsers();
674 | console.log(response)
675 | } catch (error) {
676 | console.error(`Error listing expired users:`, error.message);
677 | }
678 | })();
679 | ```
680 |
681 |
682 |
683 | ### 💻 Delete expired users
684 |
685 | ```javascript
686 | const MarzbanAPI = require('@maniwrld/marzjs');
687 |
688 | const marzban = MarzbanAPI({
689 | domain: 'example.com',
690 | port: 8080,
691 | ssl: true,
692 | username: 'admin',
693 | password: 'securepassword'
694 | });
695 |
696 | (async () => {
697 | try {
698 | const response = await marzban.user.deleteExpiredUsers();
699 | console.log(response)
700 | } catch (error) {
701 | console.error(`Error deleting expired users:`, error.message);
702 | }
703 | })();
704 | ```
705 |
706 |
707 |
708 | ### 💻 Get user subscription
709 |
710 | ```javascript
711 | const MarzbanAPI = require('@maniwrld/marzjs');
712 |
713 | const marzban = MarzbanAPI({
714 | domain: 'example.com',
715 | port: 8080,
716 | ssl: true,
717 | username: 'admin',
718 | password: 'securepassword'
719 | });
720 |
721 | (async () => {
722 | try {
723 | const token = "COOLTOKENINSERTEDHERE";
724 | const response = await marzban.user.getUserSubscription(token);
725 | console.log(response)
726 | } catch (error) {
727 | console.error(`Error getting user subscription:`, error.message);
728 | }
729 | })();
730 | ```
731 |
732 |
733 |
734 | ### 💻 Get user subscription information
735 |
736 | ```javascript
737 | const MarzbanAPI = require('@maniwrld/marzjs');
738 |
739 | const marzban = MarzbanAPI({
740 | domain: 'example.com',
741 | port: 8080,
742 | ssl: true,
743 | username: 'admin',
744 | password: 'securepassword'
745 | });
746 |
747 | (async () => {
748 | try {
749 | const token = "COOLTOKENINSERTEDHERE";
750 | const response = await marzban.user.getUserSubscriptionInfo(token);
751 | console.log(response)
752 | } catch (error) {
753 | console.error(`Error getting user subscription information:`, error.message);
754 | }
755 | })();
756 | ```
757 |
758 |
759 |
760 | ### 💻 Get user subscription usage
761 |
762 | ```javascript
763 | const MarzbanAPI = require('@maniwrld/marzjs');
764 |
765 | const marzban = MarzbanAPI({
766 | domain: 'example.com',
767 | port: 8080,
768 | ssl: true,
769 | username: 'admin',
770 | password: 'securepassword'
771 | });
772 |
773 | (async () => {
774 | try {
775 | const token = "COOLTOKENINSERTEDHERE";
776 | const response = await marzban.user.getUserSubscriptionUsage(token);
777 | console.log(response)
778 | } catch (error) {
779 | console.error(`Error getting user subscription usage:`, error.message);
780 | }
781 | })();
782 | ```
783 |
784 |
785 |
786 | ### 💻 Get user subscription with client type
787 |
788 | ```javascript
789 | const MarzbanAPI = require('@maniwrld/marzjs');
790 |
791 | const marzban = MarzbanAPI({
792 | domain: 'example.com',
793 | port: 8080,
794 | ssl: true,
795 | username: 'admin',
796 | password: 'securepassword'
797 | });
798 |
799 | (async () => {
800 | try {
801 | const token = "COOLTOKENINSERTEDHERE";
802 | const client = "clash";
803 | const response = await marzban.user.getUserSubscriptionWithClientType(token, client);
804 | console.log(response)
805 | } catch (error) {
806 | console.error(`Error getting user subscription with client type:`, error.message);
807 | }
808 | })();
809 | ```
810 |
811 |
812 |
813 | ### 💻 Get user templates
814 |
815 | ```javascript
816 | const MarzbanAPI = require('@maniwrld/marzjs');
817 |
818 | const marzban = MarzbanAPI({
819 | domain: 'example.com',
820 | port: 8080,
821 | ssl: true,
822 | username: 'admin',
823 | password: 'securepassword'
824 | });
825 |
826 | (async () => {
827 | try {
828 | const response = await marzban.templates.getUserTemplates();
829 | console.log(response)
830 | } catch (error) {
831 | console.error(`Error listing user templates:`, error.message);
832 | }
833 | })();
834 | ```
835 |
836 |
837 |
838 | ### 💻 Add user template
839 |
840 | ```javascript
841 | const MarzbanAPI = require('@maniwrld/marzjs');
842 |
843 | const marzban = MarzbanAPI({
844 | domain: 'example.com',
845 | port: 8080,
846 | ssl: true,
847 | username: 'admin',
848 | password: 'securepassword'
849 | });
850 |
851 | (async () => {
852 | try {
853 | const template_data = {
854 | "name": "cool_template",
855 | "inbounds": {
856 | "vmess": [
857 | "VMESS_INBOUND"
858 | ],
859 | "vless": [
860 | "VLESS_INBOUND"
861 | ]
862 | },
863 | "data_limit": 0,
864 | "expire_duration": 0
865 | }
866 | const response = await marzban.templates.addUserTemplate(template_data);
867 | console.log(response)
868 | } catch (error) {
869 | console.error(`Error creating template:`, error.message);
870 | }
871 | })();
872 | ```
873 |
874 |
875 |
876 | ### 💻 Get user template by id
877 |
878 | ```javascript
879 | const MarzbanAPI = require('@maniwrld/marzjs');
880 |
881 | const marzban = MarzbanAPI({
882 | domain: 'example.com',
883 | port: 8080,
884 | ssl: true,
885 | username: 'admin',
886 | password: 'securepassword'
887 | });
888 |
889 | (async () => {
890 | try {
891 | const template_id = "1";
892 | const response = await marzban.templates.getUserTemplateById(template_id);
893 | console.log(response)
894 | } catch (error) {
895 | console.error(`Error getting template by id:`, error.message);
896 | }
897 | })();
898 | ```
899 |
900 |
901 |
902 | ### 💻 Modify user template
903 |
904 | ```javascript
905 | const MarzbanAPI = require('@maniwrld/marzjs');
906 |
907 | const marzban = MarzbanAPI({
908 | domain: 'example.com',
909 | port: 8080,
910 | ssl: true,
911 | username: 'admin',
912 | password: 'securepassword'
913 | });
914 |
915 | (async () => {
916 | try {
917 | const target_template_id = "1";
918 | const template_data = {
919 | "name": "cool_template_2",
920 | "inbounds": {
921 | "vmess": [
922 | "VMESS_INBOUND"
923 | ]
924 | },
925 | "data_limit": 0,
926 | "expire_duration": 0
927 | }
928 | const response = await marzban.templates.modifyUserTemplate(target_template_id, template_data);
929 | console.log(response)
930 | } catch (error) {
931 | console.error(`Error modifying template:`, error.message);
932 | }
933 | })();
934 | ```
935 |
936 |
937 |
938 | ### 💻 Deleting user template
939 |
940 | ```javascript
941 | const MarzbanAPI = require('@maniwrld/marzjs');
942 |
943 | const marzban = MarzbanAPI({
944 | domain: 'example.com',
945 | port: 8080,
946 | ssl: true,
947 | username: 'admin',
948 | password: 'securepassword'
949 | });
950 |
951 | (async () => {
952 | try {
953 | const target_template_id = "1";
954 | const response = await marzban.templates.removeUserTemplate(target_template_id);
955 | console.log(response)
956 | } catch (error) {
957 | console.error(`Error deleting template:`, error.message);
958 | }
959 | })();
960 | ```
961 |
962 |
963 |
964 | ### 💻 Get node settings
965 |
966 | ```javascript
967 | const MarzbanAPI = require('@maniwrld/marzjs');
968 |
969 | const marzban = MarzbanAPI({
970 | domain: 'example.com',
971 | port: 8080,
972 | ssl: true,
973 | username: 'admin',
974 | password: 'securepassword'
975 | });
976 |
977 | (async () => {
978 | try {
979 | const node_settings = await marzban.node.getNodeSettings();
980 | console.log(node_settings)
981 | } catch (error) {
982 | console.error(`Error getting node settings:`, error.message);
983 | }
984 | })();
985 | ```
986 |
987 |
988 |
989 | ### 💻 Add node
990 |
991 | ```javascript
992 | const MarzbanAPI = require('@maniwrld/marzjs');
993 |
994 | const marzban = MarzbanAPI({
995 | domain: 'example.com',
996 | port: 8080,
997 | ssl: true,
998 | username: 'admin',
999 | password: 'securepassword'
1000 | });
1001 |
1002 | (async () => {
1003 | try {
1004 | const node_data = {
1005 | "name": "Germany node",
1006 | "address": "192.168.1.1",
1007 | "port": 62050,
1008 | "api_port": 62051,
1009 | "add_as_new_host": false,
1010 | "usage_coefficient": 1
1011 | }
1012 | const node = await marzban.node.addNode(nodeData);
1013 | console.log(node);
1014 | } catch (error) {
1015 | console.error(`Error while adding a new node:`, error.message);
1016 | }
1017 | })();
1018 | ```
1019 |
1020 |
1021 |
1022 | ### 💻 Get node
1023 |
1024 | ```javascript
1025 | const MarzbanAPI = require('@maniwrld/marzjs');
1026 |
1027 | const marzban = MarzbanAPI({
1028 | domain: 'example.com',
1029 | port: 8080,
1030 | ssl: true,
1031 | username: 'admin',
1032 | password: 'securepassword'
1033 | });
1034 |
1035 | (async () => {
1036 | try {
1037 | const target_node_id = "1";
1038 | const node = await marzban.node.getNode(target_node_id);
1039 | console.log(node);
1040 | } catch (error) {
1041 | console.error(`Error while getting a node:`, error.message);
1042 | }
1043 | })();
1044 | ```
1045 |
1046 |
1047 |
1048 | ### 💻 Modify node
1049 |
1050 | ```javascript
1051 | const MarzbanAPI = require('@maniwrld/marzjs');
1052 |
1053 | const marzban = MarzbanAPI({
1054 | domain: 'example.com',
1055 | port: 8080,
1056 | ssl: true,
1057 | username: 'admin',
1058 | password: 'securepassword'
1059 | });
1060 |
1061 | (async () => {
1062 | try {
1063 | const target_node_id = "1";
1064 | const new_node_data = {
1065 | "name": "Germany Node Modified",
1066 | "address": "192.168.1.1",
1067 | "port": 62050,
1068 | "api_port": 62051,
1069 | "status": "disabled",
1070 | "usage_coefficient": 1
1071 | }
1072 | const node = await marzban.node.modifyNode(target_node_id, new_node_data);
1073 | console.log(node);
1074 | } catch (error) {
1075 | console.error(`Error while modifying a node:`, error.message);
1076 | }
1077 | })();
1078 | ```
1079 |
1080 |
1081 |
1082 | ### 💻 Remove node
1083 |
1084 | ```javascript
1085 | const MarzbanAPI = require('@maniwrld/marzjs');
1086 |
1087 | const marzban = MarzbanAPI({
1088 | domain: 'example.com',
1089 | port: 8080,
1090 | ssl: true,
1091 | username: 'admin',
1092 | password: 'securepassword'
1093 | });
1094 |
1095 | (async () => {
1096 | try {
1097 | const target_node_id = "1";
1098 | const node = await marzban.node.removeNode(target_node_id);
1099 | console.log(node);
1100 | } catch (error) {
1101 | console.error(`Error while removing a node:`, error.message);
1102 | }
1103 | })();
1104 | ```
1105 |
1106 |
1107 |
1108 | ### 💻 Get nodes
1109 |
1110 | ```javascript
1111 | const MarzbanAPI = require('@maniwrld/marzjs');
1112 |
1113 | const marzban = MarzbanAPI({
1114 | domain: 'example.com',
1115 | port: 8080,
1116 | ssl: true,
1117 | username: 'admin',
1118 | password: 'securepassword'
1119 | });
1120 |
1121 | (async () => {
1122 | try {
1123 | const nodes = await marzban.node.getNodes();
1124 | console.log(nodes);
1125 | } catch (error) {
1126 | console.error(`Error while retrieving nodes:`, error.message);
1127 | }
1128 | })();
1129 | ```
1130 |
1131 |
1132 |
1133 | ### 💻 Reconnect node
1134 |
1135 | ```javascript
1136 | const MarzbanAPI = require('@maniwrld/marzjs');
1137 |
1138 | const marzban = MarzbanAPI({
1139 | domain: 'example.com',
1140 | port: 8080,
1141 | ssl: true,
1142 | username: 'admin',
1143 | password: 'securepassword'
1144 | });
1145 |
1146 | (async () => {
1147 | try {
1148 | const target_node_id = "1";
1149 | const node = await marzban.node.reconnectNode(target_node_id);
1150 | console.log(node);
1151 | } catch (error) {
1152 | console.error(`Error while retrieving nodes:`, error.message);
1153 | }
1154 | })();
1155 | ```
1156 |
1157 |
1158 |
1159 | ### 💻 Get nodes usage
1160 |
1161 | ```javascript
1162 | const MarzbanAPI = require('@maniwrld/marzjs');
1163 |
1164 | const marzban = MarzbanAPI({
1165 | domain: 'example.com',
1166 | port: 8080,
1167 | ssl: true,
1168 | username: 'admin',
1169 | password: 'securepassword'
1170 | });
1171 |
1172 | (async () => {
1173 | try {
1174 | const nodes_usage = await marzban.node.getNodesUsage();
1175 | console.log(nodes_usage);
1176 | } catch (error) {
1177 | console.error(`Error while retrieving nodes usages:`, error.message);
1178 | }
1179 | })();
1180 | ```
1181 |
1182 |
1183 |
1184 | ### 💻 Get system stats
1185 |
1186 | ```javascript
1187 | const MarzbanAPI = require('@maniwrld/marzjs');
1188 |
1189 | const marzban = MarzbanAPI({
1190 | domain: 'example.com',
1191 | port: 8080,
1192 | ssl: true,
1193 | username: 'admin',
1194 | password: 'securepassword'
1195 | });
1196 |
1197 | (async () => {
1198 | try {
1199 | const system_stats = await marzban.system.getSystemStats();
1200 | console.log(system_stats);
1201 | } catch (error) {
1202 | console.error(`Error while getting system stats:`, error.message);
1203 | }
1204 | })();
1205 | ```
1206 |
1207 |
1208 |
1209 | ### 💻 Get inbounds
1210 |
1211 | ```javascript
1212 | const MarzbanAPI = require('@maniwrld/marzjs');
1213 |
1214 | const marzban = MarzbanAPI({
1215 | domain: 'example.com',
1216 | port: 8080,
1217 | ssl: true,
1218 | username: 'admin',
1219 | password: 'securepassword'
1220 | });
1221 |
1222 | (async () => {
1223 | try {
1224 | const inbounds = await marzban.system.getInbounds();
1225 | console.log(inbounds);
1226 | } catch (error) {
1227 | console.error(`Error while getting inbounds:`, error.message);
1228 | }
1229 | })();
1230 | ```
1231 |
1232 |
1233 |
1234 | ### 💻 Get hosts
1235 |
1236 | ```javascript
1237 | const MarzbanAPI = require('@maniwrld/marzjs');
1238 |
1239 | const marzban = MarzbanAPI({
1240 | domain: 'example.com',
1241 | port: 8080,
1242 | ssl: true,
1243 | username: 'admin',
1244 | password: 'securepassword'
1245 | });
1246 |
1247 | (async () => {
1248 | try {
1249 | const hosts = await marzban.system.getHosts();
1250 | console.log(hosts);
1251 | } catch (error) {
1252 | console.error(`Error while getting hosts:`, error.message);
1253 | }
1254 | })();
1255 | ```
1256 |
1257 |
1258 |
1259 | ### 💻 Modify hosts
1260 |
1261 | ```javascript
1262 | const MarzbanAPI = require('@maniwrld/marzjs');
1263 |
1264 | const marzban = MarzbanAPI({
1265 | domain: 'example.com',
1266 | port: 8080,
1267 | ssl: true,
1268 | username: 'admin',
1269 | password: 'securepassword'
1270 | });
1271 |
1272 | (async () => {
1273 | try {
1274 | const host_data = {
1275 | "VLESS_CDN_INBOUND": [
1276 | {
1277 | "remark": "Germany Node",
1278 | "address": "192.168.1.1",
1279 | "port": 8585,
1280 | "sni": "",
1281 | "host": "",
1282 | "path": "",
1283 | "security": "inbound_default",
1284 | "alpn": "",
1285 | "fingerprint": "",
1286 | "allowinsecure": true,
1287 | "is_disabled": true,
1288 | "mux_enable": true,
1289 | "fragment_setting": "",
1290 | "noise_setting": "",
1291 | "random_user_agent": true
1292 | }
1293 | ]
1294 | };
1295 | const hosts = marzban.system.modifyHosts(host_data);
1296 | console.log(hosts);
1297 | } catch (error) {
1298 | console.error(`Error while modifying hosts:`, error.message);
1299 | }
1300 | })();
1301 | ```
1302 |
1303 |
1304 |
1305 | ### 💻 Get core stats
1306 |
1307 | ```javascript
1308 | const MarzbanAPI = require('@maniwrld/marzjs');
1309 |
1310 | const marzban = MarzbanAPI({
1311 | domain: 'example.com',
1312 | port: 8080,
1313 | ssl: true,
1314 | username: 'admin',
1315 | password: 'securepassword'
1316 | });
1317 |
1318 | (async () => {
1319 | try {
1320 | const core_stats = marzban.core.getCoreStats();
1321 | console.log(core_stats);
1322 | } catch (error) {
1323 | console.error(`Error while getting core stats:`, error.message);
1324 | }
1325 | })();
1326 | ```
1327 |
1328 |
1329 |
1330 | ### 💻 Restart core
1331 |
1332 | ```javascript
1333 | const MarzbanAPI = require('@maniwrld/marzjs');
1334 |
1335 | const marzban = MarzbanAPI({
1336 | domain: 'example.com',
1337 | port: 8080,
1338 | ssl: true,
1339 | username: 'admin',
1340 | password: 'securepassword'
1341 | });
1342 |
1343 | (async () => {
1344 | try {
1345 | const restart_core = marzban.core.restartCore();
1346 | console.log(restart_core);
1347 | } catch (error) {
1348 | console.error(`Error while restarting core:`, error.message);
1349 | }
1350 | })();
1351 | ```
1352 |
1353 |
1354 |
1355 | ### 💻 Get core config
1356 |
1357 | ```javascript
1358 | const MarzbanAPI = require('@maniwrld/marzjs');
1359 |
1360 | const marzban = MarzbanAPI({
1361 | domain: 'example.com',
1362 | port: 8080,
1363 | ssl: true,
1364 | username: 'admin',
1365 | password: 'securepassword'
1366 | });
1367 |
1368 | (async () => {
1369 | try {
1370 | const core_config = marzban.core.getCoreConfig();
1371 | console.log(core_config);
1372 | } catch (error) {
1373 | console.error(`Error while getting core config:`, error.message);
1374 | }
1375 | })();
1376 | ```
1377 |
1378 |
1379 |
1380 | ### 💻 Modify core config
1381 |
1382 | ```javascript
1383 | const fs = require('fs');
1384 | const MarzbanAPI = require('@maniwrld/marzjs');
1385 |
1386 | const marzban = MarzbanAPI({
1387 | domain: 'example.com',
1388 | port: 8080,
1389 | ssl: true,
1390 | username: 'admin',
1391 | password: 'securepassword'
1392 | });
1393 |
1394 | (async () => {
1395 | try {
1396 | const xrayConfigPath = './xray_config.json';
1397 | if (!fs.existsSync(xrayConfigPath)) {
1398 | throw new Error('xray_config.json file not found');
1399 | }
1400 |
1401 | const xrayConfigContent = fs.readFileSync(xrayConfigPath, 'utf8');
1402 | const xrayConfig = JSON.parse(xrayConfigContent);
1403 |
1404 | const coreConfig = await marzban.core.modifyCoreConfig(xrayConfig);
1405 | console.log('Core configuration updated successfully:', coreConfig);
1406 | } catch (error) {
1407 | console.error(`Error while modifying core config:`, error.message);
1408 | }
1409 | })();
1410 | ```
1411 |
1412 | ## 🛡 Error Handling
1413 |
1414 | The library provides comprehensive error handling:
1415 | - Automatic token refresh
1416 | - Detailed error messages
1417 | - Joi input validation
1418 |
1419 | ## 🗺️ Roadmap & Community Forks
1420 |
1421 | ### 📍 Future Development Roadmap
1422 | - [ ] Add TypeScript type definitions
1423 | - [ ] Implement comprehensive unit and integration tests
1424 | - [ ] Enhance WebSocket logging with more filtering options
1425 | - [ ] Create detailed documentation with more comprehensive examples
1426 | - [ ] Add support for more advanced authentication methods
1427 | - [ ] Implement rate limiting and advanced retry strategies
1428 | - [ ] Develop a CLI tool for MarzJS
1429 |
1430 | ### 🌐 Supporting Marzban Forks
1431 | MarzJS aims to maintain compatibility with various Marzban forks to provide a versatile API client:
1432 |
1433 | #### 1. Marzneshin
1434 | - **Repository**: [https://github.com/marzneshin/marzneshin](https://github.com/marzneshin/marzneshin)
1435 | - **Status**: Active development
1436 | - **Compatibility**: Ongoing testing and support planned
1437 | - **Key Features**: Enhanced UI, additional management tools
1438 |
1439 | #### 2. MarzGosha
1440 | - **Repository**: [https://github.com/GFWFuckers/MarzGosha](https://github.com/GFWFuckers/MarzGosha)
1441 | - **Status**: Community-driven fork
1442 | - **Compatibility**: Preliminary support
1443 | - **Unique Characteristics**: Community modifications and extensions
1444 |
1445 | *Note: Compatibility with these forks is an active area of development. Community feedback and contributions are welcome!*
1446 |
1447 | ## 📝 Requirements
1448 |
1449 | - Node.js 12.0.0 or higher
1450 | - Dependencies: axios, ws, qs, joi
1451 |
1452 | ## 🤝 Contributing
1453 |
1454 | 1. Fork the repository
1455 | 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
1456 | 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
1457 | 4. Push to the branch (`git push origin feature/AmazingFeature`)
1458 | 5. Open a Pull Request
1459 |
1460 | ## 📄 License
1461 |
1462 | This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0)
1463 |
1464 | ## 🏷️ Versioning
1465 |
1466 | Current Version: **1.0.9**
1467 | We use [SemVer](http://semver.org/) for versioning.
1468 |
1469 | ## 💌 Support
1470 |
1471 | Encountering issues? [Open an issue](https://github.com/maniwrld/marzjs/issues) on GitHub.
1472 |
1473 | ## ⭐ Support the Project
1474 |
1475 | If you find MarzJS useful, please give it a star on [GitHub](https://github.com/maniwrld/marzjs)! It helps us stay motivated and grow the project.
1476 |
--------------------------------------------------------------------------------
/classes/Admin.js:
--------------------------------------------------------------------------------
1 | const { adminCreateSchema, adminModifySchema, adminPartialModifySchema } = require('../schemas/AdminSchemas');
2 |
3 | class Admin {
4 | constructor(api) {
5 | this.api = api;
6 | }
7 |
8 | /**
9 | * Get the current authenticated admin's details
10 | * Retrieves information about the admin currently authenticated with the API.
11 | * @returns {Promise