Skip to content


aiogram now is fully support of Telegram Bot API v4.9

All API methods and types is fully autogenerated from Telegram Bot API docs by parser with code-generator.

Package: aiogram.api


All API methods is wrapped as pydantic models and placed in aiogram.api.methods package so that's mean all values which you pass as arguments to the methods will be validated. Here is all methods is classes and in due to Python standards all classes named in upper camel case, for example methods sendMessage has the name SendMessage

Full list of methods can be found in section "Methods"


All types is also wrapped with pydantic and placed in aiogram.api.types package. In this place makes some more differences with official documentations:

  • name from was renamed to from_user in due to from is an keyword in python
  • timestamps has datetime.datetime type instead of int
  • InputFile is used for sending files and is not use pydantic.BaseModel as base class

Full list of methods can be found in section "Types"

Bot instance

Bot instance can be created from aiogram.Bot (from aiogram import Bot) and you can't use API methods without instance of bot with configured token.

Constructor specification:

Argument Type Description
token str Telegram Bot token (Obtained from @BotFather).
session Optional[BaseSession] HTTP Client session (For example AiohttpSession). If not specified it will be automatically created.
parse_mode Optional[str] Default parse mode. If specified it will be propagated into the API methods at runtime.

This class has aliases for all API methods and named in lower_camel_case. For example sendMessage named send_message and has the same specification with all class-based methods.

Here you can pass default parse mode (argument parse_mode) and this value will be used in all API methods automatically.


import asyncio
from os import getenv

from aiogram import Bot

async def main():
    async with Bot(token=getenv("TELEGRAM_TOKEN"), parse_mode="HTML").context() as bot:
        await bot.send_message(61043901, "<b>Hello, World!</b>")

if __name__ == "__main__":