aiomarzban
Async SDK for the Marzban API based on aiohttp and pydantic. This library is fully compatible with Marzban version 0.8.4 and supports all panel methods.
Features
- Async library for non-blocking operations
- Automatic under-the-hood access token management
- All functions implemented as native class methods
- Extensive test coverage for most of the code
- Default values can be provided for user creation
- Simplified user creation through method parameters
- Automatic conversion of gigabytes to bytes
- Custom methods for tailored functionality
Installation
pip install aiomarzban --upgrade
Examples
from aiomarzban import MarzbanAPI, UserDataLimitResetStrategy, UserStatusModify
marzban = MarzbanAPI(
address="https://my_domain.com/",
username="admin",
password="super_secret_password",
default_proxies={"vless": {"flow": ""}},
)
async def main():
# Create admin
new_admin = await marzban.create_admin(username="new_admin", password="12345678", is_sudo=False)
print("New admin: ", new_admin)
# Create user
new_user = await marzban.add_user(
username="user1",
days=90,
data_limit=100, # In GB
data_limit_reset_strategy=UserDataLimitResetStrategy.month,
)
print("New user: ", new_user)
# Modify user
modified_user = await marzban.modify_user(
username="user1",
status=UserStatusModify.disabled,
)
print("Modified user: ", modified_user)
# Add days of subscription to user
modified_user = await marzban.user_add_days("user1", 60)
print("Modified user: ", modified_user)
# Get users
users = await marzban.get_users(offset=0, limit=100)
print("Users: ", users)
# Create node
new_node = await marzban.add_node(
name="New node",
address="8.8.8.8",
)
print("New node: ", new_node)
# Modify node
modified_node = await marzban.modify_node(
node_id=new_node.id,
usage_coefficient=0.2,
)
print("Modified node: ", modified_node)
Test coverage
Warning: It is highly not recommended to run tests on a production server!
- Admin
- Core
- Node
- Subscription
- System
- User template
- User
To run tests:
Create .env file with panel information
pytest tests/
Contributing
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature). - Make your changes.
- Run tests to ensure everything works (optional).
- Submit a pull request.
Tasks
- Fix tests to avoid freezing
- Tests for subscription
Timeout for requestsRetries for requests- More custom useful methods
Create library in PyPi- Find and remove bugs :)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For questions, suggestions, or feedback, please reach out to my telegram or mestepanik@gmail.com.
Metadata
Release files for aiomarzban 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiomarzban-1.0.4.tar.gz | 17.5 kB | Without provenance | Details for aiomarzban-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiomarzban-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for aiomarzban-1.0.4-py3-none-any.whl |
Total release size: 37.0 kB
Release files / aiomarzban-1.0.4.tar.gz
| Download URL | aiomarzban-1.0.4.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efdb9e2ca25fb02d799efbb9b3d7202f46696563d4e862e53eab16390832c8ed
|
|
BLAKE2b-256 checksum How to use checksums |
98deb497d8aeaec5c89bb31a285ecaf67f60af2ce8e224a0e1ca14847c3b56cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.6
|
Release files / aiomarzban-1.0.4-py3-none-any.whl
| Download URL | aiomarzban-1.0.4-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
55687a2a670b5ff3a30340ba542055d154abddb3307b31e76cef9de2e6cc5f5b
|
|
BLAKE2b-256 checksum How to use checksums |
31fea7be7522b020c0edc474789b0a4b2055c2b23a12d7f65f480bac701afec0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.6
|
Security for aiomarzban 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.