# 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
```
## How To Use
- Import pyxui in your .py file
```python
from pyxui 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.errors import BadLogin
try:
xui.login(USERNAME, PASSWORD)
except BadLogin:
...
```
- Get inbounds list
```python
get_inbounds = 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 = 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 = 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 = 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 = 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 = 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.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/staliox/pyxui",
"name": "pyxui",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "pyxui, xui, xui python, xui panel",
"author": "Staliox",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/24/0f/f11f2d08d4b12dc77ece2f130481061473c657088804c91beb5f008d94f1/pyxui-1.0.1.tar.gz",
"platform": null,
"description": "# PyXUI \r\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)) \r\n\r\n## How To Install\r\n```\r\npip install pyxui\r\n```\r\n\r\n## How To Use\r\n- Import pyxui in your .py file\r\n```python\r\nfrom pyxui import XUI\r\n\r\n# Basic:\r\nxui = XUI(\r\n full_address=\"https://staliox.com:2087\",\r\n panel=\"alireza\", # Your panel name, \"alireza\" or \"sanaei\"\r\n)\r\n\r\n# Advanced:\r\nxui = XUI(\r\n full_address=\"http://staliox.site:2087\",\r\n panel=\"alireza\", # Your panel name, \"alireza\" or \"sanaei\"\r\n https=False, # Make note if you don't use https set False else set True\r\n session_string=... # If you have session cookie to use panel without login\r\n)\r\n```\r\n\r\n- Login in your panel\r\n```python\r\nfrom pyxui.errors import BadLogin\r\n\r\ntry:\r\n xui.login(USERNAME, PASSWORD)\r\nexcept BadLogin:\r\n ...\r\n```\r\n\r\n- Get inbounds list\r\n```python\r\nget_inbounds = xui.get_inbounds()\r\n\r\n# Result\r\n{\r\n \"success\": true,\r\n \"msg\": \"\",\r\n \"obj\": [\r\n {\r\n \"id\": 1,\r\n \"up\": 552345026,\r\n \"down\": 18164200325,\r\n \"total\": 0,\r\n \"remark\": \"Staliox\",\r\n \"enable\": true,\r\n \"expiryTime\": 0,\r\n \"clientStats\": [\r\n {\r\n \"id\": 1,\r\n \"inboundId\": 1,\r\n \"enable\": true,\r\n \"email\": \"Me\",\r\n \"up\": 191308877,\r\n \"down\": 4945030148,\r\n \"expiryTime\": 0,\r\n \"total\": 0\r\n }\r\n ],\r\n \"listen\": \"\",\r\n \"port\": 443,\r\n \"protocol\": \"vless\",\r\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}\",\r\n \"tag\": \"inbound-443\",\r\n \"sniffing\": \"{\\n \\\"enabled\\\": true,\\n \\\"destOverride\\\": [\\n \\\"http\\\",\\n \\\"tls\\\"\\n ]\\n}\"\r\n }\r\n ]\r\n}\r\n```\r\n\r\n- Add client to the existing inbound\r\n```python\r\nget = xui.add_client(\r\n inbound_id=1,\r\n email=\"example@gmal.com\",\r\n uuid=\"5d3d1bac-49cd-4b66-8be9-a728efa205fa\",\r\n enable = True,\r\n flow = \"\",\r\n limit_ip = 0,\r\n total_gb = 5368709120,\r\n expire_time = 1684948641772, # You must pass 13 digit timestamp\r\n telegram_id = \"\",\r\n subscription_id = \"\"\r\n)\r\n```\r\n\r\n- Update the existing client\r\n```python\r\nget = xui.update_client(\r\n inbound_id=1,\r\n email=\"example@gmal.com\",\r\n uuid=\"5d3d1bac-49cd-4b66-8be9-a728efa205fa\",\r\n enable = True,\r\n flow = \"\",\r\n limit_ip = 0,\r\n total_gb = 5368709120,\r\n expire_time = 1684948641772,\r\n telegram_id = \"\",\r\n subscription_id = \"\"\r\n)\r\n```\r\n\r\n- Get client's information:\r\n```python\r\nget_client = xui.get_client(\r\n inbound_id=1,\r\n email=\"Me\",\r\n uuid=\"5d3d1bac-49cd-4b66-8be9-a728efa205fa\" # Make note you don't have to pass both of them (emaill, uuid), just one is enough\r\n)\r\n\r\n# Result\r\n{\r\n 'email': 'Me',\r\n 'enable': True,\r\n 'expiryTime': 0,\r\n 'flow': 'xtls-rprx-vision',\r\n 'id': '5d3d1bac-49cd-4b66-8be9-a728efa205fa',\r\n 'limitIp': 0,\r\n 'subId': '',\r\n 'tgId': '',\r\n 'totalGB': 0\r\n}\r\n```\r\n\r\n- Get client's statistics:\r\n```python\r\nget_client = xui.get_client_stats(\r\n inbound_id=1,\r\n email=\"Me\",\r\n)\r\n\r\n# Result\r\n{\r\n 'id': 1,\r\n 'inboundId': 1,\r\n 'enable': True,\r\n 'email': 'Me',\r\n 'up': 111494230,\r\n 'down': 620533614,\r\n 'expiryTime': 0,\r\n 'total': 0\r\n}\r\n```\r\n\r\n- Delete client from the existing inbound:\r\n```python\r\nget_client = xui.delete_client(\r\n inbound_id=1,\r\n email=\"Me\",\r\n uuid=\"5d3d1bac-49cd-4b66-8be9-a728efa205fa\" # Make note you don't have to pass both of them (email, uuid), just one is enough\r\n)\r\n```\r\n\r\n# Create vmess and vless config string\r\n- Import config_generator\r\n```python\r\nfrom pyxui.config_gen import config_generator\r\n```\r\n\r\n- VMESS:\r\n```python\r\nconfig = {\r\n \"v\": \"2\",\r\n \"ps\": \"Staliox-Me\",\r\n \"add\": \"staliox.com\",\r\n \"port\": \"443\",\r\n \"id\": \"a85def57-0a86-43d1-b15c-0494519067c6\",\r\n \"aid\": \"0\",\r\n \"scy\": \"auto\",\r\n \"net\": \"tcp\",\r\n \"type\": \"ws\",\r\n \"host\": \"staliox.site\",\r\n \"path\": \"/\",\r\n \"tls\": \"tls\",\r\n \"sni\": \"staliox.site\",\r\n \"alpn\": \"h2,http/1.1\",\r\n \"fp\": \"chrome\"\r\n}\r\n\r\ngenerate_config = config_generator(\"vmess\", config)\r\n\r\n# Result\r\nvmess://eyJ2IjogIjIiLCAicHMiOiAiU3RhbGlveC1NZSIsICJhZGQiOiAic3RhbGlveC5jb20iLCAicG9ydCI6ICI0NDMiLCAiaWQiOiAiYTg1ZGVmNTctMGE4Ni00M2QxLWIxNWMtMDQ5NDUxOTA2N2M2IiwgImFpZCI6ICIwIiwgInNjeSI6ICJhdXRvIiwgIm5ldCI6ICJ0Y3AiLCAidHlwZSI6ICJ3cyIsICJob3N0IjogInN0YWxpb3guc2l0ZSIsICJwYXRoIjogIi8iLCAidGxzIjogInRscyIsICJzbmkiOiAic3RhbGlveC5zaXRlIiwgImFscG4iOiAiaDIsaHR0cC8xLjEiLCAiZnAiOiAiY2hyb21lIn0=\r\n```\r\n\r\n- VLESS:\r\n```python\r\nconfig = {\r\n \"ps\": \"Staliox-Me\",\r\n \"add\": \"staliox.com\",\r\n \"port\": \"443\",\r\n \"id\": \"a85def57-0a86-43d1-b15c-0494519067c6\"\r\n}\r\n\r\ndata = {\r\n \"security\": \"tls\",\r\n \"type\": \"ws\",\r\n \"host\": \"staliox.site\",\r\n \"path\": \"/\",\r\n \"sni\": \"staliox.site\",\r\n \"alpn\": \"h2,http/1.1\",\r\n \"fp\": \"chrome\"\r\n}\r\n\r\ngenerate_config = config_generator(\"vless\", config, data)\r\n\r\n# Result\r\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\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An application with python that allows you to modify your xui panel",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/staliox/pyxui"
},
"split_keywords": [
"pyxui",
" xui",
" xui python",
" xui panel"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "240ff11f2d08d4b12dc77ece2f130481061473c657088804c91beb5f008d94f1",
"md5": "3a0227b1bf1f7e4e42034f24b7c3221c",
"sha256": "a2754632889d4d5dfcbe095415502010b08f90e3e6adbf55fb56c4007ba09534"
},
"downloads": -1,
"filename": "pyxui-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "3a0227b1bf1f7e4e42034f24b7c3221c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8681,
"upload_time": "2024-05-07T20:36:24",
"upload_time_iso_8601": "2024-05-07T20:36:24.244788Z",
"url": "https://files.pythonhosted.org/packages/24/0f/f11f2d08d4b12dc77ece2f130481061473c657088804c91beb5f008d94f1/pyxui-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-07 20:36:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "staliox",
"github_project": "pyxui",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyxui"
}