Python APIs cover lifecycle, authorization, peers, updates, messages, media, sessions, retries and typed errors.
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, 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.
Generated classes expose the pinned Telegram functions and constructors, with source metadata and links to related results and errors.
Transport framing, cryptography and selected TL constructors use native implementations when their capabilities are available, with supported Python fallbacks.
Start with an in-memory session
Section titled “Start with an in-memory session”import asyncioimport os
from miniproto import Client, ClientConfig, InMemorySessionStoragefrom 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.
Guides explain connection ownership, retry safety, flood waits, datacenter migration, update recovery, media scheduling and cancellation.
Native capabilities are checked and benchmarked. Supported Python fallbacks remain available when a native symbol or wheel is unavailable.
Handwritten guides and generated Python, Telegram and Rust pages share one local Pagefind index with language, kind, module, namespace, layer and visibility facets.
`miniproto` handles Telegram's protocol. The planned `mpgram` package adds routers, filters, middleware, plugins, commands and application-level helpers.
Choose your route
Section titled “Choose your route”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.