MTProto vs. Bot API
Pyrogram is a framework that acts as a fully-fledged Telegram client based on MTProto, and this very feature makes it
already superior to, what is usually called, the official Bot API, in many respects. This page will therefore show you
why Pyrogram might be a better choice for your project by comparing the two APIs, but first, let’s make it clear what
actually is the MTProto and the Bot API.
What is the MTProto API?
MTProto, took alone, is the name of the custom-made, open and encrypted communication protocol created by Telegram
itself — it’s the only protocol used to exchange information between a client and the actual Telegram servers.
The MTProto API on the other hand, is what people, for convenience, call the main Telegram API as a whole. This API
is able to authorize both users and bots and is built on top of the MTProto encryption protocol by means of
binary data serialized in a specific way, as described by the TL language, and delivered using UDP, TCP or even
HTTP as transport-layer protocol.
What is the Bot API?
The Bot API is an HTTP(S) interface for building normal bots using a sub-set of the main MTProto API. Bots are special
accounts that are authorized via tokens instead of phone numbers. The Bot API is built yet again on top of the main
Telegram API, but runs on an intermediate server application that in turn communicates with the actual Telegram servers
using MTProto.
Advantages of the MTProto API
Here is a list of all the advantages in using MTProto-based libraries – such as Pyrogram – instead of the official
HTTP Bot API. Using Pyrogram you can:
+ Upload & download any file, up to 2000 MiB each (~2 GB)
– The Bot API allows uploads and downloads of files only up to 50 MB / 20 MB in size (respectively).
|
+ Run multiple sessions at once, up to 10 per account (either bot or user)
– The Bot API intermediate server will terminate any other session in case you try to use the same
bot again in a parallel connection.
|
+ Receive extra updates, such as the one about a user name change
– The Bot API simply doesn’t support this
|
+ Get API version updates, and thus new features, sooner
– The Bot API is simply slower in implementing new features
|