Skip to main content

xuipy

A Python client for the 3x-ui panel, covering inbounds, clients, and server management.

Installing

pip install xuipy

Quick start

from xuipy import XUI

xui = XUI(
    base_url="https://your-panel-url.com",
    username="admin",
    password="admin",
)

for client in xui.get_clients():
    print(client["email"])

Authentication

Username and password:

xui = XUI(base_url="https://your-panel-url.com", username="admin", password="admin")

Base URL

Use the exact address you use to access your panel in a browser:

https://your-panel-url.com
https://your-panel-url.com:2053

API token

xui = XUI(base_url="https://your-panel-url.com", api_token="your-token-here")

You can get a token from the panel UI under Settings → Security → API Token, or generate one from code:

token = xui.create_api_token("new-token")
print(token["token"])  # shown only once 

Usage

Inbounds

xui.get_inbounds()                  # list every inbound
xui.get_inbound(1)                  # fetch one by id

xui.add_inbound({
    "remark": "my-inbound",
    "protocol": "vless",
    "port": 20000,
    "enable": True,
    "expiryTime": 0,
    "settings": {"clients": [], "decryption": "none"},
    "streamSettings": {"network": "tcp", "security": "none"},
    "sniffing": {"enabled": True, "destOverride": ["http", "tls", "quic", "fakedns"]},
})

xui.set_inbound_enable(1, False)    # disable
xui.reset_inbound_traffic(1)        # zero out traffic counters
xui.delete_inbound(1)               # remove

Clients

Fetch clients:

xui.get_clients()                    # every client, across all inbounds
xui.get_client("new-user")           # one client's full details

Add a client:

xui.add_client(
    email="new-user",
    inbound_ids=None,          # attach to all current inbounds by default
    expiry_days=30,             # 0 = never expires
    total_gb=10,                 # 0 = unlimited
    limit_ip=2,                  # 0 = unlimited simultaneous IPs
)

Update a client:

xui.update_client(
    "new-user",
    total_gb=20,
    expiry_days=60,
)

Enable or disable a client:

xui.update_client("new-user", enable=False)

Connection info:

xui.get_client_links("new-user")     # proxy links (vless://, vmess://, ...)
xui.get_client_traffic("new-user")   # up/down usage
xui.get_client_ips("new-user")       # connected source IPs

Reset traffic:

xui.reset_client_traffic("new-user")

Delete a client:

xui.delete_client("new-user")
xui.delete_client("new-user", keep_traffic=True)  # keep the traffic record

Server

xui.get_server_status()      # CPU, memory, disk, Xray state
xui.get_logs(count=50)       # last 50 lines of the panel log

API tokens

xui.get_api_tokens()                          # list every token
xui.create_api_token("new-token")          # mint a new one — it's shown once
xui.set_api_token_enabled(token_id, False)    # disable without deleting
xui.delete_api_token(token_id)                # permanently revoke

More examples covering these and other flows are in examples/.

License

MIT

Metadata

Release files for xuipy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xuipy 0.1.0
File Size Uploaded
xuipy-0.1.0.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xuipy 0.1.0
File Interpreter ABI Platform
xuipy-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.3 kB

Release files / xuipy-0.1.0.tar.gz

Download URL xuipy-0.1.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f5898c8065f3a7f2a8a2155cdb647e62808f75e16302e18fc30354b5e02e18e1
BLAKE2b-256 checksum
How to use checksums
a51ed7aeabd74b9428b978a2a88b81f459e2c66a3f2b9a6d45b0181ed355ceb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / xuipy-0.1.0-py3-none-any.whl

Download URL xuipy-0.1.0-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70f085428e4d645d388426deec7d6dbcc1cd2486ed638f1ea20c39f57a7b67c4
BLAKE2b-256 checksum
How to use checksums
ab42b39667406583496cd914fc716aea84978f6a9f4537d0c97058ebf2b8a473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page