Skip to main content

Mezon Python SDK - A Python implementation of the Mezon TypeScript SDK

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mezon_sdk-1.8.2.tar.gz (157.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mezon_sdk-1.8.2-py3-none-any.whl (173.7 kB view details)

Uploaded Python 3

File details

Details for the file mezon_sdk-1.8.2.tar.gz.

File metadata

  • Download URL: mezon_sdk-1.8.2.tar.gz
  • Upload date:
  • Size: 157.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mezon_sdk-1.8.2.tar.gz
Algorithm Hash digest
SHA256 d939f5c0618aba3f842a663ac7fe7479f2f1d71d2509e9b31ca3e28f8b9a44dd
MD5 62a62637fab9f0152c61c93d551f6be1
BLAKE2b-256 07fb314913d8e2e275d359f3214fa2f3571cc632f643d49d77e65afe0f634ed5

See more details on using hashes here.

File details

Details for the file mezon_sdk-1.8.2-py3-none-any.whl.

File metadata

  • Download URL: mezon_sdk-1.8.2-py3-none-any.whl
  • Upload date:
  • Size: 173.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mezon_sdk-1.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 86289e2375703db95499a527106c30073181ae2c1340831cd5f9bd307b05d5c6
MD5 8046068b5a6fd818b8f41d671e8d0e15
BLAKE2b-256 b3db4fe7abf583abcad436941b02708412218bdb0707e346931b855d8dbde1b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page