3x-ui wrapper for python
Project description
Hi! This is my example python 3x-ui wrapper!
I'm not expecting much to be honest, so please feel free to fork it if I abandon the project and you need it!
Also, if you REALLY want it I can give you the ownership if I step down, you can find my email in the pyproject.toml (I don't check it that much but trust me I do)
0.1.3 Release Notes
Adds Hysteria2 support for inbounds and client provisioning.New: Hysteria2 support
Inbound.protocolnow accepts"hysteria"alongside"vless"and"vmess".SingleInboundClientgains anauthfield (the Hysteria2 secret). A newmodel_validator,ensure_auth_or_id_present, requires eitherauth(Hysteria2) oruuid(everything else).uuidnow defaults to"", and both fields are dropped from the serialized payload when empty.create_and_add_prod_clientdetectshysteriainbounds and emits a random per-clientauthinstead of the deterministic Telegram-ID-derived UUID it uses for VLESS/VMess.
Misc
- New
trust_envconstructor kwarg, forwarded tohttpx.AsyncClient. Defaults toTrue; setFalseto make httpx ignore the environment's proxy/SSL config — handy behind a socks4 proxy httpx can't use.
0.1.1r1 Release Notes
First "middle" version. Brings 3X-UI 3.0.0+ panel support and a client-side workaround for the panel's new duplicate-email behavior.New: 3.0.0+ panel auth
Three new XUIClient constructor kwargs:
use_new_schema=True— switcheslogin()to the 3.0.0+ flow. Required for any 3.0.0+ panel.bearer_token=...— long-lived API token from the panel. Required whenuse_new_schema=True; wrapped inSecretStrinternally and sent asAuthorization: Bearer <...>on every request.force_login=True— additive on top of bearer. Coins a CSRF token (/csrf-token) and runs the cookie-login on top, for routes that still need it.
SessionCore.login() becomes a 3-branch dispatcher; the existing 2.X.X cookie-only flow is unchanged when use_new_schema=False.
Three new exceptions, all re-exported via python_3xui.exceptions:
SchemaMismatchError— constructor-time.use_new_schema=Truewith nobearer_token.InvalidBearerTokenError— runtime. A 404 in pure-bearer mode would otherwise loop intologin()re-setting the same (bad) header; the request now fast-fails instead.CsrfTokenNotCoined— runtime./csrf-tokendidn't return a usableobj; the panel is almost certainly down.
New: client-side duplicate-email guard
3X-UI 3.0.0+ silently accepts duplicate client emails on add instead of hard-rejecting them, which broke the "duplicate email" response-msg scan that drove exist_ok / replace_if_exist in create_and_add_prod_client. Workaround landed in this release:
- New
guard_duplicate_emailsXUIClientkwarg. Defaults touse_new_schema(on for 3.0.0+, off for 2.X.X). PassTrue/Falseto force. - New
guard_duplicatesper-call override oncreate_and_add_prod_client. - When active, the method burst-probes
get_client_with_emailfor every production inbound's deterministic(tgid, inbid)email before adding. Hits become aconflicts: dict[int, ClientStats]map; the panel add is skipped for those inbounds. exist_ok,replace_if_exist, and raise-on-default all keep their original semantics — the guard just feeds them.replace_if_existeven saves a round-trip vs the old path, since the guard already has the existing client's uuid.- Return type widens to
dict[int, Response | None].Noneappears only withexist_ok=Trueand noreplace_if_exist, for the inbounds the guard short-circuited.
Fixes & misc
SchemaMismatchErrormessage rendered as a tuple instead of formatted; switched the call site to an f-string.tests/conftest.pynow requiresBEARERin the env-var precheck; without it the fixture would raiseSchemaMismatchErrorat construction instead of skipping cleanly.- Stale
FIXMEcomment removed fromSessionCore.login. cachetoolspin relaxed to~=7.1.1.- Public exception surface now also exports
CsrfTokenNotCoined,SchemaMismatchError, andInvalidBearerTokenErrorviapython_3xui.exceptions.
0.0.12 Release Notes
Mainly just bugfixes. Fix email fallback, fix adding clients, add inbound management.Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_3xui-0.1.3.tar.gz.
File metadata
- Download URL: python_3xui-0.1.3.tar.gz
- Upload date:
- Size: 45.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f424b5219c6a26b2549a2c27f36d6c0dfeb149bd31a6174215705621a4a7bf1
|
|
| MD5 |
a450927668ecdc2e9b8a85ec4756a244
|
|
| BLAKE2b-256 |
38cc36a14771aa21ca9569de61131404a2add0b9af94380a6bfaae0716f80cdf
|
File details
Details for the file python_3xui-0.1.3-py3-none-any.whl.
File metadata
- Download URL: python_3xui-0.1.3-py3-none-any.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e35d7a281b8c68c3c9e1afd34a74a2adfbfbdbb6ac243f7297299beaf5bf2d3c
|
|
| MD5 |
f5dc043ee562a5c1f149162d68d20122
|
|
| BLAKE2b-256 |
a4a404e04751f91fce5737e25ca385a788b02231855078415460877099f01c8b
|