APIs
- Telegram APIs
- Bot API
- The Telegram API and TDLib allow you to build your own customized Telegram clients.
- TDLib - Telegram Database Library
- TDLib is a fully functional Telegram client which takes care of all networking, local storage and data consistency details. So that you can dedicate more time to design, responsive interfaces and beautiful animations.
- Client means an interface for interaction with a TDLib instance
- Application means the program that uses TDLib to interact with Telegram.
- Github Repo tdlib/td
- Telegram API
- This API allows you to build your own customized Telegram clients.
- Need to register your application in telegram system.
- API Methods
- TDLib - Telegram Database Library
- MTProto Protocol: Mobile Telegram Protocol
- The protocol is designed for access to a server API from applications running on mobile devices.
- It must be emphasized that a web browser is not such an application.
- Independent components
- High-level component (API query language)
- Cryptographic (authorization) layer
- Transport component
- Used for cloud chats and server-client encryption
- Used for Telegram API and TDLib
- TL Language
- TL (Type Language) serves to describe the used system of types, constructors, and existing functions.
Glossary
- Glossary of TDLib
- message
- chat
- private chat
- basic group
- supergroup
- secret chat
- user
- update
MTProto
Exchange of encryption key:
Schema of telegram’s exported data:
Popular libraries using MTProto:
- ⭐https://github.com/LonamiWebs/Telethon
- https://github.com/Arman92/go-tdlib
- https://github.com/alik0211/mtproto-core
Data flow
Bot Application --> Bot API --> Telegram Server
TDLib Application --> TDLib (client) --> Telegram Server
Telegram-like messaging applications --> Telegam API (connect to data center with IP:PORT) --> Telegram Server
Mobile Client -(MTProto)-> Optional MTProxy --> Telegram Server
Recap
Telegram’s MTProto have reinvent almost all layers of ISO/OSI stack.
Self-destruction
Security of Bot
Specifically, Telegram bots don’t use MTProto, Telegram’s encryption protocol, which creates the framework in which users’ messages to each other are scrambled and illegible while in transit between a sender and recipient’s devices. While researchers have raised various concerns about MTProto over the years—Telegram maintains it is sound—if you trust Telegram with your secure communications, you’re trusting MTProto.
But Telegram’s bot platform relies instead on the transport layer security protocol used in HTTPS web encryption. TLS is great for a lot of things but isn’t robust enough to act as the only encryption in a secure communication service meant to provide advanced protection. That’s why apps like Signal and WhatsApp use the Signal Protocol, and Telegram has MTProto. By building its bot platform without MTProto, though, Telegram creates a situation where introducing a bot to a chat or channel essentially downgrades its encryption.
To keep your Telegram communications safe, don’t add bots to your chats, and be aware when you’re in chats and channels that include them. And to keep messages really secret, always minimize the number of people in a chat to reduce exposure.