.NET bindings for TDLib (Telegram Database Library): https://github.com/tdlib/td
- Generated API bindings
- Supports .NET Standard 2.0 and later
Install via NuGet: TDLib
You're recommended to use precompiled version of TDLib native artifacts from NuGet: tdlib.native.
Note that this is the main cross-platform package, and there are per-platform packages and additional options described in the tdlib.native documentation.
Note that tdlib.native
is not a dependency of TDLib
, so you may choose to build the binaries yourself and provide them at the runtime.
To do that, build TDLib and put the compiled library into your project's output directory
- tdjson.dll (Windows) (optionally accompanied by other DLL files from the build directory if you want to bundle OpenSSL and ZLib dependencies as well)
- libtdjson.dylib (MacOS)
- libtdjson.so (Linux)
Report bugs to the issue tracker.
Ask questions at the discussion section on GitHub.
TdJsonClient is a wrapper around native JSON APIs. Use it to send/receive data as strings.
using TdLib;
var json = ""; // json data
double timeout = 1.0; // 1 second
using (var jsonClient = new TdJsonClient())
{
jsonClient.Send(json); // send request
var result = jsonClient.Receive(timeout); // receive response
}
This library contains generated classes for objects and functions. JSON serialization and deserialization is handled automatically. Use TdClient to asynchronously execute functions.
using TdLib;
using (var client = new TdClient())
{
try
{
// asynchronously execute function
TdApi.Ok ok = await client.ExecuteAsync(new TdApi.SetAuthenticationPhoneNumber
{
PhoneNumber = phoneNumber
});
// or use extension method
ok = await client.SetAuthenticationPhoneNumberAsync(phoneNumber);
// do something...
}
catch (ErrorException e)
{
TdApi.Error error = e.Error;
// handle error...
}
}
By default, TdSharp will try to detect the platform and use the corresponding bindings to native td library. In case you want to override it (e.g. for Xamarin), create a custom implementation of ITdLibBindings
(which corresponds to native library interface used by TdSharp) and pass it to TdClient
constructor.
All the project code is licensed under the MIT license.
The code generated from the upstream TDLib has the same license as TDLib, which is the Boost Software License - Version 1.0.
The license indication in the project's sources is compliant with the [REUSE specification v3.0][reuse.spec].