Skip to main content
Socialift
Comparison

Telegram Bot API vs MTProto: which one to use

The Bot API is an HTTPS interface driven by a BotFather token: simple and low-risk, but a bot only sees new events meant for it. MTProto is the API built for Telegram clients: a user account (a userbot) can read history, list members and send files up to 2 GB, at the cost of FLOOD_WAIT limits and ban risk. Customer-facing service — bot; automating your own account — MTProto.

Updated:

The difference in short

With the Bot API you act as a bot: token-based, over HTTPS, within what bots are allowed to do. With MTProto you usually log in as a regular user — phone, code, 2FA — and can do from code nearly everything the Telegram app can. More power means more responsibility and more risk.

One clarification: MTProto doesn't automatically mean “userbot”. Bots can also log in over MTProto (auth.importBotAuthorization, with an api_id), but bot restrictions still apply. In practice, “MTProto” usually refers to acting as a user account, and that's how this article uses it.

Terms

Bot API
The HTTP interface at api.telegram.org. Each request is /bot<token>/methodName with a JSON response.
MTProto API
The protocol and API built for Telegram clients. Connecting requires an api_id and api_hash from my.telegram.org.
Userbot
A regular user account automated over MTProto. Developer slang, not an official term.
Telethon
A popular Python library for MTProto. Socialift's TelegramAccount client is built on top of it.
Local Bot API server
Running Telegram's open-source Bot API server yourself, which raises file size limits and relaxes webhook restrictions.

The big comparison table

The big comparison table — Capability matrix by platform
CriterionBot APIMTProto (user account)
AuthenticationBotFather tokenapi_id + api_hash, then phone → code → 2FA; the result is a session string
TransportHTTPS + JSON, stateless requestsA persistent MTProto connection with session state
Messaging firstNo: a person must message the bot or add it to a groupPossible, but privacy settings and anti-spam limits apply
Reading historyNo history method; only new updates, kept up to 24 hoursFull history (unless the group hides it from new members)
Member listsOnly admins, a single member's status and the member countAvailable; channel subscribers are visible to admins only, and admins can hide the list
Group messagesPrivacy mode: commands and replies only (everything if admin or mode disabled)Everything in chats the account belongs to
Joining chatsCan't join on its own — someone adds itVia an invite link or public @username
Sending files50 MB (photos 10 MB); 2000 MB on a local server2 GB, 4 GB with Telegram Premium
Downloading files20 MB; unlimited on a local serverAnything the account can see, up to 4 GB
Rate limitsDocumented: ~1 msg/s per chat, 20/min per group, ~30/s for broadcasts; exceed → 429 + retry_afterNo published numbers; exceed → 420 FLOOD_WAIT_X, wait X seconds
Scheduled messagesNoYes: Telegram sends the message at the set time itself
Channel statisticsNoFor admins of channels above a certain size
ToS riskLow; the main risk is a leaked tokenUnofficial-client accounts are observed; spam, flooding or fake metrics mean a permanent ban
HostingWebhook (443/80/88/8443) or long polling; serverless-friendlyA long-running process; one session can't be used in parallel (AUTH_KEY_DUPLICATED)
Socialift SDKTelegramTelegramAccount (pip install "socialift[telegram]")

Decision guide: pick by task

Decision guide: pick by task — Capability matrix by platform
TaskChoiceWhy
Customer replies, order status, notificationsBot APIUsers press /start themselves; buttons and webhooks; low ban risk
News for thousands of subscribersChannel + bot posting as adminYou avoid private message limits
Moderating your own groupBot APIBans, restrictions and join requests are all available to bots
Exporting or analysing your chat historyMTProtoBots have no history method
Member list of your own groupMTProto (as an admin)The Bot API doesn't return full lists
Scheduled channel posts, statisticsMTProtoNot in the Bot API
Files over 50 MBMTProto or a local Bot API serverThe official Bot API server caps uploads at 50 MB
Mass messages or invites to strangersNeitherAgainst Telegram's rules; the account can be banned permanently

