tdlight/example
levlam 161b932256 Increase version to 1.5.5.
GitOrigin-RevId: 313abbdb9c746d7dac72427465025e5c8608deea
2020-01-14 04:38:15 +03:00
..
cpp Increase version to 1.5.5. 2020-01-14 04:38:15 +03:00
csharp Update copyright year. 2020-01-01 04:23:48 +03:00
ios Fix iOS example. 2019-10-17 22:09:17 +03:00
java Documentation improvements. 2020-01-06 21:44:09 +03:00
python Update copyright year. 2020-01-01 04:23:48 +03:00
swift Update copyright year. 2020-01-01 04:23:48 +03:00
uwp Increase version to 1.5.5. 2020-01-14 04:38:15 +03:00
web Specify exact emsdk version in tdweb README. 2020-01-06 19:30:40 +03:00
README.md Update link to wrapper. 2019-12-13 00:30:03 +03:00

TDLib usage and build examples

This directory contains basic examples of TDLib usage from different programming languages and examples of library building for different platforms. If you are looking for documentation of all available TDLib methods, see the td_api.tl scheme or the automatically generated HTML documentation for a list of all available TDLib methods and classes. Also take a look at our Getting Started tutorial for a description of basic TDLib concepts.

TDLib can be easily used from almost any programming language on any platform. See a TDLib build instructions generator for detailed instructions on how to build TDLib. Choose your preferred programming language to see examples of usage and a detailed description:

Using TDLib in Python projects

TDLib can be used from Python through the JSON interface.

Convenient Python wrappers already exist for our JSON interface.

If you use modern Python >= 3.6, take a look at python-telegram. The wrapper uses the full power of asyncio, has a good documentation and has several examples. It can be installed through pip or used in a Docker container. You can also try a fork python-telegram of this library.

For older Python versions you can use pytdlib or python-tdlib. These wrappers contain generators for TDLib API classes and basic classes for interaction with TDLib.

You can also check out example/python/tdjson_example.py and tdlib-python for some very basic examples of TDLib JSON interface integration with Python.

Using TDLib in JavaScript projects

TDLib can be compiled to WebAssembly or asm.js and used in a browser from JavaScript. See tdweb as a convenient wrapper for TDLib in a browser and telegram-react as an example of a TDLib-based Telegram client.

TDLib can be used from Node.js through the JSON interface.

Convenient Node.js wrappers already exist for our JSON interface. For example, take a look at Airgram modern TDLib framework for TypeScript/JavaScript, or at tdl, which provides a convenient, fully-asynchronous interface for interaction with TDLib and contains a bunch of examples.

You can also see tglib, node-tdlib, tdlnode, Paper Plane and node-tlg for other examples of TDLib JSON interface integration with Node.js.

TDLib can be used also from NativeScript through the JSON interface. See nativescript-tglib as an example of a NativeScript library for building Telegram clients.

Using TDLib in Go projects

TDLib can be used from the Go programming language through the JSON interface and Cgo, and can be linked either statically or dynamically.

Convenient Go wrappers already exist for our JSON interface. For example, take a look at go-tdlib or go-tdlib, which provide a convenient TDLib client, a generator for TDLib API classes and contain many examples.

You can also see go-tdjson for another example of TDLib JSON interface integration with Go.

Using TDLib in Java projects

TDLib can be used from the Java programming language through native JNI binding.

We provide a generator for JNI bridge methods and Java classes for all TDLib API methods and objects. See example/java for an example of using TDLib from desktop Java along with detailed building and usage instructions. To use TDLib to create Android Java applications, use our prebuilt library for Android.

You can also see JTDLib for another example of Java wrapper for TDLib.

Using TDLib in Kotlin projects

TDLib can be used from the Kotlin/JVM programming language through same way as in JAVA.

You can also use ktd library with kotlin specific bindings.

Using TDLib in C# projects

TDLib provides a native .NET interface through C++/CLI and C++/CX. See example/uwp for an example of building TDLib SDK for the Universal Windows Platform and an example of its usage from C#. See example/csharp for an example of building TDLib with C++/CLI support and an example of TDLib usage from C# on Windows.

If you want to write a cross-platform C# application using .NET Core, see tdsharp. It uses our JSON interface, provides an asynchronous interface for interaction with TDLib, automatically generated classes for TDLib API and has some examples.

