📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

xui-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

xui-client

A nodejs friendly library for xui panel

1.0.3
unpublished
latest
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

xui-client Library

Alt Text

This is a Node.js client library for interacting with XUI-PANEL.

Join Discord Server

Installation

You can install this library using npm:

npm install xui-client

Usage

Here's how you can use this library in your Node.js application:

const { XuiPanelClient,BitConverter } = require('xui-client');

async function main() {
    const xui = new XuiPanelClient();

        await xui.login('http://full.fafaamir.xyz:2002', 'Fatima','Fatima');
        const listData = await xui.list();
        
        // Datas you can get
        console.log(console.log(listData.obj[0].clientStats))
        console.log(console.log(listData.obj[0].down))
        console.log(console.log(listData.obj[0].enable))
        console.log(console.log(listData.obj[0].expiryTime))
        console.log(console.log(listData.obj[0].id))
        console.log(console.log(listData.obj[0].listen))
        console.log(console.log(listData.obj[0].port))
        console.log(console.log(listData.obj[0].protocol))
        console.log(console.log(listData.obj[0].remark))
        console.log(console.log(listData.obj[0].settings))
        console.log(console.log(listData.obj[0].sniffing))
        console.log(console.log(listData.obj[0].tag))
        console.log(console.log(listData.obj[0].total))
        console.log(console.log(listData.obj[0].up))

        xui.addClient(1, "te2st@example.com", "client2-uuid").then((response) => {
            console.log(response);
        });
}

main();

API Documentation

API DOCUMENT GIF

XuiPanelClient

constructor()

Creates a new XUI-PANEL client.

login(url, username, password) Logs in to a specified XUI-PANEL URL using the provided username and password.

url (string): The URL where the login should be performed. username (string): The username for authentication. password (string): The password for authentication. Returns a Promise that resolves with the Axios response containing cookies when the login is successful or rejects on failure.

list() Fetches a list from the XUI-PANEL using the current session cookies.

Returns a Promise that resolves with the list data or rejects on failure.

BitConverter

Utility class for bit conversions.

bitsToKilobytes(bits) Converts bits to kilobytes.

bits (number): The number of bits to convert. Returns the equivalent value in kilobytes.

bitsToMegabytes(bits) Converts bits to megabytes.

bits (number): The number of bits to convert. Returns the equivalent value in megabytes.

bitsToGigabytes(bits) Converts bits to gigabytes.

bits (number): The number of bits to convert. Returns the equivalent value in gigabytes.

addClient(inboundId, email, uuid, enable = true, flow = "", limitIp = 0, totalGb = 0, expireTime = 0, telegramId = "", subscriptionId = "") Adds a new client to an existing inbound in the XUI-PANEL.

Parameters:

  • inboundId (number): The ID of the inbound where the client will be added.
  • email (string): The email address of the client.
  • uuid (string): The UUID (Universally Unique Identifier) of the client.
  • enable (boolean, optional): Whether the client is enabled. Default is true.
  • flow (string, optional): The flow associated with the client. Default is an empty string.
  • limitIp (number, optional): The IP limit for the client. Default is 0 (no limit).
  • totalGb (number, optional): The total data transfer limit for the client in gigabytes. Default is 0 (no limit).
  • expireTime (number, optional): The client's expiration time in timestamp (epoch) format. Default is 0 (no expiration).
  • telegramId (string, optional): The Telegram ID of the client. Default is an empty string.
  • subscriptionId (string, optional): The subscription ID of the client. Default is an empty string.

Returns a Promise that resolves with a boolean indicating the success of adding the client or rejects on failure.

Keywords

xui

FAQs

Package last updated on 17 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts