# python-max-client
Python client library for VK MAX messenger (OneMe)
[](https://badge.fury.io/py/python-max-client)
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
## What is VK MAX?
MAX (internal code name OneMe) is another project by the Russian government in an attempt to create a unified domestic messaging platform with features such as login via the government services account (Gosuslugi/ESIA).  
It is developed by VK Group.  
## What is `python-max-client`?
This is a comprehensive client library for VK MAX messenger, allowing you to create userbots, custom clients, and automated solutions.  
The library provides a simple and intuitive API for interacting with the MAX messenger protocol.
## Features
- 🔐 **Authentication**: Support for SMS and token-based login
- 💬 **Messaging**: Send, receive, and edit messages
- 👥 **Users & Groups**: Manage users, groups, and channels
- 🔄 **Real-time**: WebSocket-based real-time communication
- 🛠️ **Extensible**: Easy to extend with custom functionality
- 📱 **Userbot Support**: Create powerful userbots and automation
## Installation
### Quick Install
The package is available on PyPI and can be installed with pip:
```bash
pip install python-max-client
```
### Install from Source
If you want to install the latest development version:
```bash
git clone https://github.com/huxuxuya/python-max-client.git
cd python-max-client
pip install -e .
```
### Requirements
- Python 3.9 or higher
- Internet connection for VK MAX messenger access
### Dependencies
The package automatically installs the following dependencies:
- `websockets>=12.0` - WebSocket client for real-time communication
- `httpx>=0.25.0` - HTTP client for API requests
### Verify Installation
After installation, verify that the package works correctly:
```python
import python_max_client
print(f"python-max-client version: {python_max_client.__version__}")
print(f"Author: {python_max_client.__author__}")
```
## Usage
### Basic Example
Here's a simple example of how to use the library:
```python
import asyncio
from python_max_client import MaxClient
async def main():
    # Create a client instance
    client = MaxClient()
    
    # Connect to VK MAX
    await client.connect()
    
    # Login with phone number
    phone = input("Enter your phone number: ")
    sms_token = await client.send_code(phone)
    code = input("Enter SMS code: ")
    await client.sign_in(sms_token, int(code))
    
    # Set up message handler
    async def message_handler(client, packet):
        if packet['opcode'] == 128:  # New message
            print(f"New message: {packet['payload']['message']['text']}")
    
    await client.set_callback(message_handler)
    
    # Keep running
    await asyncio.Future()
if __name__ == "__main__":
    asyncio.run(main())
```
### Advanced Example
For more complex usage, check out the [examples](examples/) directory:
```python
import asyncio
import requests
from python_max_client import MaxClient
from python_max_client.functions.messages import edit_message
from pathlib import Path
async def get_weather(city: str) -> str:
    response = requests.get(f"https://ru.wttr.in/{city}?Q&T&format=3")
    return response.text
async def packet_callback(client: MaxClient, packet: dict):
    if packet['opcode'] == 128:
        message_text: str = packet['payload']['message']['text']
        if message_text not in ['.info', '.weather']:
            return
        if message_text == ".info":
            text = "Userbot connected"
        elif ".weather" in message_text:
            city = message_text.split()[1]
            text = await get_weather(city)
        await edit_message(
            client,
            packet["payload"]["chatId"],
            packet["payload"]["message"]["id"],
            text
        )
async def main():
    client = MaxClient()
    await client.connect()
    login_token_file = Path('login_token.txt')
    if login_token_file.exists():
        login_token_from_file = login_token_file.read_text(encoding='utf-8').strip()
        try:
            await client.login_by_token(login_token_from_file)
        except:
            print("Couldn't login by token. Falling back to SMS login")
    else:
        phone_number = input('Enter your phone number: ')
        sms_login_token = await client.send_code(phone_number)
        sms_code = int(input('Enter SMS code: '))
        account_data = await client.sign_in(sms_login_token, sms_code)
        login_token = account_data['payload']['tokenAttrs']['LOGIN']['token']
        login_token_file.write_text(login_token, encoding='utf-8')
    await client.set_callback(packet_callback)
    await asyncio.Future()  # run forever
if __name__ == "__main__":
    asyncio.run(main())
```
## API Reference
### MaxClient
The main client class for interacting with VK MAX messenger.
```python
from python_max_client import MaxClient
client = MaxClient()
```
#### Methods
- `connect()` - Connect to VK MAX servers
- `send_code(phone)` - Send SMS code to phone number
- `sign_in(token, code)` - Sign in with SMS code
- `login_by_token(token)` - Login with saved token
- `set_callback(callback)` - Set message handler callback
### MaxPacket
Data class for handling VK MAX protocol packets.
```python
from python_max_client import MaxPacket
packet = MaxPacket(
    ver=1,
    cmd=0,
    opcode=128,
    seq=1,
    payload={"message": {"text": "Hello!"}}
)
```
### Functions
The library provides various functions for different operations:
- `python_max_client.functions.messages` - Message operations
- `python_max_client.functions.users` - User management
- `python_max_client.functions.groups` - Group operations
- `python_max_client.functions.chats` - Chat management
- `python_max_client.functions.channels` - Channel operations
- `python_max_client.functions.profile` - Profile management
## Documentation
- [Protocol description](docs/protocol.md)
- [Known opcodes](docs/opcodes.md)
## Examples
Check out the [examples](examples/) directory for more usage examples:
- [Weather Userbot](examples/weather-userbot/) - Simple userbot that provides weather information
- [Ayumax](examples/ayumax/) - Advanced userbot example
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Author
**huxuxuya** - [huxuxuya@gmail.com](mailto:huxuxuya@gmail.com)
## Acknowledgments
- Original project by [nsdkinx](https://github.com/nsdkinx/vkmax)
- VK Group for developing the MAX messenger platform
            
         
        Raw data
        
            {
    "_id": null,
    "home_page": null,
    "name": "python-max-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "vk, vkapi, max-messenger, vkmax, oneme, messenger, client",
    "author": null,
    "author_email": "huxuxuya <huxuxuya@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/19/19/ce9108a9ff0e6e9989b803ed4db8ed7582ce8f7b13f3af7fd8324852d4ad/python_max_client-1.0.1.tar.gz",
    "platform": null,
    "description": "# python-max-client\nPython client library for VK MAX messenger (OneMe)\n\n[](https://badge.fury.io/py/python-max-client)\n[](https://www.python.org/downloads/)\n[](https://opensource.org/licenses/MIT)\n\n## What is VK MAX?\nMAX (internal code name OneMe) is another project by the Russian government in an attempt to create a unified domestic messaging platform with features such as login via the government services account (Gosuslugi/ESIA).  \nIt is developed by VK Group.  \n\n## What is `python-max-client`?\nThis is a comprehensive client library for VK MAX messenger, allowing you to create userbots, custom clients, and automated solutions.  \nThe library provides a simple and intuitive API for interacting with the MAX messenger protocol.\n\n## Features\n- \ud83d\udd10 **Authentication**: Support for SMS and token-based login\n- \ud83d\udcac **Messaging**: Send, receive, and edit messages\n- \ud83d\udc65 **Users & Groups**: Manage users, groups, and channels\n- \ud83d\udd04 **Real-time**: WebSocket-based real-time communication\n- \ud83d\udee0\ufe0f **Extensible**: Easy to extend with custom functionality\n- \ud83d\udcf1 **Userbot Support**: Create powerful userbots and automation\n\n## Installation\n\n### Quick Install\nThe package is available on PyPI and can be installed with pip:\n```bash\npip install python-max-client\n```\n\n### Install from Source\nIf you want to install the latest development version:\n```bash\ngit clone https://github.com/huxuxuya/python-max-client.git\ncd python-max-client\npip install -e .\n```\n\n### Requirements\n- Python 3.9 or higher\n- Internet connection for VK MAX messenger access\n\n### Dependencies\nThe package automatically installs the following dependencies:\n- `websockets>=12.0` - WebSocket client for real-time communication\n- `httpx>=0.25.0` - HTTP client for API requests\n\n### Verify Installation\nAfter installation, verify that the package works correctly:\n```python\nimport python_max_client\nprint(f\"python-max-client version: {python_max_client.__version__}\")\nprint(f\"Author: {python_max_client.__author__}\")\n```\n\n## Usage\n\n### Basic Example\nHere's a simple example of how to use the library:\n\n```python\nimport asyncio\nfrom python_max_client import MaxClient\n\nasync def main():\n    # Create a client instance\n    client = MaxClient()\n    \n    # Connect to VK MAX\n    await client.connect()\n    \n    # Login with phone number\n    phone = input(\"Enter your phone number: \")\n    sms_token = await client.send_code(phone)\n    code = input(\"Enter SMS code: \")\n    await client.sign_in(sms_token, int(code))\n    \n    # Set up message handler\n    async def message_handler(client, packet):\n        if packet['opcode'] == 128:  # New message\n            print(f\"New message: {packet['payload']['message']['text']}\")\n    \n    await client.set_callback(message_handler)\n    \n    # Keep running\n    await asyncio.Future()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### Advanced Example\nFor more complex usage, check out the [examples](examples/) directory:\n\n```python\nimport asyncio\nimport requests\nfrom python_max_client import MaxClient\nfrom python_max_client.functions.messages import edit_message\nfrom pathlib import Path\n\n\nasync def get_weather(city: str) -> str:\n    response = requests.get(f\"https://ru.wttr.in/{city}?Q&T&format=3\")\n    return response.text\n\n\nasync def packet_callback(client: MaxClient, packet: dict):\n    if packet['opcode'] == 128:\n        message_text: str = packet['payload']['message']['text']\n        if message_text not in ['.info', '.weather']:\n            return\n\n        if message_text == \".info\":\n            text = \"Userbot connected\"\n\n        elif \".weather\" in message_text:\n            city = message_text.split()[1]\n            text = await get_weather(city)\n\n        await edit_message(\n            client,\n            packet[\"payload\"][\"chatId\"],\n            packet[\"payload\"][\"message\"][\"id\"],\n            text\n        )\n\n\nasync def main():\n    client = MaxClient()\n\n    await client.connect()\n\n    login_token_file = Path('login_token.txt')\n\n    if login_token_file.exists():\n        login_token_from_file = login_token_file.read_text(encoding='utf-8').strip()\n        try:\n            await client.login_by_token(login_token_from_file)\n        except:\n            print(\"Couldn't login by token. Falling back to SMS login\")\n\n    else:\n        phone_number = input('Enter your phone number: ')\n        sms_login_token = await client.send_code(phone_number)\n        sms_code = int(input('Enter SMS code: '))\n        account_data = await client.sign_in(sms_login_token, sms_code)\n\n        login_token = account_data['payload']['tokenAttrs']['LOGIN']['token']\n        login_token_file.write_text(login_token, encoding='utf-8')\n\n    await client.set_callback(packet_callback)\n\n    await asyncio.Future()  # run forever\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## API Reference\n\n### MaxClient\nThe main client class for interacting with VK MAX messenger.\n\n```python\nfrom python_max_client import MaxClient\n\nclient = MaxClient()\n```\n\n#### Methods\n- `connect()` - Connect to VK MAX servers\n- `send_code(phone)` - Send SMS code to phone number\n- `sign_in(token, code)` - Sign in with SMS code\n- `login_by_token(token)` - Login with saved token\n- `set_callback(callback)` - Set message handler callback\n\n### MaxPacket\nData class for handling VK MAX protocol packets.\n\n```python\nfrom python_max_client import MaxPacket\n\npacket = MaxPacket(\n    ver=1,\n    cmd=0,\n    opcode=128,\n    seq=1,\n    payload={\"message\": {\"text\": \"Hello!\"}}\n)\n```\n\n### Functions\nThe library provides various functions for different operations:\n\n- `python_max_client.functions.messages` - Message operations\n- `python_max_client.functions.users` - User management\n- `python_max_client.functions.groups` - Group operations\n- `python_max_client.functions.chats` - Chat management\n- `python_max_client.functions.channels` - Channel operations\n- `python_max_client.functions.profile` - Profile management\n\n## Documentation\n- [Protocol description](docs/protocol.md)\n- [Known opcodes](docs/opcodes.md)\n\n## Examples\nCheck out the [examples](examples/) directory for more usage examples:\n- [Weather Userbot](examples/weather-userbot/) - Simple userbot that provides weather information\n- [Ayumax](examples/ayumax/) - Advanced userbot example\n\n## Contributing\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Author\n**huxuxuya** - [huxuxuya@gmail.com](mailto:huxuxuya@gmail.com)\n\n## Acknowledgments\n- Original project by [nsdkinx](https://github.com/nsdkinx/vkmax)\n- VK Group for developing the MAX messenger platform\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python client for VK MAX messenger (OneMe)",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/huxuxuya/python-max-client",
        "Issues": "https://github.com/huxuxuya/python-max-client/issues",
        "Repository": "https://github.com/huxuxuya/python-max-client"
    },
    "split_keywords": [
        "vk",
        " vkapi",
        " max-messenger",
        " vkmax",
        " oneme",
        " messenger",
        " client"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "48249ebe8127f13113d16d7c3c2b6009814baed23dec9d488fa2756bb6d13222",
                "md5": "f977159aa42187a200b6d5d5140b4307",
                "sha256": "aed25fc69203688be435b1d5a2a40bb809912f3961703055cbc64f1bb506936f"
            },
            "downloads": -1,
            "filename": "python_max_client-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f977159aa42187a200b6d5d5140b4307",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 14360,
            "upload_time": "2025-10-07T20:26:24",
            "upload_time_iso_8601": "2025-10-07T20:26:24.209357Z",
            "url": "https://files.pythonhosted.org/packages/48/24/9ebe8127f13113d16d7c3c2b6009814baed23dec9d488fa2756bb6d13222/python_max_client-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1919ce9108a9ff0e6e9989b803ed4db8ed7582ce8f7b13f3af7fd8324852d4ad",
                "md5": "d51fa1d625dbad50e9d70e52bff8b084",
                "sha256": "204c973b89cc20628c8194f2d0c98449008f1f692c5f79d9ba6e6704a1289d57"
            },
            "downloads": -1,
            "filename": "python_max_client-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d51fa1d625dbad50e9d70e52bff8b084",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 14475,
            "upload_time": "2025-10-07T20:26:25",
            "upload_time_iso_8601": "2025-10-07T20:26:25.340089Z",
            "url": "https://files.pythonhosted.org/packages/19/19/ce9108a9ff0e6e9989b803ed4db8ed7582ce8f7b13f3af7fd8324852d4ad/python_max_client-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-07 20:26:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "huxuxuya",
    "github_project": "python-max-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "websockets",
            "specs": [
                [
                    ">=",
                    "12.0"
                ]
            ]
        },
        {
            "name": "httpx",
            "specs": [
                [
                    ">=",
                    "0.25.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.32.0"
                ]
            ]
        }
    ],
    "lcname": "python-max-client"
}