aiomarzban


Nameaiomarzban JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/P1nk-L0rD/aiomarzban
SummaryUser-friendly async SDK for the Marzban API.
upload_time2025-02-18 21:13:49
maintainerNone
docs_urlNone
authorP1nk_L0rd
requires_python>=3.9
licenseNone
keywords aiomarzban marzban marzban api marzban sdk gozargah marzpy
VCS
bugtrack_url
requirements pydantic requests aiohttp python-dotenv bumpversion pytest pytest-asyncio twine
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aiomarzban

Async SDK for the Marzban API based on aiohttp, requests, 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

```bash
pip install aiomarzban
```

## Examples

```python
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)

    # Examples for all methods in /examples/examples.py
```


## Test coverage

**Warning**: It is highly not recommended to run tests on a production server!

- [x] Admin
- [x] Core
- [x] Node
- [ ] Subscription
- [x] System
- [x] User template
- [x] User

To run tests:

Create .env file with panel information

```bash
pytest tests/
```

## Contributing

We welcome contributions! Please follow these steps:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature/YourFeature`).
3. Make your changes.
4. Run tests to ensure everything works (optional).
5. Submit a pull request.

## Tasks

1. Fix tests to avoid freezing
2. Tests for subscription
3. ~~Timeout for requests~~
4. ~~Retries for requests~~
5. More custom useful methods
6. Create library in PyPi

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contact

For questions, suggestions, or feedback, please reach out to [my telegram](https://t.me/IMC_tech).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/P1nk-L0rD/aiomarzban",
    "name": "aiomarzban",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "aiomarzban, marzban, marzban API, marzban SDK, Gozargah, marzpy",
    "author": "P1nk_L0rd",
    "author_email": "mestepanik@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/76/6e/0aea3d627f1236fbe0eb4592e417d6710dcec665d6312b413a378b3b6fc4/aiomarzban-1.0.0.tar.gz",
    "platform": null,
    "description": "# aiomarzban\r\n\r\nAsync SDK for the Marzban API based on aiohttp, requests, and pydantic.\r\nThis library is fully compatible with **Marzban version 0.8.4** and supports all panel methods.\r\n\r\n## Features\r\n\r\n- Async library for non-blocking operations\r\n- Automatic under-the-hood access token management\r\n- All functions implemented as native class methods\r\n- Extensive test coverage for most of the code\r\n- Default values can be provided for user creation\r\n- Simplified user creation through method parameters\r\n- Automatic conversion of gigabytes to bytes\r\n- Custom methods for tailored functionality\r\n\r\n\r\n## Installation\r\n\r\n```bash\r\npip install aiomarzban\r\n```\r\n\r\n## Examples\r\n\r\n```python\r\nfrom aiomarzban import MarzbanAPI, UserDataLimitResetStrategy, UserStatusModify\r\n\r\nmarzban = MarzbanAPI(\r\n    address=\"https://my_domain.com/\",\r\n    username=\"admin\",\r\n    password=\"super_secret_password\",\r\n    default_proxies={\"vless\": {\"flow\": \"\"}},\r\n)\r\n\r\nasync def main():\r\n    # Create admin\r\n    new_admin = await marzban.create_admin(username=\"new_admin\", password=\"12345678\", is_sudo=False)\r\n    print(\"New admin: \", new_admin)\r\n\r\n    # Create user\r\n    new_user = await marzban.add_user(\r\n        username=\"user1\",\r\n        days=90,\r\n        data_limit=100, # In GB\r\n        data_limit_reset_strategy=UserDataLimitResetStrategy.month,\r\n    )\r\n    print(\"New user: \", new_user)\r\n\r\n    # Modify user\r\n    modified_user = await marzban.modify_user(\r\n        username=\"user1\",\r\n        status=UserStatusModify.disabled,\r\n    )\r\n    print(\"Modified user: \", modified_user)\r\n\r\n    # Add days of subscription to user\r\n    modified_user = await marzban.user_add_days(\"user1\", 60)\r\n    print(\"Modified user: \", modified_user)\r\n\r\n    # Get users\r\n    users = await marzban.get_users(offset=0, limit=100)\r\n    print(\"Users: \", users)\r\n    \r\n    # Create node\r\n    new_node = await marzban.add_node(\r\n        name=\"New node\",\r\n        address=\"8.8.8.8\",\r\n    )\r\n    print(\"New node: \", new_node)\r\n\r\n    # Modify node\r\n    modified_node = await marzban.modify_node(\r\n        node_id=new_node.id,\r\n        usage_coefficient=0.2,\r\n    )\r\n    print(\"Modified node: \", modified_node)\r\n\r\n    # Examples for all methods in /examples/examples.py\r\n```\r\n\r\n\r\n## Test coverage\r\n\r\n**Warning**: It is highly not recommended to run tests on a production server!\r\n\r\n- [x] Admin\r\n- [x] Core\r\n- [x] Node\r\n- [ ] Subscription\r\n- [x] System\r\n- [x] User template\r\n- [x] User\r\n\r\nTo run tests:\r\n\r\nCreate .env file with panel information\r\n\r\n```bash\r\npytest tests/\r\n```\r\n\r\n## Contributing\r\n\r\nWe welcome contributions! Please follow these steps:\r\n\r\n1. Fork the repository.\r\n2. Create a new branch (`git checkout -b feature/YourFeature`).\r\n3. Make your changes.\r\n4. Run tests to ensure everything works (optional).\r\n5. Submit a pull request.\r\n\r\n## Tasks\r\n\r\n1. Fix tests to avoid freezing\r\n2. Tests for subscription\r\n3. ~~Timeout for requests~~\r\n4. ~~Retries for requests~~\r\n5. More custom useful methods\r\n6. Create library in PyPi\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\r\n\r\n## Contact\r\n\r\nFor questions, suggestions, or feedback, please reach out to [my telegram](https://t.me/IMC_tech).\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "User-friendly async SDK for the Marzban API.",
    "version": "1.0.0",
    "project_urls": {
        "Developer": "https://t.me/IMC_tech",
        "Homepage": "https://github.com/P1nk-L0rD/aiomarzban",
        "Source": "https://github.com/P1nk-L0rD/aiomarzban"
    },
    "split_keywords": [
        "aiomarzban",
        " marzban",
        " marzban api",
        " marzban sdk",
        " gozargah",
        " marzpy"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e74ed8869364e076e954eebbfe3600dfab1305b4fffed52b70f53f917c00a982",
                "md5": "cf3a40c127738a92fd6ebe4b10a30d58",
                "sha256": "afd9b97c6e36d2216d0c0474ed3b2e3fc4bfbfda84f5d8d1e8127fbd0783da17"
            },
            "downloads": -1,
            "filename": "aiomarzban-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cf3a40c127738a92fd6ebe4b10a30d58",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 18828,
            "upload_time": "2025-02-18T21:13:48",
            "upload_time_iso_8601": "2025-02-18T21:13:48.362372Z",
            "url": "https://files.pythonhosted.org/packages/e7/4e/d8869364e076e954eebbfe3600dfab1305b4fffed52b70f53f917c00a982/aiomarzban-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "766e0aea3d627f1236fbe0eb4592e417d6710dcec665d6312b413a378b3b6fc4",
                "md5": "151f91b3e4325538e36c287c2a798832",
                "sha256": "2fa0b433177d90cf09a8ed8fab4290bc21b81b6440ceaf65d8e4e5835f384168"
            },
            "downloads": -1,
            "filename": "aiomarzban-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "151f91b3e4325538e36c287c2a798832",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 16363,
            "upload_time": "2025-02-18T21:13:49",
            "upload_time_iso_8601": "2025-02-18T21:13:49.799743Z",
            "url": "https://files.pythonhosted.org/packages/76/6e/0aea3d627f1236fbe0eb4592e417d6710dcec665d6312b413a378b3b6fc4/aiomarzban-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-18 21:13:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "P1nk-L0rD",
    "github_project": "aiomarzban",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pydantic",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "aiohttp",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "bumpversion",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "pytest-asyncio",
            "specs": []
        },
        {
            "name": "twine",
            "specs": []
        }
    ],
    "lcname": "aiomarzban"
}
        
Elapsed time: 1.37359s