Are userbots allowed? What Telegram's rules say

Telegram invites developers to build apps on its API free of charge, so automating an account over MTProto isn't forbidden in itself. The conditions: the app needs its own api_id, must not act on a user's behalf without their knowledge and consent, and must not use Telegram data to train AI models.

The official page is explicit: every account that logs in through an unofficial client is automatically put under observation, and using the API for flooding, spamming or faking channel subscriber and view counts gets you banned forever. The Bot API has rules too, but a bot's biggest practical risk is usually a leaked token — fixed with /token in BotFather.

Using both in one project

Often the right answer is “both”: the account reads what bots can't, and the bot handles the customer-facing part.

hybrid.py
import asyncio
from socialift import Telegram, TelegramAccount

async def main():
    async with Telegram.from_env() as bot, TelegramAccount.from_env() as account:
        # Account: something a bot can't do — read and search group history
        last = await account.messages("@my_group", limit=100)
        found = await account.search("@my_group", "price", limit=100)

        # Bot: post the report to a channel as the bot (the bot is a channel admin)
        await bot.send_message("@my_channel",
                               f"Read {len(last)} messages, {len(found)} mention 'price'")

asyncio.run(main())

Telegram.from_env() reads TELEGRAM_BOT_TOKEN; TelegramAccount.from_env() reads TELEGRAM_API_ID, TELEGRAM_API_HASH and TELEGRAM_SESSION.

Rate limits: two errors, one except

The Bot API returns 429 with retry_after; MTProto returns FLOOD_WAIT_X. The SDK maps both to RateLimitError; when the wait is known it's in retry_after, otherwise fall back to a fixed pause.

rate_limit.py
import asyncio
from socialift import RateLimitError

async def send_with_backoff(client, chat, text: str):
    """client is a Telegram or TelegramAccount instance."""
    try:
        return await client.send_message(chat, text)
    except RateLimitError as exc:
        await asyncio.sleep(exc.retry_after or 5)
        return await client.send_message(chat, text)

When a bot isn't enough

  • You need messages from before the bot joined, or ones the bot never receives.
  • You need the actual member list of a group or channel, not just the count or the admins.
  • You need channel statistics or scheduled posts that Telegram sends itself.
  • You handle files over 50 MB and can't run a local Bot API server.
  • You need user actions such as creating a group or channel or joining a chat by link.

← Back to blog

Frequently asked questions

Telethon or the Bot API — which is better?

They solve different problems. The Bot API is simpler and safer for public services, notifications and moderation. Telethon (MTProto) is for acting as an account, reading history, listing members and big files, but it demands serious care around FLOOD_WAIT and the ToS.

What is a Telegram userbot, and is it banned?

A userbot is a regular account automated over MTProto. It isn't banned as such, but the Telegram API Terms of Service apply: actions without user consent, spam, flooding and fake metrics are prohibited. Accounts using unofficial clients are automatically observed.

Can a bot read a group's history?

No. The Bot API has no method for reading chat history: a bot only receives new updates, and in groups privacy mode limits even those. If you need history, use MTProto with an account that is a member of the group.

What's the file size limit with MTProto?

A regular account can upload files up to 2 GB, and a Telegram Premium account up to 4 GB. The official Bot API server caps sending at 50 MB and downloading at 20 MB.

Can I run a bot over MTProto?

Yes: auth.importBotAuthorization logs a bot in with its token and an api_id, after which most MTProto methods work. Bot restrictions still apply. In Socialift, bots use the Telegram client (Bot API) and user accounts use TelegramAccount.

Can one project use both APIs?

Yes, it's a common setup: the bot talks to customers and moderates, while the account fetches data bots can't reach, such as history, member lists or statistics. In the SDK both clients share one error model.

Sources

  1. Telegram Bots: how bots differ from users
  2. Telegram Bot API
  3. Telegram Bots FAQ: limits
  4. Telegram: Creating your Telegram Application
  5. Telegram: Working with bots (MTProto)
  6. Telegram FAQ: file size

Related pages