# SAR-BAN
An application with python that allows you to modify your marzban panel ([Gozargah/Marzban](https://github.com/Gozargah/Marzban))
- Special thanks to ([meta-syfu](https://github.com/meta-syfu))
## How To Install
```
pip install sarban
```
## How To Use
- Import sarban in your .py file
```python
from sarban import SARBAN
sb = SARBAN(
full_address="https://liwyd.site:2087",
https=True
)
```
- Login in your panel
```python
from sarban.errors import BadLogin
try:
sb.login(USERNAME, PASSWORD)
except BadLogin:
...
```
- Get users list
```python
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
```python
result = sb.add_client(
username = "sarban",
inboundTag = ["England"],
note= "",
enable= "active",
flow= "",
total_gb= 5, #GB
expire_time= 1725522433, #UTC timestamp
)
```
- Edit the existing client
```python
result = sb.edit_client(
username = "sarban",
inboundTag = ["England"],
note= "",
enable= "active",
flow= "",
total_gb= 15, #GB
expire_time= 0, #UTC timestamp
)
```
- Get client's information:
```python
# 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:
```python
get_client = sb.delete_client(
username="sarban",
)
```
# Create subscription-link string
- Import sub_generator
```python
from sarban.sub_gen import sub_generator
```
- TEST:
```python
generated_sub = sub_generator()
#result:
'
https://sub.liwyd.com:2096/sus/dGVzdGluZ0hvbGRlcjUsMTcyMzU0NTk1MgSZOThncjMi
'
```
Raw data
{
"_id": null,
"home_page": "https://github.com/liwyd/sarban",
"name": "sarban",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "sarban, marzban, marzban python, marzban panel",
"author": "liwyd",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/a0/af/e136223369918bdc9bc1e87f8cd7e5ed0f8f7db79223448f6c848dddcf29/sarban-1.1.0.tar.gz",
"platform": null,
"description": "# SAR-BAN\n\nAn application with python that allows you to modify your marzban panel ([Gozargah/Marzban](https://github.com/Gozargah/Marzban))\n\n- Special thanks to ([meta-syfu](https://github.com/meta-syfu))\n\n## How To Install\n\n```\npip install sarban\n```\n\n## How To Use\n\n- Import sarban in your .py file\n\n```python\nfrom sarban import SARBAN\n\n\nsb = SARBAN(\n full_address=\"https://liwyd.site:2087\",\n https=True\n)\n```\n\n- Login in your panel\n\n```python\nfrom sarban.errors import BadLogin\n\ntry:\n sb.login(USERNAME, PASSWORD)\nexcept BadLogin:\n ...\n```\n\n- Get users list\n\n```python\nusers = sb.get_users()\n\n# a part of Result\n{\n \"proxies\": {\n \"vless\": {\n \"id\": \"4f5b7542-72b4-4d14-8dd6-7dea537c64a1\",\n \"flow\": \"\"\n }\n },\n \"expire\": null,\n \"data_limit\": null,\n \"data_limit_reset_strategy\": \"no_reset\",\n \"inbounds\": {\n \"vless\": [\n \"England\",\n ]\n },\n \"note\": \"sarban\",\n \"sub_updated_at\": null,\n \"sub_last_user_agent\": null,\n \"online_at\": null,\n \"on_hold_expire_duration\": null,\n \"on_hold_timeout\": \"2023-11-03T20:30:00\",\n \"auto_delete_in_days\": null,\n \"username\": \"sarban\",\n \"status\": \"active\",\n \"used_traffic\": 0,\n \"lifetime_used_traffic\": 0,\n \"created_at\": \"2024-08-11T13:29:15\",\n \"links\": [\n \"vless://...\"\n ],\n \"subscription_url\": \"https://sub.liwyd.com:2096/sus/...\",\n \"excluded_inbounds\": {\n \"vless\": [\n \"Spain\",\n \"Germany\",\n \"Netherlands\",\n \"France\",\n \"Finland\",\n ]\n },\n \"admin\": {\n \"username\": \"liwyd\",\n \"is_sudo\": true,\n \"telegram_id\": 1451599691,\n \"discord_webhook\": null\n }\n}\n```\n\n- Add client\n\n```python\nresult = sb.add_client(\n username = \"sarban\",\n inboundTag = [\"England\"],\n note= \"\",\n enable= \"active\",\n flow= \"\",\n total_gb= 5, #GB\n expire_time= 1725522433, #UTC timestamp\n)\n```\n\n- Edit the existing client\n\n```python\nresult = sb.edit_client(\n username = \"sarban\",\n inboundTag = [\"England\"],\n note= \"\",\n enable= \"active\",\n flow= \"\",\n total_gb= 15, #GB\n expire_time= 0, #UTC timestamp\n)\n```\n\n- Get client's information:\n\n```python\n# get client by username\nclient = sb.get_client(\n username=\"sarban\",\n)\n\n# get client by subscription token\nclient = sb.get_client_by_subLink(\n token=\"dGVzdGluZ0hvbGRlcjUsMTcyMzU0NTk1MgSZOThncjMi\",\n)\n\n\n# Result\n{\n \"proxies\": {\n \"vless\": {\n \"id\": \"4f7991aa-8813-4074-ae66-1c681a8a49aa\",\n \"flow\": \"xtls-rprx-vision\"\n }\n },\n \"expire\": null,\n \"data_limit\": 5465454564,\n \"data_limit_reset_strategy\": \"no_reset\",\n \"sub_updated_at\": \"2024-08-13T10:46:04\",\n \"online_at\": null,\n \"username\": \"sarban\",\n \"status\": \"active\",\n \"used_traffic\": 0,\n \"lifetime_used_traffic\": 0,\n \"created_at\": \"2024-08-11T14:10:43\",\n \"links\": [\n \"vless://..\"\n ],\n \"subscription_url\": \"https://sub.liwyd.com:2096/sus/...\"\n}\n```\n\n- Delete existing client:\n\n```python\nget_client = sb.delete_client(\n username=\"sarban\",\n)\n```\n\n# Create subscription-link string\n\n- Import sub_generator\n\n```python\nfrom sarban.sub_gen import sub_generator\n```\n\n- TEST:\n\n```python\n\ngenerated_sub = sub_generator()\n\n#result:\n\n'\nhttps://sub.liwyd.com:2096/sus/dGVzdGluZ0hvbGRlcjUsMTcyMzU0NTk1MgSZOThncjMi\n'\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "marzban panel API easey-managing.",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/liwyd/sarban"
},
"split_keywords": [
"sarban",
" marzban",
" marzban python",
" marzban panel"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "628f9daeb04a707426d42934fce2315b9cf9803f875788ae95215dcd437f12fd",
"md5": "bb6822c4d5d406340e5c5b61e7c241a9",
"sha256": "07d4520d73c3ac99125c29f5f6dff037831259077c4aa3ab516c4f0f0adf7dcc"
},
"downloads": -1,
"filename": "sarban-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bb6822c4d5d406340e5c5b61e7c241a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 8187,
"upload_time": "2024-08-14T19:03:14",
"upload_time_iso_8601": "2024-08-14T19:03:14.901052Z",
"url": "https://files.pythonhosted.org/packages/62/8f/9daeb04a707426d42934fce2315b9cf9803f875788ae95215dcd437f12fd/sarban-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a0afe136223369918bdc9bc1e87f8cd7e5ed0f8f7db79223448f6c848dddcf29",
"md5": "0b45fcf52a4d7d0694537ffc8490cbd3",
"sha256": "3559b9d1a8f4545a900036164518728c0614e900e224f6eafc1941f0327d8036"
},
"downloads": -1,
"filename": "sarban-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "0b45fcf52a4d7d0694537ffc8490cbd3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 7273,
"upload_time": "2024-08-14T19:03:16",
"upload_time_iso_8601": "2024-08-14T19:03:16.581514Z",
"url": "https://files.pythonhosted.org/packages/a0/af/e136223369918bdc9bc1e87f8cd7e5ed0f8f7db79223448f6c848dddcf29/sarban-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-14 19:03:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "liwyd",
"github_project": "sarban",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "sarban"
}