Skip to main content
All Telegram failures are raised as exceptions instead of returning False or silently ignoring the problem.

Exception hierarchy

TelegramTimeoutError is a subclass of TelegramNetworkError, which is a subclass of TelegramAPIError. Catching TelegramAPIError catches all three.

Error fields

The bot token is redacted from exception descriptions and network error text.

Automatic retries

Rate-limited requests (429) are retried automatically up to max_flood_retries times, respecting Telegram’s retry_after value. The wait is capped at 60 seconds per attempt. Upload streams are rewound before a retry. If an upload uses a non-seekable stream, the request is not retried with empty data; the error is raised instead. Downloads also retry 429 and 5xx responses up to max_flood_retries times.

Permanent errors

Permanent errors such as an invalid token or a webhook conflict are raised immediately. They are not retried.