Coder Social home page Coder Social logo

xui.client's Introduction

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('link', 'username','password');
        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, "[email protected]", "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.

xui.client's People

Contributors

zellias avatar

Stargazers

psychotaha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.