npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xui.client

v1.0.3

Published

A nodejs friendly library for xui panel

Downloads

12

Readme

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.