aiogram implements the Telegram Bot API with asyncio, routers, filters, FSM, middlewares, and pydantic-typed models for Python 3.10+.
Overview
aiogram is a fully asynchronous Python framework for the Telegram Bot API built on asyncio and aiohttp. It targets bot authors who want structured handlers instead of ad hoc HTTP calls.
Routers nest like blueprints to split features. Magic filters match updates declaratively. A finite-state machine supports multi-step dialogs with pluggable storage. Middlewares wrap incoming updates and outbound API calls.
Types map Telegram objects to pydantic models for editor assistance. Documentation covers polling or webhook setups, payments, inline mode, and mini-app scenarios. Community Telegram chats and a news channel back support.
Install via pip or uv; quick-start examples show a minimal echo bot using environment-provided bot tokens.
Key features
- asyncio-first Bot API client
- Nested routers
- Magic filter expressions
- Finite-state machine dialogs
- Incoming and outbound middlewares
- Pydantic-typed Telegram models
- Polling and webhook modes
- i18n via gettext or Fluent
Use cases
- Customer Telegram bots
- Multi-step onboarding flows
- Inline search bots
- Webhook-hosted bots
- Payment-enabled bots