Skip to content

0.1.x Alpha

A Python client core for Telegram MTProto

A compact, async-first Telegram client core with explicit state, generated Layer 234 bindings, encrypted sessions and bundled Rust acceleration where measurements justify it.

CPython 3.13–3.15 · Free-threaded 3.14t and 3.15t · Linux, macOS, Windows · x86-64 and ARM64

Python API
Layer 234 schema
Rust acceleration
miniproto logo
MTProto

Python API, Telegram schema and Rust acceleration

Section titled “Python API, Telegram schema and Rust acceleration”

miniproto exposes an async Python API for Telegram MTProto. Python handles the client API and request policy, the pinned Telegram schema defines raw requests and results, and Rust accelerates selected hot paths without being required for correctness.

01Python API

Python APIs cover lifecycle, authorization, peers, updates, messages, media, sessions, retries and typed errors.

02Layer 234 schema

Generated classes expose the pinned Telegram functions and constructors, with source metadata and links to related results and errors.

03Rust acceleration

Transport framing, cryptography and selected TL constructors use native implementations when their capabilities are available, with supported Python fallbacks.

import asyncio
import os
from miniproto import Client, ClientConfig, InMemorySessionStorage
from miniproto.raw import functions
async def main() -> None:
config = ClientConfig(
api_id=int(os.environ["MINIPROTO_API_ID"]),
api_hash=os.environ["MINIPROTO_API_HASH"],
session_storage=InMemorySessionStorage(),
)
async with Client(config) as client:
await client.sign_in_bot(os.environ["MINIPROTO_BOT_TOKEN"])
me = await client.get_me()
telegram_config = await client.invoke(functions.HelpGetConfig())
print(me.id, telegram_config.this_dc)
asyncio.run(main())

Keep credentials outside source control. This call uses in-memory storage and does not save bot authorization after shutdown. Encrypted SQLite sessions require a constructor key or MINIPROTO_SESSION_KEY. The quickstart explains this before the first persistent authorization.

Lifecycle and safety

Guides explain connection ownership, retry safety, flood waits, datacenter migration, update recovery, media scheduling and cancellation.

Native acceleration

Native capabilities are checked and benchmarked. Supported Python fallbacks remain available when a native symbol or wheel is unavailable.

Reference you can search

Handwritten guides and generated Python, Telegram and Rust pages share one local Pagefind index with language, kind, module, namespace, layer and visibility facets.

Protocol SDK

`miniproto` handles Telegram's protocol. The planned `mpgram` package adds routers, filters, middleware, plugins, commands and application-level helpers.

Complete reference, committed with the code

Section titled “Complete reference, committed with the code”

The generated Markdown is versioned with the source. The documentation workflow uses Node.js, Python and Rust nightly to check the references and build the site. The deployed output is static HTML, CSS, JavaScript and a self-hosted search index.