Mezon SDK Python
A Python SDK for building bots and applications on the Mezon platform. Async-first, type-safe, and production-ready.
Installation
pip install mezon-sdk
Quick Start
import asyncio
from mezon import MezonClient
from mezon.models import ChannelMessage, ChannelMessageContent
client = MezonClient(
client_id="YOUR_BOT_ID",
api_key="YOUR_API_KEY",
)
async def handle_message(message: ChannelMessage):
if message.sender_id == client.client_id:
return
channel = await client.channels.fetch(message.channel_id)
await channel.send(content=ChannelMessageContent(t="Hello!"))
client.on_channel_message(handle_message)
async def main():
await client.login()
await asyncio.Event().wait()
asyncio.run(main())
Documentation
Full documentation: https://docs.laptrinhai.id.vn/
Features
- Async/await native with
asyncio - Real-time WebSocket with auto-reconnection
- Type-safe with Pydantic models
- Event-driven architecture
- Interactive messages (buttons, forms)
- Token sending support
- Message caching with SQLite
Testing
Pytest is the primary path for focused unit and regression coverage.
For regression coverage around socket/protobuf/login behavior, run:
uv run pytest tests/unit/test_socket_regressions.py
You can also run the broader pytest suite with:
uv run pytest tests/
For broader integration coverage against a real Mezon environment, set the required MEZON_* environment variables and run:
uv run python -m tests.test_runner
The integration runner includes the reconnect/login suite in tests/test_reconnect.py.
Links
License
Apache License 2.0 - see LICENSE for details.
Release files for mezon-sdk 1.8.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mezon_sdk-1.8.3.tar.gz | 160.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mezon_sdk-1.8.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 335.8 kB
Release files / mezon_sdk-1.8.3.tar.gz
| Download URL | mezon_sdk-1.8.3.tar.gz |
|---|---|
| Size | 160.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0bfd55b3daea25a1ce96205e1d3cba905181cae515849bb4cf68dbfe242435f
|
|
BLAKE2b-256 checksum How to use checksums |
16694d3698fced0935d8160f62fc94f671608d8eb0c20e3eaef93043f5eeeb70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / mezon_sdk-1.8.3-py3-none-any.whl
| Download URL | mezon_sdk-1.8.3-py3-none-any.whl |
|---|---|
| Size | 175.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38f6a94b755b5416755e61106834c63bad61daf220f2e7bdabe81f6a2858e03b
|
|
BLAKE2b-256 checksum How to use checksums |
41d5d9a1cf049ec8a79f02649bf734266ee5f0ee8e6085c200a0d23a4aa267e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|