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.Release files for Python-3xui 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_3xui-0.1.3.tar.gz | 45.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_3xui-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 84.3 kB
Release files / python_3xui-0.1.3.tar.gz
| Download URL | python_3xui-0.1.3.tar.gz |
|---|---|
| Size | 45.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f424b5219c6a26b2549a2c27f36d6c0dfeb149bd31a6174215705621a4a7bf1
|
|
BLAKE2b-256 checksum How to use checksums |
38cc36a14771aa21ca9569de61131404a2add0b9af94380a6bfaae0716f80cdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / python_3xui-0.1.3-py3-none-any.whl
| Download URL | python_3xui-0.1.3-py3-none-any.whl |
|---|---|
| Size | 38.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e35d7a281b8c68c3c9e1afd34a74a2adfbfbdbb6ac243f7297299beaf5bf2d3c
|
|
BLAKE2b-256 checksum How to use checksums |
a4a404e04751f91fce5737e25ca385a788b02231855078415460877099f01c8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|