Skip to content

Mezon SDK Python

A Python implementation of the Mezon SDK for building bots and applications on the Mezon platform.

PyPI version Python Support License

Features

  • Async/Await Native - Built with asyncio for high-performance concurrent operations
  • Real-time WebSocket - Full support for real-time messaging with automatic reconnection
  • Type-Safe - Comprehensive type hints and Pydantic models
  • Event-Driven - Elegant event handler system for reactive applications
  • Protocol Buffers - Efficient binary serialization
  • Production Ready - Proper error handling, logging, and graceful shutdown

Quick Install

pip install mezon-sdk

Quick Example

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())

Next Steps