Also see Unigram, which is a full-featured client rewritten from scratch in C# using TDLib SDK for Universal Windows Platform in less than 2 months, or egram.tel a cross-platform Telegram client written in C#, .NET Core, ReactiveUI and Avalonia.

Using TDLib in C++ projects

TDLib has a simple and convenient C++11-interface for sending and receiving requests and can be statically linked to your application.

See example/cpp for an example of TDLib usage from C++. td_example.cpp contains an example of authorization, processing new incoming messages, getting a list of chats and sending a text message.

See also the source code of Depecher a Telegram app for Sailfish OS, and TELEports a Qt-client for Ubuntu Touch, both of which are based on TDLib.

Using TDLib in Swift projects

TDLib can be used from the Swift programming language through the JSON interface and can be linked statically or dynamically.

See TDLib-iOS, which provide a convenient TDLib client with automatically generated and fully-documented classes for all TDLib API methods and objects.

See example/swift for an example of a macOS Swift application. See example/ios for an example of building TDLib for iOS, watchOS, tvOS, and macOS.

Using TDLib in Objective-C projects

TDLib can be used from the Objective-C programming language through JSON interface and can be linked statically or dynamically.

See example/ios for an example of building TDLib for iOS, watchOS, tvOS, and macOS.

Using TDLib in Dart projects

TDLib can be used from the Dart programming language through the JSON interface and a Dart Native Extension or Dart FFI.

See dart_tdlib or Dart wrapper for TDLib for an example of a TDLib Dart bindings through FFI.

See project.scarlet or tdlib-dart for an example of using TDLib from Dart.

Using TDLib in Rust projects

TDLib can be used from the Rust programming language through the JSON interface.

See rtdlib, tdlib-rs, tdlib-futures, rust-tdlib or tdjson-rs for an example of TDLib Rust bindings.

Using TDLib in Erlang projects

TDLib can be used from the Erlang programming language through the JSON interface.

See erl-tdlib for an example of TDLib Erlang bindings.

Using TDLib in PHP projects

TDLib can be used from the PHP programming language by wrapping its functionality in a PHP extension.

See phptdlib or PIF-TDPony for examples of such extensions which provide access to TDLib from PHP. See tdlib-bundle a Symfony bundle based on phptdlib.

Using TDLib in Lua projects

TDLib can be used from the Lua programming language through the JSON interface.

See tdlua for examples of TDLib Lua bindings and basic usage examples.

See also tdbot, which makes all TDLib features available from Lua scripts.

Using TDLib in D projects

TDLib can be used from the D programming language through the JSON interface.

See d-tdlib-service for an example of TDLib D bindings.

Using TDLib in Ruby projects

TDLib can be used from the Ruby programming language through the JSON interface.

See tdlib-ruby for examples of Ruby bindings and a client for TDLib.

Using TDLib in Clojure projects

TDLib can be used from the Clojure programming language through the JSON interface.

See clojure-tdlib-json-wrapper for an example of TDLib Clojure bindings.

Using TDLib in Emacs Lisp projects

TDLib can be used from the Emacs Lisp programming language.

See telega.el for an example of a GNU Emacs Telegram client.

Using TDLib in Elixir projects

TDLib can be used from the Elixir programming language.

See Elixir TDLib or Elixir TDLib for examples of such usage and an Elixir client for TDLib. This library contains automatically generated and fully-documented classes for all TDLib API methods and objects.

Using TDLib from 1С:Enterprise

TDLib can be used from the 1С programming language.

See TDLib bindings for 1С:Enterprise for examples of such usage.

Using TDLib in C projects

TDLib can be used from the C programming language through the JSON interface and can be linked statically or dynamically.

You can also try to use our C client, which was used by the private TDLib-based version of telegram-cli.

Using TDLib from other programming languages

You can use TDLib from any other programming language using tdbot or TDLib JSON CLI, which provide a command line tool for interaction with TDLIb using the JSON interface through stdin and stdout. You can use this method to use TDLib, for example, from Brainfuck (unfortunately, we haven't seen examples of sending a Telegram message through TDLib on Brainfuck yet).

Alternatively, you can use the TDLib JSON interface directly from your programming language.

Feel free to create an issue, if you have created a valuable TDLib binding or a TDLib client in some programming language and want it to be added to this list of examples.