marzban panel API easey-managing.
Project description
SAR-BAN
An application with python that allows you to modify your marzban panel (Gozargah/Marzban)
How To Install
pip install sarban
How To Use
- Import sarban in your .py file
from sarban import SARBAN
sb = SARBAN(
full_address="http://liwyd.site:2087",
https=True
)
- Login in your panel
from sarban.errors import BadLogin
try:
sb.login(USERNAME, PASSWORD)
except BadLogin:
...
- Get users list
users = sb.get_users()
# a part of Result
{
"proxies": {
"vless": {
"id": "4f5b7542-72b4-4d14-8dd6-7dea537c64a1",
"flow": ""
}
},
"expire": null,
"data_limit": null,
"data_limit_reset_strategy": "no_reset",
"inbounds": {
"vless": [
"England",
]
},
"note": "sarban",
"sub_updated_at": null,
"sub_last_user_agent": null,
"online_at": null,
"on_hold_expire_duration": null,
"on_hold_timeout": "2023-11-03T20:30:00",
"auto_delete_in_days": null,
"username": "sarban",
"status": "active",
"used_traffic": 0,
"lifetime_used_traffic": 0,
"created_at": "2024-08-11T13:29:15",
"links": [
"vless://..."
],
"subscription_url": "https://sub.liwyd.com:2096/sus/...",
"excluded_inbounds": {
"vless": [
"Spain",
"Germany",
"Netherlands",
"France",
"Finland",
]
},
"admin": {
"username": "liwyd",
"is_sudo": true,
"telegram_id": 1451599691,
"discord_webhook": null
}
}
- Add client
result = sb.add_client(
username = "sraban",
inboundTag = ["England"],
note= "",
enable= "active",
flow= "",
total_gb= 5, #GB
expire_time= 1725522433, #UTC timestamp
)
- Edit the existing client
result = sb.edit_client(
username = "sraban",
inboundTag = ["England"],
note= "",
enable= "active",
flow= "",
total_gb= 15, #GB
expire_time= 0, #UTC timestamp
)
- Get client's information:
# get client by username
client = sb.get_client(
username="sarban",
)
# get client by subscription token
client = sb.get_client_by_subLink(
token="dGVzdGluZ0hvbGRlcjUsMTcyMzU0NTk1MgSZOThncjMi",
)
# Result
{
"proxies": {
"vless": {
"id": "4f7991aa-8813-4074-ae66-1c681a8a49aa",
"flow": "xtls-rprx-vision"
}
},
"expire": null,
"data_limit": 5465454564,
"data_limit_reset_strategy": "no_reset",
"sub_updated_at": "2024-08-13T10:46:04",
"online_at": null,
"username": "sarban",
"status": "active",
"used_traffic": 0,
"lifetime_used_traffic": 0,
"created_at": "2024-08-11T14:10:43",
"links": [
"vless://.."
],
"subscription_url": "https://sub.liwyd.com:2096/sus/..."
}
- Delete existing client:
get_client = sb.delete_client(
username="sarban",
)
Create subscription-link string
- Import sub_generator
from sarban.sub_gen import sub_generator
- TEST:
generated_sub = sub_generator()
#result:
'
https://sub.liwyd.com:2096/sus/dGVzdGluZ0hvbGRlcjUsMTcyMzU0NTk1MgSZOThncjMi
'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sarban-1.0.0.tar.gz
(6.6 kB
view details)
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 sarban-1.0.0.tar.gz.
File metadata
- Download URL: sarban-1.0.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75b545927c49154fd465c45bef35bad62c21b1ea414d66ff88650812869fae72
|
|
| MD5 |
0fdd6279c1ff10026e306e610e78da7c
|
|
| BLAKE2b-256 |
99a3c878d6d1a76d1dd9e1d6d5fc3424cca80634de04043b9549fd35aeeb7158
|
File details
Details for the file sarban-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sarban-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb995747b4c0779ed3c113008ba097d19f4f33c022e899dfb26cb37d04ee4ddd
|
|
| MD5 |
c27ca35685cd3a6a21a19ff30a0fce15
|
|
| BLAKE2b-256 |
d1bb00a96b13b2a1f15c6547a51f8da8a18025b7e9902f47782eb0d4067b47ff
|