{"_id":"3xworkaround","_rev":"2-f86ac2cb901bd5ed8f0f1956cfe461f0","name":"3xworkaround","dist-tags":{"latest":"2.2.1"},"versions":{"2.1.1":{"name":"3xworkaround","version":"2.1.1","keywords":["api"],"author":{"url":"https://github.com/mehdikhody","name":"Mehdi Khodayari","email":"khodayari.khoram@gmail.com"},"_id":"3xworkaround@2.1.1","maintainers":[{"name":"gkiselev","email":"kiselevgeorgy@gmail.com"}],"homepage":"https://github.com/mehdikhody/3x-ui-js#readme","bugs":{"url":"https://github.com/mehdikhody/3x-ui-js/issues"},"dist":{"shasum":"15da50e47e35bcad5f67f25d98b628f46243fc81","tarball":"https://registry.npmjs.org/3xworkaround/-/3xworkaround-2.1.1.tgz","fileCount":27,"integrity":"sha512-PMVi6iBHqXuYKgbTcDRvG/4Ms6xKcFAg2k9ml7cOmjQ9Uyq/VOqG2ODAQdb0c2pXn9+VbXmMHfRnTNKZYTAEKA==","signatures":[{"sig":"MEUCIQDdcAhtyJFhb6vck5S+R/quKu3jRhYI5P6Rx0IpUQ2T8gIgNbRlcW/h2XCfVwSPadx6X98CyJBrTai5dcBRlpGqVj0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37316},"main":"build/index.js","type":"module","types":"build/index.d.ts","gitHead":"c1112a4dd8e9ec959cd5f827a7d8329b561433ff","scripts":{"test":"vitest .","build":"tsc -p tsconfig.build.json && resolve-tspaths","format":"prettier --write ."},"_npmUser":{"name":"gkiselev","email":"kiselevgeorgy@gmail.com"},"repository":{"url":"git+https://github.com/mehdikhody/3x-ui-js.git","type":"git"},"_npmVersion":"10.7.0","description":"This is workaround version.","directories":{},"_nodeVersion":"20.14.0","dependencies":{"qs":"^6.11.2","axios":"^1.6.4","winston":"^3.11.0","url-join":"^5.0.0","node-cache":"^5.1.2","async-mutex":"^0.5.0","proxy-agent":"^6.3.1"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.6.2","zod":"^3.23.8","eslint":"^8.55.0","vitest":"^2.1.2","prettier":"^3.1.0","xray-zod":"^1.0.0","@types/qs":"^6.9.11","typescript":"^5.3.3","@types/node":"^20.16.11","@faker-js/faker":"^9.0.3","resolve-tspaths":"^0.8.22","vite-tsconfig-paths":"^5.0.1","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.0.1","@typescript-eslint/parser":"^6.13.2","@typescript-eslint/eslint-plugin":"^6.13.2"},"_npmOperationalInternal":{"tmp":"tmp/3xworkaround_2.1.1_1731675902203_0.7941519340614904","host":"s3://npm-registry-packages"}},"2.2.1":{"name":"3xworkaround","description":"This is an interface for 3x-ui panel. It will help developers to create, edit and delete inbounds and clients in a simple way.","version":"2.2.1","type":"module","main":"build/cjs/index.js","module":"build/esm/index.js","exports":{".":{"import":"./build/esm/index.js","require":"./build/cjs/index.js","types":"./build/esm/index.d.ts"}},"types":"build/esm/index.d.ts","author":{"name":"Mehdi Khodayari","email":"khodayari.khoram@gmail.com","url":"https://github.com/mehdikhody"},"scripts":{"build":"npm run build:clean && npm run build:esm && npm run build:cjs && npm run build:package-json","build:clean":"rm -rf build","build:esm":"tsc -p tsconfig.esm.json && resolve-tspaths -p tsconfig.esm.json","build:cjs":"tsc -p tsconfig.cjs.json && resolve-tspaths -p tsconfig.cjs.json","build:package-json":"node build-utils.js","format":"prettier --write .","test":"vitest ."},"devDependencies":{"@faker-js/faker":"^9.0.3","@types/node":"^20.16.11","@types/qs":"^6.9.11","@typescript-eslint/eslint-plugin":"^6.13.2","@typescript-eslint/parser":"^6.13.2","eslint":"^8.55.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.0.1","prettier":"^3.1.0","resolve-tspaths":"^0.8.22","tsx":"^4.6.2","typescript":"^5.3.3","vite-tsconfig-paths":"^5.0.1","vitest":"^2.1.2","xray-zod":"^1.0.0","zod":"^3.23.8"},"dependencies":{"async-mutex":"^0.5.0","axios":"^1.6.4","node-cache":"^5.1.2","proxy-agent":"^6.3.1","qs":"^6.11.2","url-join":"^5.0.0","winston":"^3.11.0"},"keywords":["xray","x-ui","3x-ui","3x-ui-js"],"repository":{"type":"git","url":"git+https://github.com/mehdikhody/3x-ui-js.git"},"_id":"3xworkaround@2.2.1","gitHead":"ca24a46e888964d484ee092b9ee0a4d7efb63033","bugs":{"url":"https://github.com/mehdikhody/3x-ui-js/issues"},"homepage":"https://github.com/mehdikhody/3x-ui-js#readme","_nodeVersion":"20.19.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-aDagZAk9es2sB+Z90rFwYizfOj7ke3+xsRWJal89iJwwVZJESpSBSHnPaBtttCFxPwRV2rawzb6zUKRCAP7stg==","shasum":"34cd7197a3743b8545a031ea910bc94505bb1662","tarball":"https://registry.npmjs.org/3xworkaround/-/3xworkaround-2.2.1.tgz","fileCount":56,"unpackedSize":72564,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEuGpBnlz1LEv/x/N88x+xukgrP+7PmlkzjvXhvrduySAiA3WNXNfNUnMJJpAGmx9dN50vcePJ02JLlFYIkhgcB/jw=="}]},"_npmUser":{"name":"gkiselev","email":"kiselevgeorgy@gmail.com","actor":{"name":"gkiselev","email":"kiselevgeorgy@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"gkiselev","email":"kiselevgeorgy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/3xworkaround_2.2.1_1751806483886_0.9349091659471036"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-15T13:05:02.202Z","modified":"2025-07-06T12:54:44.278Z","2.1.1":"2024-11-15T13:05:02.395Z","2.2.1":"2025-07-06T12:54:44.081Z"},"bugs":{"url":"https://github.com/mehdikhody/3x-ui-js/issues"},"author":{"name":"Mehdi Khodayari","email":"khodayari.khoram@gmail.com","url":"https://github.com/mehdikhody"},"homepage":"https://github.com/mehdikhody/3x-ui-js#readme","keywords":["xray","x-ui","3x-ui","3x-ui-js"],"repository":{"type":"git","url":"git+https://github.com/mehdikhody/3x-ui-js.git"},"description":"This is an interface for 3x-ui panel. It will help developers to create, edit and delete inbounds and clients in a simple way.","maintainers":[{"name":"gkiselev","email":"kiselevgeorgy@gmail.com"}],"readme":"# 3x-ui Node.js SDK\n\nThe 3x-ui is a JavaScript library designed to facilitate communication with the [3x-ui panel](https://github.com/MHSanaei/3x-ui), which runs Xray Core for proxy services. This SDK empowers JavaScript developers to create bots and websites for both commercial and non-commercial uses, providing simplicity, abstraction around the API, caching for improved performance, and mutex for asynchronous safety.\n\nThis package is developed based on [MHSanaei Postman Collection](https://documenter.getpostman.com/view/16802678/2s9YkgD5jm#9cac8101-017e-4415-94e2-d30f4dcf49de) and you can check it out for more information.\n\n### Features\n\n-   ✅ **Simplicity**: Designed with simplicity in mind to streamline the process of interacting with the 3x-ui panel.\n-   ✅ **Abstraction**: Provides an abstraction layer around the 3x-ui API to simplify finding clients by email, uuid (vmess, vless) or password (trojan).\n-   ✅ **Proxy:** Utilizes an underlying proxy agent for communication with the panel if needed.\n-   ✅ **Caching:** Caches responses for improved performance.\n-   ✅ **Mutex:** Provides a mutex, a lock mechanism, to ensure asynchronous safety and prevent race conditions.\n-   ✅ **Debug Mode:** Enables debug mode for detailed logging.\n-   ✅ **TTL:** Allows you to set the cache time in seconds.\n\n## Installation\n\nTo install the 3x-ui SDK, use npm:\n\n```bash\nnpm install 3x-ui\n```\n\n## Usage\n\nFirst, import the SDK:\n\n```js\nimport { XuiApi } from \"3x-ui\";\n```\n\nInitialize the SDK with the URL of your 3x-ui panel:\n\n```js\nconst api = new XuiApi(\"http://username:password@localhost:2053\");\napi.debug = true; // Enables debug mode - defualt is false\napi.stdTTL = 60; // Cache time in seconds - default is 10s\n```\n\nThen, you can utilize the SDK functions:\n\n```js\nconst inbounds = await api.getInbounds();\nconst clientStat = await api.getClient(\"email or clientId\");\nconst clientOptions = await api.getClientOptions(\"email or clientId\");\nconst onlines = await api.getOnlineClients();\n```\n\n## Proxy\n\nThe SDK uses an underlying proxy agent to connect to the panel. You can specify the proxy settings using environment variables such as HTTP_PROXY and HTTPS_PROXY. Refer to the proxy-agent [documentation](https://www.npmjs.com/package/proxy-agent) for more information.\n\n```env\nHTTP_PROXY=\"http://proxy-server-over-tcp.com:3128\"\nHTTPS_PROXY=\"https://proxy-server-over-tls.com:3129\"\n```\n\n## API\n\n### Inbounds\n\n-   `getInbounds()`: Returns an array of all inbounds.\n-   `getInbound(id: number)`: Returns the inbound with the specified ID.\n-   `addInbound(options: InboundOptions)`: Adds a new inbound with the provided options.\n-   `updateInbound(id: number, options: Partial<InboundOptions>)`: Updates the inbound with the specified ID using the provided options.\n-   `resetInboundsStat()`: Resets statistics for all inbounds.\n-   `resetInboundStat(id: number)`: Resets statistics for the inbound with the specified ID.\n-   `deleteInbound(id: number)`: Deletes the inbound with the specified ID.\n\n### Clients\n\n-   `getClient(clientId: string)`: Returns a client with the given `email` or `clientId`.\n-   `getClientIps(clientId: string)`: Returns all client's IPs with the given `email` or `clientId`.\n-   `getClientOptions(clientId: string)`: Returns all client's options with the given `email` or `clientId`.\n-   `addClient(inboundId: number, options: ClientOptions)`: Adds a new client with the given options.\n-   `updateClient(clientId: string, options: Partial<ClientOptions>)`: Updates a client with the given `email` or `clientId`.\n-   `resetClientIps(clientId: string)`: Resets all client's IPs with the given `email` or `clientId`.\n-   `resetClientStat(clientId: string)`: Resets a client's stat with the given `email` or `clientId`.\n-   `deleteClient(clientId: string)`: Deletes a client with the given `email` or `clientId`.\n-   `deleteDepletedClients()`: Deletes all clients that have depleted their traffic.\n-   `deleteInboundDepletedClients(inboundId: number)`: Deletes all clients of an inbound that have depleted their traffic.\n-   `getOnlineClients()`: Returns all online clients.\n\n### Other Functions\n\n-   `sendBackup()`: send backup file via Telegram bot.\n\n## Example\n\nFor more examples, check out [the test directory on our GitHub repository](https://github.com/mehdikhody/3x-ui-js/tree/master/tests).\n","readmeFilename":"README.md"}