Mezon Python SDK - A Python implementation of the Mezon TypeScript SDK
Project description
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 ChannelMessageContent
from mezon.protobuf.api import api_pb2
client = MezonClient(
client_id="YOUR_BOT_ID",
api_key="YOUR_API_KEY",
)
async def handle_message(message: api_pb2.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.
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 mezon_sdk-1.8.1.tar.gz.
File metadata
- Download URL: mezon_sdk-1.8.1.tar.gz
- Upload date:
- Size: 153.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
137d9b17a1c2014a6f796b8884a480db559ee2fbeb432f6254bbdd9a69ce66ec
|
|
| MD5 |
035a7af558b25f967ef763425fbfbcac
|
|
| BLAKE2b-256 |
04243aab92054725ccc47f358a37ef4b49ad7bb5f6c3155c07a12277546ac8a7
|
File details
Details for the file mezon_sdk-1.8.1-py3-none-any.whl.
File metadata
- Download URL: mezon_sdk-1.8.1-py3-none-any.whl
- Upload date:
- Size: 169.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bcaa4d40d9e8015ca3ace354860f1809b2613cb3735a60a96e0268dfd12fb6d
|
|
| MD5 |
81e99cb8b9666ecc5eeab2dd9fdf296f
|
|
| BLAKE2b-256 |
b3e87ab6dcb0032c2743cb32f438411bf0e43269db9504bfd1d1df81241c5d6e
|