python-telegram-bot is a Python package that implements the Telegram Bot API with asyncio. The telegram.ext module adds high-level handlers for polling, webhooks, jobs, and conversation flows.
Overview
python-telegram-bot lets developers build Telegram chatbots in Python using a typed, asynchronous interface to the official Bot API. The core package maps API types and methods; the telegram.ext submodule supplies application scaffolding, command and message handlers, and helpers aimed at everyday bot development.
The library targets Python 3.11 and newer and is built on asyncio. It supports webhook and long-polling delivery models, shortcut helpers such as replying from a Message object, and optional extras for rate limiting, callback data, scheduled jobs, SOCKS proxies, and webhook serving when installed with named dependency groups.
Networking defaults to httpx. Optional integrations include APScheduler for job queues, cachetools for arbitrary callback data, and aiolimiter for rate limiting. Documentation, wiki guides, and example bots illustrate patterns from minimal echo bots to more structured handlers.
Bots you write with the package run as your own Python process using a bot token from Telegram; the library itself is not a hosted bot service.
Key features
- Native Telegram Bot API coverage
- Async asyncio-based architecture
- telegram.ext handlers and Application class
- Webhook and polling integration
- Static type hints throughout
- Optional job queue and rate limiter
- Shortcut methods on message objects
- pip install with optional feature extras
Use cases
- Command-driven Telegram chatbots
- Customer notification bots
- Interactive conversation flows
- Webhook-hosted bot backends
- Scheduled messages via job queue