aiogram — asynchronous Python framework for the Telegram Bot API
A modern, fully asynchronous framework for the Telegram Bot API, built on asyncio and aiohttp. Typed end to end, with routers, magic filters, a finite-state machine and middlewares that keep your bot code small and testable.
pip install -U aiogramuv add aiogramPython 3.10+ · MIT license · Installation guide
Quick start
An echo bot in about 30 lines. Set BOT_TOKEN and run it with Python 3.10 or newer.
import asyncio
import logging
from os import getenv
from aiogram import Bot, Dispatcher
from aiogram.filters import CommandStart
from aiogram.types import Message
dp = Dispatcher()
@dp.message(CommandStart())
async def start(message: Message) -> None:
await message.answer(f"Hello, {message.from_user.full_name}!")
@dp.message()
async def echo(message: Message) -> None:
try:
await message.send_copy(chat_id=message.chat.id)
except TypeError:
await message.answer("Nice try!")
async def main() -> None:
bot = Bot(token=getenv("BOT_TOKEN"))
await dp.start_polling(bot)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main())Why aiogram
Routers
Split handlers into nested routers by feature and include them where you need them.
Filters & magic filters
Match updates declaratively, from commands and chat types to F.text.startswith("hi").
Finite-state machine
Build multi-step dialogs with states and pluggable storages like memory or Redis.
Middlewares
Wrap updates and handlers with outer and inner middlewares for auth, i18n or throttling.
Fully typed (pydantic models)
Every Telegram type is a pydantic model, so your IDE completes and checks it.
Complete Bot API
Polling or webhooks, payments, inline mode and Mini Apps, tracking each Bot API release.
Community & support
Telegram chat
@aiogramAsk questions and get help from other aiogram developers.
News channel
@aiogram_liveReleases, announcements and Bot API updates.
GitHub
Issues & discussionsReport bugs, request features and discuss ideas.
aiogram is free, open source and maintained by volunteers.Support the project