mehdikhody / 3x-ui-js

This is an interface for 3x-ui panel. It will help developers to create, edit and delete inbounds and clients in a simple way.
5 stars 2 forks source link
3x-ui v2ray x-ui

3x-ui Node.js SDK

The 3x-ui is a JavaScript library designed to facilitate communication with the 3x-ui panel, 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.

This package is developed based on MHSanaei Postman Collection and you can check it out for more information.

Features

Installation

To install the 3x-ui SDK, use npm:

npm install 3x-ui

Usage

First, import the SDK:

import { Panel } from "3x-ui";

Initialize the SDK with the URL of your 3x-ui panel:

const api = new Panel("http://username:password@localhost:2053");
api.debug = true; // Enables debug mode - defualt is false
api.stdTTL = 60; // Cache time in seconds - default is 10s

Then, you can utilize the SDK functions:

const inbounds = await api.getInbounds();
const clientStat = await api.getClient("email or uuid or password");
const clientOptions = await api.getClientOptions("email or uuid or password");
const onlines = await api.getOnlineClients();

Proxy

The 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 for more information.

HTTP_PROXY="http://proxy-server-over-tcp.com:3128"
HTTPS_PROXY="https://proxy-server-over-tls.com:3129"

API

Inbounds

Clients

Other Functions

Example

For more examples, check out the example directory on our GitHub repository.