Asynchronous Python library for interacting with Marzban
Project description
pymarz
pymarz is an asynchronous Python library designed for interacting with Marzban. It provides comprehensive methods for managing administrators, users, nodes, and system statistics.
Requirements.
Python 3.7+
Installation & Usage
pip install
pip install pymarz
install from repository
you can install directly form github repository using:
pip install git+https://github.com/SSaeedHoseini/pymarz.git
(you may need to run pip with root permission: sudo pip install git+https://github.com/SSaeedHoseini/pymarz.git)
Setuptools
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install to install the package for all users)
Getting Started
Please follow the installation procedure and then run the following:
from asyncio import run
from pymarz import MarzAPI
pyload = {
"url": "your-domain",
"username": "admin-username",
"password": "admin-password",
}
async def main():
client = MarzAPI(**pyload)
hosts = await client.host.get_all()
print(hosts)
if __name__ == "__main__":
try:
run(main())
except Exception as e:
print(str(e))
Documentation for API Endpoints
All URIs are relative to http://localhost
| Class | Method | HTTP request | Description |
|---|---|---|---|
| AdminApi | admin_token | POST /api/admin/token | Admin Token |
| AdminApi | create_admin | POST /api/admin | Create Admin |
| AdminApi | get_admins | GET /api/admins | Get Admins |
| AdminApi | get_current_admin | GET /api/admin | Get Current Admin |
| AdminApi | modify_admin | PUT /api/admin/{username} | Modify Admin |
| AdminApi | remove_admin | DELETE /api/admin/{username} | Remove Admin |
| CoreApi | get_core_config | GET /api/core/config | Get Core Config |
| CoreApi | get_core_stats | GET /api/core | Get Core Stats |
| CoreApi | modify_core_config | PUT /api/core/config | Modify Core Config |
| CoreApi | restart_core | POST /api/core/restart | Restart Core |
| NodeApi | add_node | POST /api/node | Add Node |
| NodeApi | get_node | GET /api/node/{node_id} | Get Node |
| NodeApi | get_node_settings | GET /api/node/settings | Get Node Settings |
| NodeApi | get_nodes | GET /api/nodes | Get Nodes |
| NodeApi | get_usage | GET /api/nodes/usage | Get Usage |
| NodeApi | modify_node | PUT /api/node/{node_id} | Modify Node |
| NodeApi | reconnect_node | POST /api/node/{node_id}/reconnect | Reconnect Node |
| NodeApi | remove_node | DELETE /api/node/{node_id} | Remove Node |
| SubscriptionApi | user_get_usage | GET /sub/{token}/usage | User Get Usage |
| SubscriptionApi | user_subscription | GET /sub/{token}/ | User Subscription |
| SubscriptionApi | user_subscription_info | GET /sub/{token}/info | User Subscription Info |
| SubscriptionApi | user_subscription_with_client_type | GET /sub/{token}/{client_type} | User Subscription With Client Type |
| SystemApi | get_hosts | GET /api/hosts | Get Hosts |
| SystemApi | get_inbounds | GET /api/inbounds | Get Inbounds |
| SystemApi | get_system_stats | GET /api/system | Get System Stats |
| SystemApi | modify_hosts | PUT /api/hosts | Modify Hosts |
| UserApi | add_user | POST /api/user | Add User |
| UserApi | delete_expired_users | DELETE /api/users/expired | Delete Expired Users |
| UserApi | get_expired_users | GET /api/users/expired | Get Expired Users |
| UserApi | get_user | GET /api/user/{username} | Get User |
| UserApi | get_user_usage | GET /api/user/{username}/usage | Get User Usage |
| UserApi | get_users | GET /api/users | Get Users |
| UserApi | get_users_usage | GET /api/users/usage | Get Users Usage |
| UserApi | modify_user | PUT /api/user/{username} | Modify User |
| UserApi | remove_user | DELETE /api/user/{username} | Remove User |
| UserApi | reset_user_data_usage | POST /api/user/{username}/reset | Reset User Data Usage |
| UserApi | reset_users_data_usage | POST /api/users/reset | Reset Users Data Usage |
| UserApi | revoke_user_subscription | POST /api/user/{username}/revoke_sub | Revoke User Subscription |
| UserApi | set_owner | PUT /api/user/{username}/set-owner | Set Owner |
| UserTemplateApi | add_user_template | POST /api/user_template | Add User Template |
| UserTemplateApi | get_user_template_endpoint | GET /api/user_template/{id} | Get User Template Endpoint |
| UserTemplateApi | get_user_templates | GET /api/user_template | Get User Templates |
| UserTemplateApi | modify_user_template | PUT /api/user_template/{id} | Modify User Template |
| UserTemplateApi | remove_user_template | DELETE /api/user_template/{id} | Remove User Template |
| DefaultApi | base | GET / | Base |
Documentation For Models
- Admin
- AdminCreate
- AdminModify
- CoreStats
- HTTPValidationError
- LocationInner
- NodeCreate
- NodeModify
- NodeResponse
- NodeSettings
- NodeStatus
- NodeUsageResponse
- NodesUsageResponse
- Port
- ProxyHost
- ProxyHostALPN
- ProxyHostFingerprint
- ProxyHostSecurity
- ProxyInbound
- ProxyTypes
- SubscriptionUserResponse
- SystemStats
- Token
- UserCreate
- UserDataLimitResetStrategy
- UserModify
- UserResponse
- UserStatus
- UserStatusCreate
- UserStatusModify
- UserTemplateCreate
- UserTemplateModify
- UserTemplateResponse
- UserUsageResponse
- UserUsagesResponse
- UsersResponse
- UsersUsagesResponse
- ValidationError
Project Links
Contributing
We welcome contributions! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a Pull Request (PR).
Support
If you have any questions or need assistance, you can contact the author via:
- Telegram: @SSaeedhoseini
License
This project is licensed under the MIT License. For more details, refer to the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 pymarz-1.0.1.tar.gz.
File metadata
- Download URL: pymarz-1.0.1.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93b00a2c81cd2fe5857aff8c58e37617ac3f6c016dcdf6e9fdec657a749bccdf
|
|
| MD5 |
769caf87c2323cb317117543335ad872
|
|
| BLAKE2b-256 |
da99f7999288bc8d79aaf42c217e255e4fc1d44702f7238600b4c3c9865e0b7d
|
File details
Details for the file pymarz-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pymarz-1.0.1-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96f03c0387cb78f662ba45cc1fd825442735d68ab8d731e9edf65a7cb88d8334
|
|
| MD5 |
042816d13d3997684b26c18c1c824d76
|
|
| BLAKE2b-256 |
03b403cbdb1beedb27bb90ed85f433c230a58d676a1ac861df22abcd9e94252e
|