{"id":15107187,"url":"https://github.com/liwyd/sarban","last_synced_at":"2026-02-06T07:35:48.775Z","repository":{"id":261228705,"uuid":"841959962","full_name":"Liwyd/sarban","owner":"Liwyd","description":"An application with python that allows you to fully modify your marzban panel - Xray/V2ray","archived":false,"fork":false,"pushed_at":"2024-08-14T19:16:22.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T18:51:24.690Z","etag":null,"topics":["api","censorship-resistant","marzban","marzban-api-python","shadowsocks","trojan","v2ray","vless","vmess","vpn","xray"],"latest_commit_sha":null,"homepage":"https://t.me/liwyd","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Liwyd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-13T11:45:17.000Z","updated_at":"2025-01-09T08:05:53.000Z","dependencies_parsed_at":"2024-11-05T13:06:52.148Z","dependency_job_id":null,"html_url":"https://github.com/Liwyd/sarban","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"a9893655bfdd991368c981f6fbdba12170c7b25b"},"previous_names":["liwyd/sarban"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Liwyd%2Fsarban","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Liwyd%2Fsarban/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Liwyd%2Fsarban/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Liwyd%2Fsarban/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Liwyd","download_url":"https://codeload.github.com/Liwyd/sarban/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166929,"owners_count":21058480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","censorship-resistant","marzban","marzban-api-python","shadowsocks","trojan","v2ray","vless","vmess","vpn","xray"],"created_at":"2024-09-25T21:20:30.510Z","updated_at":"2026-02-06T07:35:48.763Z","avatar_url":"https://github.com/Liwyd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SARBAN\n\nA comprehensive Python SDK for managing Marzban panel ([Gozargah/Marzban](https://github.com/Gozargah/Marzban)) through its REST API.\n\n## 📚 Documentation\n\n### Quick Reference\n- [English Quick Reference](README_EN.md)\n- [Persian Quick Reference (فارسی)](README_FA.md)\n- [Chinese Quick Reference (中文)](README_ZH.md)\n\n### Complete Documentation\n- [Complete English Documentation](DOCUMENTATION_EN.md) - Full guide with examples and best practices\n- [Complete Persian Documentation (فارسی)](DOCUMENTATION_FA.md) - راهنمای کامل با مثال‌ها و بهترین روش‌ها\n- [Complete Chinese Documentation (中文)](DOCUMENTATION_ZH.md) - 完整指南，包含示例和最佳实践\n\n## ✨ Features\n\n- ✅ Complete API coverage for all Marzban endpoints\n- ✅ Admin management (create, modify, remove admins)\n- ✅ User management (CRUD operations, usage tracking)\n- ✅ Node management (add, modify, remove, reconnect nodes)\n- ✅ Core configuration and statistics\n- ✅ System statistics and monitoring\n- ✅ User template management\n- ✅ Subscription management\n- ✅ Comprehensive error handling\n- ✅ Type hints for better IDE support\n\n## 🚀 Installation\n\n```bash\npip install sarban\n```\n\n## 📦 Quick Start\n\n```python\nfrom sarban import SARBAN\nfrom sarban.errors import BadLogin\n\n# Initialize the client\nsb = SARBAN(\n    full_address=\"https://your-marzban-panel.com:2087\",\n    https=True\n)\n\n# Login\ntry:\n    sb.login(\"admin_username\", \"admin_password\")\n    print(\"Login successful!\")\nexcept BadLogin:\n    print(\"Invalid credentials\")\n```\n\n## 📖 API Categories\n\n### Authentication\n- `login()` - Authenticate and get access token\n\n### Admin Management\n- `get_current_admin()` - Get current authenticated admin\n- `create_admin()` - Create a new admin\n- `get_admins()` - Get list of admins\n- `modify_admin()` - Modify admin details\n- `remove_admin()` - Remove an admin\n- `disable_all_active_users()` - Disable all active users under admin\n- `activate_all_disabled_users()` - Activate all disabled users under admin\n- `reset_admin_usage()` - Reset admin usage\n- `get_admin_usage()` - Get admin usage statistics\n\n### User Management\n- `get_client()` - Get user by username\n- `get_client_by_subLink()` - Get user by subscription token\n- `add_client()` - Add a new user\n- `edit_client()` - Modify existing user\n- `delete_client()` - Remove a user\n- `get_users()` - Get list of users with filters\n- `reset_user_data_usage()` - Reset user data usage\n- `revoke_user_subscription()` - Revoke user subscription\n- `get_user_usage()` - Get user usage statistics\n- `active_next_plan()` - Activate next plan for user\n- `set_owner()` - Set owner (admin) for user\n- `reset_users_data_usage()` - Reset all users data usage\n- `get_users_usage()` - Get all users usage statistics\n- `get_expired_users()` - Get expired users\n- `delete_expired_users()` - Delete expired users\n\n### Node Management\n- `get_node_settings()` - Get node settings\n- `add_node()` - Add a new node\n- `get_node()` - Get node by ID\n- `get_nodes()` - Get all nodes\n- `modify_node()` - Modify node details\n- `remove_node()` - Remove a node\n- `reconnect_node()` - Reconnect a node\n- `get_usage()` - Get nodes usage statistics\n\n### Core Management\n- `get_core_stats()` - Get core statistics\n- `restart_core()` - Restart the core\n- `get_core_config()` - Get core configuration\n- `modify_core_config()` - Modify core configuration\n\n### System Management\n- `get_system_stats()` - Get system statistics\n- `get_inbounds()` - Get inbound configurations\n- `get_hosts()` - Get proxy hosts\n- `modify_hosts()` - Modify proxy hosts\n\n### User Template Management\n- `add_user_template()` - Add a new user template\n- `get_user_templates()` - Get list of user templates\n- `get_user_template()` - Get user template by ID\n- `modify_user_template()` - Modify user template\n- `remove_user_template()` - Remove user template\n\n### Subscription Management\n- `user_subscription()` - Get user subscription\n- `user_subscription_info()` - Get subscription info\n- `user_get_usage()` - Get subscription usage\n- `user_subscription_with_client_type()` - Get subscription by client type\n\n## 🔧 Error Handling\n\nThe SDK provides comprehensive error handling:\n\n```python\nfrom sarban.errors import (\n    BadLogin,\n    Unauthorized,\n    Forbidden,\n    NotFound,\n    Conflict,\n    BadRequest,\n    ValidationError,\n    HTTPException\n)\n\ntry:\n    user = sb.get_client(username=\"nonexistent\")\nexcept NotFound:\n    print(\"User not found\")\nexcept Unauthorized:\n    print(\"Not authenticated\")\nexcept Forbidden:\n    print(\"Access denied\")\n```\n\n## 🔗 Subscription Link Generator\n\n```python\nfrom sarban.sub_gen import sub_generator\n\nsubscription_link = sub_generator(\n    userToken=\"token\",\n    fullAddress=\"sub.example.com:2096\",\n    verify=True\n)\n```\n\n## 📝 Example Usage\n\n```python\nfrom sarban import SARBAN\n\nsb = SARBAN(full_address=\"https://panel.example.com:2087\", https=True)\nsb.login(\"admin\", \"password\")\n\n# Get all users\nusers = sb.get_users(limit=10)\n\n# Add a new user\nnew_user = sb.add_client(\n    username=\"test_user\",\n    inboundTag=[\"VLESS_INBOUND\"],\n    total_gb=10,\n    expire_time=1735689600\n)\n\n# Get system stats\nstats = sb.get_system_stats()\nprint(f\"Total users: {stats['total_user']}\")\nprint(f\"Online users: {stats['online_users']}\")\n```\n\n## 📄 License\n\nMIT License\n\n## 👤 Author\n\nliwyd\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## 🔗 Links\n\n- [Marzban Project](https://github.com/Gozargah/Marzban)\n- [PyPI Package](https://pypi.org/project/sarban/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliwyd%2Fsarban","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliwyd%2Fsarban","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliwyd%2Fsarban/lists"}