# PyXUI
An application with python that allows you to modify your xui panel ([alireza0 x-ui](https://github.com/alireza0/x-ui)) ([Sanaeii 3x-ui](https://github.com/MHSanaei/3x-ui))
## How To Install
```
pip install pyxui_async
```
## How To Use
- Import pyxui in your .py file
```python
from pyxui_async import XUI
# Basic:
xui = XUI(
full_address="https://staliox.com:2087",
panel="alireza", # Your panel name, "alireza" or "sanaei"
)
# Advanced:
xui = XUI(
full_address="http://staliox.site:2087",
panel="alireza", # Your panel name, "alireza" or "sanaei"
https=False, # Make note if you don't use https set False else set True
session_string=... # If you have session cookie to use panel without login
)
```
- Login in your panel
```python
from pyxui_async.errors import BadLogin
try:
await xui.login(USERNAME, PASSWORD)
except BadLogin:
...
```
- Get inbounds list
```python
get_inbounds = await xui.get_inbounds()
# Result
{
"success": true,
"msg": "",
"obj": [
{
"id": 1,
"up": 552345026,
"down": 18164200325,
"total": 0,
"remark": "Staliox",
"enable": true,
"expiryTime": 0,
"clientStats": [
{
"id": 1,
"inboundId": 1,
"enable": true,
"email": "Me",
"up": 191308877,
"down": 4945030148,
"expiryTime": 0,
"total": 0
}
],
"listen": "",
"port": 443,
"protocol": "vless",
"settings": "{\n \"clients\": [\n {\n \"email\": \"Me\",\n \"enable\": true,\n \"expiryTime\": 0,\n \"flow\": \"\",\n \"id\": \"c6419651-68d7-gfhg-d611-32v5df41g105\",\n \"limitIp\": 0,\n \"subId\": \"\",\n \"tgId\": \"@staliox\",\n \"totalGB\": 0\n }\n ],\n \"decryption\": \"none\",\n \"fallbacks\": []\n}",
"tag": "inbound-443",
"sniffing": "{\n \"enabled\": true,\n \"destOverride\": [\n \"http\",\n \"tls\"\n ]\n}"
}
]
}
```
- Add client to the existing inbound
```python
get = await xui.add_client(
inbound_id=1,
email="example@gmal.com",
uuid="5d3d1bac-49cd-4b66-8be9-a728efa205fa",
enable = True,
flow = "",
limit_ip = 0,
total_gb = 5368709120,
expire_time = 1684948641772, # You must pass 13 digit timestamp
telegram_id = "",
subscription_id = ""
)
```
- Update the existing client
```python
get = await xui.update_client(
inbound_id=1,
email="example@gmal.com",
uuid="5d3d1bac-49cd-4b66-8be9-a728efa205fa",
enable = True,
flow = "",
limit_ip = 0,
total_gb = 5368709120,
expire_time = 1684948641772,
telegram_id = "",
subscription_id = ""
)
```
- Get client's information:
```python
get_client = await xui.get_client(
inbound_id=1,
email="Me",
uuid="5d3d1bac-49cd-4b66-8be9-a728efa205fa" # Make note you don't have to pass both of them (emaill, uuid), just one is enough
)
# Result
{
'email': 'Me',
'enable': True,
'expiryTime': 0,
'flow': 'xtls-rprx-vision',
'id': '5d3d1bac-49cd-4b66-8be9-a728efa205fa',
'limitIp': 0,
'subId': '',
'tgId': '',
'totalGB': 0
}
```
- Get client's statistics:
```python
get_client = await xui.get_client_stats(
inbound_id=1,
email="Me",
)
# Result
{
'id': 1,
'inboundId': 1,
'enable': True,
'email': 'Me',
'up': 111494230,
'down': 620533614,
'expiryTime': 0,
'total': 0
}
```
- Delete client from the existing inbound:
```python
get_client = await xui.delete_client(
inbound_id=1,
email="Me",
uuid="5d3d1bac-49cd-4b66-8be9-a728efa205fa" # Make note you don't have to pass both of them (email, uuid), just one is enough
)
```
# Create vmess and vless config string
- Import config_generator
```python
from pyxui_async.config_gen import config_generator
```
- VMESS:
```python
config = {
"v": "2",
"ps": "Staliox-Me",
"add": "staliox.com",
"port": "443",
"id": "a85def57-0a86-43d1-b15c-0494519067c6",
"aid": "0",
"scy": "auto",
"net": "tcp",
"type": "ws",
"host": "staliox.site",
"path": "/",
"tls": "tls",
"sni": "staliox.site",
"alpn": "h2,http/1.1",
"fp": "chrome"
}
generate_config = config_generator("vmess", config)
# Result
vmess://eyJ2IjogIjIiLCAicHMiOiAiU3RhbGlveC1NZSIsICJhZGQiOiAic3RhbGlveC5jb20iLCAicG9ydCI6ICI0NDMiLCAiaWQiOiAiYTg1ZGVmNTctMGE4Ni00M2QxLWIxNWMtMDQ5NDUxOTA2N2M2IiwgImFpZCI6ICIwIiwgInNjeSI6ICJhdXRvIiwgIm5ldCI6ICJ0Y3AiLCAidHlwZSI6ICJ3cyIsICJob3N0IjogInN0YWxpb3guc2l0ZSIsICJwYXRoIjogIi8iLCAidGxzIjogInRscyIsICJzbmkiOiAic3RhbGlveC5zaXRlIiwgImFscG4iOiAiaDIsaHR0cC8xLjEiLCAiZnAiOiAiY2hyb21lIn0=
```
- VLESS:
```python
config = {
"ps": "Staliox-Me",
"add": "staliox.com",
"port": "443",
"id": "a85def57-0a86-43d1-b15c-0494519067c6"
}
data = {
"security": "tls",
"type": "ws",
"host": "staliox.site",
"path": "/",
"sni": "staliox.site",
"alpn": "h2,http/1.1",
"fp": "chrome"
}
generate_config = config_generator("vless", config, data)
# Result
vless://a85def57-0a86-43d1-b15c-0494519067c6@staliox.com:443?security=tls&type=ws&host=staliox.site&path=%2F&tls=tls&sni=staliox.site&alpn=h2%2Chttp%2F1.1&fp=chrome#Staliox-Me
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ARLIKIN/pyxui_async",
"name": "pyxui-async",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "pyxui async, xui, xui python, xui panel",
"author": "Staliox, ARLIKIN",
"author_email": null,
"download_url": null,
"platform": null,
"description": "# PyXUI \nAn application with python that allows you to modify your xui panel ([alireza0 x-ui](https://github.com/alireza0/x-ui)) ([Sanaeii 3x-ui](https://github.com/MHSanaei/3x-ui)) \n\n## How To Install\n```\npip install pyxui_async\n```\n\n## How To Use\n- Import pyxui in your .py file\n\n```python\nfrom pyxui_async import XUI\n\n# Basic:\nxui = XUI(\n full_address=\"https://staliox.com:2087\",\n panel=\"alireza\", # Your panel name, \"alireza\" or \"sanaei\"\n)\n\n# Advanced:\nxui = XUI(\n full_address=\"http://staliox.site:2087\",\n panel=\"alireza\", # Your panel name, \"alireza\" or \"sanaei\"\n https=False, # Make note if you don't use https set False else set True\n session_string=... # If you have session cookie to use panel without login\n)\n```\n\n- Login in your panel\n\n```python\nfrom pyxui_async.errors import BadLogin\n\ntry:\n await xui.login(USERNAME, PASSWORD)\nexcept BadLogin:\n ...\n```\n\n- Get inbounds list\n```python\nget_inbounds = await xui.get_inbounds()\n\n# Result\n{\n \"success\": true,\n \"msg\": \"\",\n \"obj\": [\n {\n \"id\": 1,\n \"up\": 552345026,\n \"down\": 18164200325,\n \"total\": 0,\n \"remark\": \"Staliox\",\n \"enable\": true,\n \"expiryTime\": 0,\n \"clientStats\": [\n {\n \"id\": 1,\n \"inboundId\": 1,\n \"enable\": true,\n \"email\": \"Me\",\n \"up\": 191308877,\n \"down\": 4945030148,\n \"expiryTime\": 0,\n \"total\": 0\n }\n ],\n \"listen\": \"\",\n \"port\": 443,\n \"protocol\": \"vless\",\n \"settings\": \"{\\n \\\"clients\\\": [\\n {\\n \\\"email\\\": \\\"Me\\\",\\n \\\"enable\\\": true,\\n \\\"expiryTime\\\": 0,\\n \\\"flow\\\": \\\"\\\",\\n \\\"id\\\": \\\"c6419651-68d7-gfhg-d611-32v5df41g105\\\",\\n \\\"limitIp\\\": 0,\\n \\\"subId\\\": \\\"\\\",\\n \\\"tgId\\\": \\\"@staliox\\\",\\n \\\"totalGB\\\": 0\\n }\\n ],\\n \\\"decryption\\\": \\\"none\\\",\\n \\\"fallbacks\\\": []\\n}\",\n \"tag\": \"inbound-443\",\n \"sniffing\": \"{\\n \\\"enabled\\\": true,\\n \\\"destOverride\\\": [\\n \\\"http\\\",\\n \\\"tls\\\"\\n ]\\n}\"\n }\n ]\n}\n```\n\n- Add client to the existing inbound\n```python\nget = await xui.add_client(\n inbound_id=1,\n email=\"example@gmal.com\",\n uuid=\"5d3d1bac-49cd-4b66-8be9-a728efa205fa\",\n enable = True,\n flow = \"\",\n limit_ip = 0,\n total_gb = 5368709120,\n expire_time = 1684948641772, # You must pass 13 digit timestamp\n telegram_id = \"\",\n subscription_id = \"\"\n)\n```\n\n- Update the existing client\n```python\nget = await xui.update_client(\n inbound_id=1,\n email=\"example@gmal.com\",\n uuid=\"5d3d1bac-49cd-4b66-8be9-a728efa205fa\",\n enable = True,\n flow = \"\",\n limit_ip = 0,\n total_gb = 5368709120,\n expire_time = 1684948641772,\n telegram_id = \"\",\n subscription_id = \"\"\n)\n```\n\n- Get client's information:\n```python\nget_client = await xui.get_client(\n inbound_id=1,\n email=\"Me\",\n uuid=\"5d3d1bac-49cd-4b66-8be9-a728efa205fa\" # Make note you don't have to pass both of them (emaill, uuid), just one is enough\n)\n\n# Result\n{\n 'email': 'Me',\n 'enable': True,\n 'expiryTime': 0,\n 'flow': 'xtls-rprx-vision',\n 'id': '5d3d1bac-49cd-4b66-8be9-a728efa205fa',\n 'limitIp': 0,\n 'subId': '',\n 'tgId': '',\n 'totalGB': 0\n}\n```\n\n- Get client's statistics:\n```python\nget_client = await xui.get_client_stats(\n inbound_id=1,\n email=\"Me\",\n)\n\n# Result\n{\n 'id': 1,\n 'inboundId': 1,\n 'enable': True,\n 'email': 'Me',\n 'up': 111494230,\n 'down': 620533614,\n 'expiryTime': 0,\n 'total': 0\n}\n```\n\n- Delete client from the existing inbound:\n```python\nget_client = await xui.delete_client(\n inbound_id=1,\n email=\"Me\",\n uuid=\"5d3d1bac-49cd-4b66-8be9-a728efa205fa\" # Make note you don't have to pass both of them (email, uuid), just one is enough\n)\n```\n\n# Create vmess and vless config string\n- Import config_generator\n\n```python\nfrom pyxui_async.config_gen import config_generator\n```\n\n- VMESS:\n```python\nconfig = {\n \"v\": \"2\",\n \"ps\": \"Staliox-Me\",\n \"add\": \"staliox.com\",\n \"port\": \"443\",\n \"id\": \"a85def57-0a86-43d1-b15c-0494519067c6\",\n \"aid\": \"0\",\n \"scy\": \"auto\",\n \"net\": \"tcp\",\n \"type\": \"ws\",\n \"host\": \"staliox.site\",\n \"path\": \"/\",\n \"tls\": \"tls\",\n \"sni\": \"staliox.site\",\n \"alpn\": \"h2,http/1.1\",\n \"fp\": \"chrome\"\n}\n\ngenerate_config = config_generator(\"vmess\", config)\n\n# Result\nvmess://eyJ2IjogIjIiLCAicHMiOiAiU3RhbGlveC1NZSIsICJhZGQiOiAic3RhbGlveC5jb20iLCAicG9ydCI6ICI0NDMiLCAiaWQiOiAiYTg1ZGVmNTctMGE4Ni00M2QxLWIxNWMtMDQ5NDUxOTA2N2M2IiwgImFpZCI6ICIwIiwgInNjeSI6ICJhdXRvIiwgIm5ldCI6ICJ0Y3AiLCAidHlwZSI6ICJ3cyIsICJob3N0IjogInN0YWxpb3guc2l0ZSIsICJwYXRoIjogIi8iLCAidGxzIjogInRscyIsICJzbmkiOiAic3RhbGlveC5zaXRlIiwgImFscG4iOiAiaDIsaHR0cC8xLjEiLCAiZnAiOiAiY2hyb21lIn0=\n```\n\n- VLESS:\n```python\nconfig = {\n \"ps\": \"Staliox-Me\",\n \"add\": \"staliox.com\",\n \"port\": \"443\",\n \"id\": \"a85def57-0a86-43d1-b15c-0494519067c6\"\n}\n\ndata = {\n \"security\": \"tls\",\n \"type\": \"ws\",\n \"host\": \"staliox.site\",\n \"path\": \"/\",\n \"sni\": \"staliox.site\",\n \"alpn\": \"h2,http/1.1\",\n \"fp\": \"chrome\"\n}\n\ngenerate_config = config_generator(\"vless\", config, data)\n\n# Result\nvless://a85def57-0a86-43d1-b15c-0494519067c6@staliox.com:443?security=tls&type=ws&host=staliox.site&path=%2F&tls=tls&sni=staliox.site&alpn=h2%2Chttp%2F1.1&fp=chrome#Staliox-Me\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An application with python that allows you to modify your xui panel",
"version": "1.0.2",
"project_urls": {
"Homepage": "https://github.com/ARLIKIN/pyxui_async"
},
"split_keywords": [
"pyxui async",
" xui",
" xui python",
" xui panel"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "334ca8a2f5b78c1be356dcc417f54610df26f657814987db1a743d0e97df16b7",
"md5": "1b5938563042a9331ffd8e1219d086f3",
"sha256": "ab5f63ef8a1aaf06e7a5f4a74dfefca1f10e875907dd00dfc9f4d78162454e23"
},
"downloads": -1,
"filename": "pyxui_async-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b5938563042a9331ffd8e1219d086f3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9142,
"upload_time": "2024-08-31T11:26:29",
"upload_time_iso_8601": "2024-08-31T11:26:29.981970Z",
"url": "https://files.pythonhosted.org/packages/33/4c/a8a2f5b78c1be356dcc417f54610df26f657814987db1a743d0e97df16b7/pyxui_async-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-31 11:26:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ARLIKIN",
"github_project": "pyxui_async",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyxui-async"
}