gitmyhub

td

C++ ★ 8.9k updated 8d ago

Cross-platform library for building Telegram clients

TDLib is a cross-platform C++ library that handles all the low-level Telegram networking, encryption, and local storage so you can build Telegram clients or bots in virtually any programming language.

C++OpenSSLCMakeJSONWebAssemblysetup: hardcomplexity 4/5

TDLib, short for Telegram Database library, is a C++ library that handles the low-level work of connecting to Telegram. If you want to build your own Telegram client app or bot, TDLib takes care of the network connection, message encryption, and storing chat data locally, so you do not have to implement those details yourself.

Although the library is written in C++, it is designed to be called from almost any programming language. It exposes a JSON interface based on a simple C function, which means you can drive it from Python, Go, JavaScript, or anything else that can call C functions. For Java and .NET projects, native bindings are available through JNI and C++/CLI respectively, avoiding the need to go through JSON. All API requests are fully asynchronous, so calls to TDLib do not block each other.

The library runs on a wide range of platforms: Android, iOS, Windows, macOS, Linux, FreeBSD, WebAssembly, watchOS, tvOS, Tizen, and others. All locally stored data is encrypted with a key you supply. The library is also used internally by Telegram for their Bot API server, where a single instance handles more than 37,000 active bots at the same time.

Building TDLib requires a C++17 compiler, OpenSSL, zlib, CMake, and gperf. The project provides an online build instructions generator where you select your target language and operating system and receive a step-by-step build guide. Examples for C++, Java, and C# are included in the repository. The API follows semantic versioning, so libraries built against one minor version remain binary compatible with others sharing the same major version number.

Where it fits