Python telegram bot libraries

Updated Nov 2026

Python Telegram bot libraries receive messages and commands from Telegram and send replies from Python code. An MTProto client connects to Telegram directly as a bot or a user account rather than through the HTTP Bot API. These libraries let developers run support bots, notification bots, and AI assistants inside Telegram chats.

Popularity

python-telegram-bot has the most monthly downloads in this comparison, at 7.8M.

LibraryMonthly downloadsStarsLast releaseLicense
python-telegram-bot
7.8M
29.6KJun 2026LGPL-3.0-only
Telethon
4.1M
12.1KSep 2026MIT
aiogram
3.3M
5.9KNov 2026MIT
pyTelegramBotAPI
906.4K
8.8KOct 2026GPL-2.0
Pyrogram
402.0K
4.6KApr 2023LGPL-3.0
telebot
112.7K
53Feb 2023MIT
Telepot
14.0K
2.4KMay 2018MIT
python-telegram
6.2K
725Aug 2026MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

python-telegram-bot

Provides an asynchronous Python interface to the Telegram Bot API.

Downloads / mo
7.8M
Stars
29.6K
Last release
22.8
License
LGPL-3.0-only

Strengths

  • Organizes multi-step conversations. Use ConversationHandler to organize handlers for a conversation.
  • Supports polling and webhooks. Receive updates through polling or an optional webhook server.

Limitations

  • Conversations need sequential updates. Disable concurrent_updates when using ConversationHandler.
  • Webhook hosting needs an extra. Install the webhooks extra for the supplied webhook server.

Quickstart

From conversationbot.py
$ pip install python-telegram-bot --upgrade
import asyncio
import telegram

async def main():
    bot = telegram.Bot("TOKEN")
    async with bot:
        print(await bot.get_me())

if __name__ == '__main__':
    asyncio.run(main())

python-telegram-bot examples

From open-source projects on GitHub

Provides an asyncio MTProto client for Telegram user or bot accounts.

Downloads / mo
4.1M
Stars
12.1K
Last release
1.45.0
License
MIT

Strengths

  • Connects through the full API. Use MTProto with a user account or a bot account.
  • Tracks a per-chat conversation. Wait for replies within a conversation scoped to one chat.

Limitations

  • Needs application API credentials. Provide an API ID and hash, including for bot accounts.
  • Development moved to Codeberg. The former GitHub repository can disappear.

Quickstart

From print_messages.py
$ python3 -m pip install --upgrade telethon
import os
from telethon.sync import TelegramClient

with TelegramClient("bot", int(os.environ["TELEGRAM_API_ID"]), os.environ["TELEGRAM_API_HASH"]).start(
    bot_token=os.environ["TELEGRAM_BOT_TOKEN"]
) as bot:
    print(bot.get_me())

Telethon examples

From open-source projects on GitHub

Provides an asynchronous framework for the Telegram Bot API.

Downloads / mo
3.3M
Stars
5.9K
Last release
3.32.0
License
MIT

Strengths

  • Provides finite-state bot workflows. Organize multi-step interactions with the finite-state machine.
  • Separates handlers through routers. Group update handlers into reusable routers.

Limitations

  • Memory storage loses restart state. Use persistent storage when conversations must survive restarts.
  • Polling needs one process. Use webhooks to scale one bot across processes.
$ pip install -U aiogram
import asyncio
import os
from aiogram import Bot

async def main():
    bot = Bot(token=os.environ["TELEGRAM_BOT_TOKEN"])
    async with bot.context():
        print(await bot.get_me())

asyncio.run(main())

aiogram examples

From open-source projects on GitHub

pyTelegramBotAPI

Provides synchronous and asynchronous interfaces to the Telegram Bot API.

Downloads / mo
906.4K
Stars
8.8K
Last release
4.37.1
License
GPL-2.0

Strengths

  • Offers synchronous and asynchronous APIs. Choose a synchronous or asynchronous bot implementation.
  • Provides an integrated webhook receiver. Use run_webhooks to receive and process webhook updates.

Limitations

  • State examples need durable storage. Replace the sample’s in-memory state storage for production use.

Quickstart

From custom_states.py
$ pip install pyTelegramBotAPI
import os
from telebot import TeleBot

bot = TeleBot(os.environ["TELEGRAM_BOT_TOKEN"])
print(bot.get_me())

pyTelegramBotAPI examples

From open-source projects on GitHub

Provides an asynchronous Telegram MTProto API framework for users and bots.

Downloads / mo
402.0K
Stars
4.6K
Last release
2.0.106
License
LGPL-3.0

Quickstart

From client.py
$ pip3 install pyrogram
import asyncio
import os
from pyrogram import Client

async def main():
    async with Client("bot", int(os.environ["TELEGRAM_API_ID"]), os.environ["TELEGRAM_API_HASH"],
                      bot_token=os.environ["TELEGRAM_BOT_TOKEN"]) as app:
        print(await app.get_me())

asyncio.run(main())

telebot

Builds Telegram bots with route decorators.

Downloads / mo
112.7K
Stars
53
Last release
0.0.5
License
MIT

Quickstart

From __init__.py
$ pip install telebot
import os
from telebot_router import TeleBot

app = TeleBot(__name__)
app.config["api_key"] = os.environ["TELEGRAM_BOT_TOKEN"]
print(app.get_me())

Provides a framework for the Telegram Bot API.

Downloads / mo
14.0K
Stars
2.4K
Last release
12.7
License
MIT

Quickstart

From index.rst
$ pip install telepot
import telepot
bot = telepot.Bot('***** PUT YOUR TOKEN HERE *****')
bot.getMe()

python-telegram

Builds Telegram clients in Python.

Downloads / mo
6.2K
Stars
725
Last release
2.0.0
License
MIT

Quickstart

From bot_login.py
$ pip install python-telegram
import argparse

from telegram.client import Telegram


def bot_get_me(api_id, api_hash, token):
    tg = Telegram(
        api_id=api_id,
        api_hash=api_hash,
        bot_token=token,
        database_encryption_key="changeme1234",
    )
    # you must call login method before others
    tg.login()

    result = tg.get_me()
    result.wait()
    print(result.update)
    tg.stop()


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("api_id", help="API id")  # https://my.telegram.org/apps
    parser.add_argument("api_hash", help="API hash")
    parser.add_argument("token", help="Bot token")
    args = parser.parse_args()
    bot_get_me(args.api_id, args.api_hash, args.token)

FAQ

python-telegram-bot suits async bots with multi-step conversations, polling, and webhooks. aiogram suits async bots organized with routers and finite-state workflows. Telethon suits user accounts or bots that need Telegram's full MTProto API.

Telethon is an asyncio MTProto client for Telegram user and bot accounts. It needs an application API ID and hash even for a bot account.

Pyrogram is an asynchronous Telegram MTProto API framework for users and bots.

aiogram is an asynchronous framework for the Telegram Bot API, with routers and finite-state workflows. Only one polling process can use a given bot token.

pyTelegramBotAPI offers synchronous and asynchronous interfaces to the Telegram Bot API, with an integrated webhook receiver.

For coding agents

Found your telegram bot library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official