Skip to content

Repository files navigation

Mezon SDK Python

PyPI version Python Support License

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.

About

Mezon Python SDK for realtime messaging and APIs

Resources

Stars

15 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages