Skip to content

Raw API

Use Client.invoke() for Telegram methods without a high-level helper. Each generated request class accepts the fields in its Telegram function reference. Inside a connected client:

from miniproto.raw import functions
config = await client.invoke(functions.HelpGetConfig())
print(config.this_dc)

The Python bindings load request and constructor classes when you access them. The generated stubs expose their signatures to type checkers. Look up the schema sources for the pinned inputs, layer and source differences.

invoke() applies the client’s timeout, migration, retry and flood-wait policies. A stats.* request can follow one statistics-DC redirect using a secondary connection. Raw file RPCs expose FileMigrate, while the high-level transfer methods follow file migrations. Set retry=True on writes only when the operation is idempotent or Telegram deduplicates it. A transport quick acknowledgement reports that Telegram received the packet. Await the RPC to obtain its result.

ClientConfig.max_pending_rpcs sets the maximum number of outstanding RPCs per sender (512 by default). Once all slots are occupied, another call immediately raises PendingRpcLimitExceeded. Limit concurrent work at the caller and leave room for other operations on the same client. For example, process independent reads in batches:

import asyncio
from itertools import batched
for batch in batched(requests, 32):
replies = await asyncio.gather(*(client.invoke(request) for request in batch))
for reply in replies:
await handle_reply(reply)

For Telegram’s parameter flags, return types and known exceptions, browse the raw reference.