NEW 📢 Limited launch offer: up to 70% off your first month on every game!See plans

python-telegram-bot vs aiogram on PlayNHost

Discord bot hostingUpdated Oct 29, 20266 min read

Both python-telegram-bot and aiogram run well on every PlayNHost bot plan, including the 0.5 GB STARTER plan (from US$1.99 a month). In our own measurements a python-telegram-bot 22 bot used about 40 MB of memory and an aiogram 3 bot about 169 MB, so memory is not what decides between them. Pick the one whose examples and tutorials you follow. Our Python starter bot uses python-telegram-bot, because it is the most starred and most downloaded Python library for Telegram bots, and the lightest we measured.

What we measured

We measured each library on our own servers, with a bot built and ready to start (the memory the process uses, before any messages):

LibraryMemory
python-telegram-bot 22 (Python 3.13)40 MB
Telegraf (Node.js 22)60 MB
grammY (Node.js 22)61 MB
aiogram 3 (Python 3.13)169 MB

Python on its own used 8 MB in the same test. Your own code, the data it keeps in memory and the number of chats add to these numbers.

Why any plan size works

The 0.5 GB STARTER plan runs any of these libraries with room for your own code: even aiogram, the heaviest, uses about a third of it. Choose 1 GB or more when your bot keeps data in memory, handles files or images, or runs several bots in one process. Plans and prices: Telegram bot hosting.

Side by side

python-telegram-botaiogram
Memory we measuredAbout 40 MB (version 22)About 169 MB (version 3)
GitHub stars (29 Oct 2026)29,5365,912
PyPI downloads, last 30 days (29 Oct 2026)6.76 million2.76 million
Polling callapplication.run_polling()await dp.start_polling(bot)
Token name in its official examplesNone (a "TOKEN" placeholder)BOT_TOKEN
A webhook left set on the botRemoved by itself when polling startsNot removed: it retries on 409 Conflict
A refused token (401)Stops retrying: Invalid token. Aborting retry loop.Keeps retrying, so the bot looks running
Another copy running (409)Keeps retryingKeeps retrying

aiogram is common in Russian-language tutorials and answers. If you follow a tutorial, use the library it uses.

What that means on your server

  • The token: the panel gives it to your code as TELEGRAM_BOT_TOKEN, BOT_TOKEN, TOKEN, TELEGRAM_TOKEN and TELOXIDE_TOKEN. aiogram's os.getenv("BOT_TOKEN") works as it is; in python-telegram-bot examples, replace the placeholder with os.environ["TOKEN"] or os.environ["TELEGRAM_BOT_TOKEN"].
  • A bot that looks running but does not answer: aiogram keeps retrying on a refused token and on 409 Conflict, and python-telegram-bot on 409 Conflict. The panel reads the console and shows a banner with the cause, for example Your bot is running somewhere else too. See Fix Telegram bot 409 Conflict.
  • A webhook from an old host: python-telegram-bot removes it when polling starts. With aiogram, click Remove webhook on the Bot page, pane Telegram, or call await bot.delete_webhook() before start_polling.
  • Online in Telegram: the chip on Overview turns to Online in Telegram when the console shows a ready line. aiogram prints Run polling for bot @your_bot when logging is at INFO. With python-telegram-bot, print Logged in as @your_bot yourself, as our starter bot does.
  • Your token in the console: when Telegram refuses the token, python-telegram-bot's error message contains the token itself. Our starter bot catches InvalidToken and prints a plain line instead, and hides the token in its log lines.
  • Python version: python-telegram-bot 22 needs Python 3.10 or newer. The Runtime on the Code pane offers 3.10 to 3.14, with 3.12 as the default.

The same bot in both

Both answer /start and read the token the panel gives them. Put the library in requirements.txt and the code in bot.py, the default Entry file.

python-telegram-bot: requirements.txt

python-telegram-bot>=22,<23

bot.py

import os

from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes


async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    await update.effective_message.reply_text("Hello! I am running on PlayNHost.")


async def post_init(application: Application) -> None:
    print(f"Logged in as @{application.bot.username}", flush=True)


application = (
    Application.builder()
    .token(os.environ["TELEGRAM_BOT_TOKEN"])
    .post_init(post_init)
    .build()
)
application.add_handler(CommandHandler("start", start))
application.run_polling()

aiogram: requirements.txt

aiogram>=3,<4

bot.py

import asyncio
import logging
import os

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("Hello! I am running on PlayNHost.")


async def main() -> None:
    bot = Bot(os.environ["BOT_TOKEN"])
    await bot.delete_webhook()
    await dp.start_polling(bot)


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    asyncio.run(main())

The aiogram version logs at INFO, so it prints Run polling for bot @your_bot when it is ready, and removes a webhook left on the bot before it starts polling.

And on Node.js

Our Node.js starter bot uses grammY. In our test grammY and Telegraf used about the same memory (61 and 60 MB), so either fits any plan. We chose grammY because it is still updated (1.46.0 on 26 Aug 2026, against Telegraf's last release, 4.16.3, on 29 Feb 2024).

Questions people ask

Which one does the starter bot use?

python-telegram-bot 22 on a Python server, grammY on a Node.js server. Click Create a starter bot in the Set up your bot card on Overview. See How to host a Telegram bot.

Can I switch from one library to the other later?

Yes. Both run on the same Python server: change requirements.txt and your code, then restart. The new package installs on that start because the package file changed.

Do I need a bigger plan for aiogram?

No. At about 169 MB it fits the 0.5 GB STARTER plan with room to spare. A bigger plan helps when your bot itself grows: data kept in memory, files and images, or several bots in one process.

Already hosting your bot somewhere else? Move it to us

OUR LATEST BLOGS