
Offers a Coroutines client for the Telegram Database Library, enabling asynchronous operations with generated Data Transfer Objects. Supports 159 update flows and 867 request methods.
TDL Coroutines is a Kotlin Multiplatform library that provides a coroutine-based client for the Telegram Database Library (TDLib). It simplifies sending requests and handling updates, making TDLib integration more straightforward and idiomatic for Kotlin Multiplatform projects.
Built with Kotlin 2.3.21.
| Platform | Architectures | Requirements |
|---|---|---|
| Android |
armeabi-v7a, arm64-v8ax86, x86_64
|
minSdk 23, compileSdk 34+ |
| JVM | ARM64 / x64 Linux ARM64 / x64 macOS ARM64 / x64 Windows |
Java 11+, glibc 2.34+, libstdc++ with GLIBCXX_3.4.29, libgcc_s.so.1, OpenSSL 3, libz.so.1macOS 11, Java 11+ Windows 10 (JDK and VC++ baseline), Java 11+, Microsoft Visual C++ v14 Redistributable |
| iOS | ARM64 devices ARM64 / x64 simulators |
iOS 15 |
| tvOS | ARM64 devices ARM64 / x64 simulators |
tvOS 15 tvOS 15 |
| watchOS | ARM64 devices ARM64_32 devices ARM64 / x64 simulators |
watchOS 26 watchOS 8 watchOS 8 |
| Linux | ARM64 / x64 | glibc, libstdc++, libgcc_s
|
| macOS | ARM64 / x64 | macOS 11 |
| Windows | x64 | Windows 10 |
Add mavenCentral() to your dependency repositories.
repositories {
mavenCentral()
}Add this dependency to commonMain.dependencies in a Kotlin Multiplatform module or to the module's dependencies
block in a JVM or Android-only module. Replace X.X.X with the version from the Maven Central badge.
implementation("dev.g000sha256:tdl-coroutines:X.X.X")[!CAUTION] TDLib patch releases can change the generated API. Use named arguments with generated constructors and request methods to keep calls clear when parameter lists change.
val client = TdlClient.create()[!IMPORTANT] Subscribe to the update flows you need before sending the first request. Update flows have no replay.
TdlClient provides 201 update flows and the allUpdates flow, which emits updates of every type for that client.
coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) {
client.authorizationStateUpdates.collect { update ->
val authorizationState = update.authorizationState
// TODO
}
}coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) {
client.allUpdates.collect { update ->
when (update) {
is UpdateAuthorizationState -> {
val authorizationState = update.authorizationState
// TODO
}
is UpdateOption -> {
val name = update.name
val value = update.value
// TODO
}
// ...
else -> {
// TODO
}
}
}
}TdlClient provides 1099 request methods.
[!TIP] Request methods suspend while waiting for a response without blocking the calling thread.
coroutineScope.launch {
val result = client.getAuthorizationState()
when (result) {
is TdlResult.Failure -> {
val code = result.code
val message = result.message
// TODO
}
is TdlResult.Success -> {
val authorizationState = result.result
// TODO
}
}
}[!TIP] You can use the
.toResult()extension to convertTdlResult<T>to the standard KotlinResult<T>type.
TDL Coroutines is a Kotlin Multiplatform library that provides a coroutine-based client for the Telegram Database Library (TDLib). It simplifies sending requests and handling updates, making TDLib integration more straightforward and idiomatic for Kotlin Multiplatform projects.
Built with Kotlin 2.3.21.
| Platform | Architectures | Requirements |
|---|---|---|
| Android |
armeabi-v7a, arm64-v8ax86, x86_64
|
minSdk 23, compileSdk 34+ |
| JVM | ARM64 / x64 Linux ARM64 / x64 macOS ARM64 / x64 Windows |
Java 11+, glibc 2.34+, libstdc++ with GLIBCXX_3.4.29, libgcc_s.so.1, OpenSSL 3, libz.so.1macOS 11, Java 11+ Windows 10 (JDK and VC++ baseline), Java 11+, Microsoft Visual C++ v14 Redistributable |
| iOS | ARM64 devices ARM64 / x64 simulators |
iOS 15 |
| tvOS | ARM64 devices ARM64 / x64 simulators |
tvOS 15 tvOS 15 |
| watchOS | ARM64 devices ARM64_32 devices ARM64 / x64 simulators |
watchOS 26 watchOS 8 watchOS 8 |
| Linux | ARM64 / x64 | glibc, libstdc++, libgcc_s
|
| macOS | ARM64 / x64 | macOS 11 |
| Windows | x64 | Windows 10 |
Add mavenCentral() to your dependency repositories.
repositories {
mavenCentral()
}Add this dependency to commonMain.dependencies in a Kotlin Multiplatform module or to the module's dependencies
block in a JVM or Android-only module. Replace X.X.X with the version from the Maven Central badge.
implementation("dev.g000sha256:tdl-coroutines:X.X.X")[!CAUTION] TDLib patch releases can change the generated API. Use named arguments with generated constructors and request methods to keep calls clear when parameter lists change.
val client = TdlClient.create()[!IMPORTANT] Subscribe to the update flows you need before sending the first request. Update flows have no replay.
TdlClient provides 201 update flows and the allUpdates flow, which emits updates of every type for that client.
coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) {
client.authorizationStateUpdates.collect { update ->
val authorizationState = update.authorizationState
// TODO
}
}coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) {
client.allUpdates.collect { update ->
when (update) {
is UpdateAuthorizationState -> {
val authorizationState = update.authorizationState
// TODO
}
is UpdateOption -> {
val name = update.name
val value = update.value
// TODO
}
// ...
else -> {
// TODO
}
}
}
}TdlClient provides 1099 request methods.
[!TIP] Request methods suspend while waiting for a response without blocking the calling thread.
coroutineScope.launch {
val result = client.getAuthorizationState()
when (result) {
is TdlResult.Failure -> {
val code = result.code
val message = result.message
// TODO
}
is TdlResult.Success -> {
val authorizationState = result.result
// TODO
}
}
}[!TIP] You can use the
.toResult()extension to convertTdlResult<T>to the standard KotlinResult<T>type.