{"id":49626941,"url":"https://github.com/tdlibx/td-ktx","last_synced_at":"2026-05-05T08:05:22.434Z","repository":{"id":47170999,"uuid":"262568944","full_name":"tdlibx/td-ktx","owner":"tdlibx","description":"Kotlin Coroutines extensions for Telegram API TDLib (Telegram Database library)","archived":false,"fork":false,"pushed_at":"2023-10-28T16:00:06.000Z","size":1698,"stargazers_count":29,"open_issues_count":3,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-06T19:05:20.604Z","etag":null,"topics":["android","coroutines-flow","kotlin","tdlib","telegram"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tdlibx.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-09T12:45:03.000Z","updated_at":"2025-07-03T05:57:10.000Z","dependencies_parsed_at":"2022-08-12T13:20:11.831Z","dependency_job_id":null,"html_url":"https://github.com/tdlibx/td-ktx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tdlibx/td-ktx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdlibx%2Ftd-ktx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdlibx%2Ftd-ktx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdlibx%2Ftd-ktx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdlibx%2Ftd-ktx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tdlibx","download_url":"https://codeload.github.com/tdlibx/td-ktx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdlibx%2Ftd-ktx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32640541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"online","status_checked_at":"2026-05-05T02:00:06.033Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","coroutines-flow","kotlin","tdlib","telegram"],"created_at":"2026-05-05T08:05:18.777Z","updated_at":"2026-05-05T08:05:22.429Z","avatar_url":"https://github.com/tdlibx.png","language":"Kotlin","funding_links":[],"categories":["Bindings"],"sub_categories":["Kotlin"],"readme":"# Telegram Flow for TDLib\n\n[![](hhttps://jitpack.io/v/tdlibx/td-ktx.svg)](https://jitpack.io/v/#tdlibx/td-ktx)\n\nTelegram Flow is a Kotlin-first extension toolkit for [TDLib](https://github.com/tdlib/td) that turns callback-based Telegram API calls into coroutines and flows. It keeps your client code concise while exposing idiomatic Compose- and coroutine-friendly APIs.\n\n## Features\n- **Coroutine wrappers** for every TDLib function so you can `suspend` instead of juggling callbacks.\n- **Flow-based updates** that emit strongly typed Telegram updates with sensible defaults.\n- **Extension interfaces** to organize API access around Telegram entities (users, chats, messages, etc.).\n- **Compose-ready**: works seamlessly with `ViewModel` scopes and state flows.\n\n## Setup\nAdd the library dependency from Maven Central:\n\n```kotlin\nimplementation(project(\":libtd-ktx\"))\n```\n\nThe `libtd-ktx` module exposes TDLib (`com.github.tdlibx:td:1.8.56`) as an API dependency, so no extra TDLib declaration is required.\n\nThe project ships a TDLib wrapper module (`libtd-ktx`) and a Compose sample under `sample/` that demonstrates usage with Hilt and the Navigation 3 typed destination APIs.\n\n## Getting started\n1. Create a single `TelegramFlow` instance and keep it in a long-lived scope (e.g., via DI).\n2. Attach a TDLib client once at startup:\n\n```kotlin\nval telegramFlow = TelegramFlow()\ntelegramFlow.attachClient()\n```\n\n3. Provide required TDLib parameters when prompted by the authorization state flow:\n\n```kotlin\ntelegramFlow.authorizationStateFlow().collect { state -\u003e\n    if (state is TdApi.AuthorizationStateWaitTdlibParameters) {\n        telegramFlow.setTdlibParameters(\n            databaseDirectory = \"/data/user/0/\u003cyour.package\u003e/files/td\",\n            apiId = BuildConfig.TELEGRAM_APP_ID,\n            apiHash = BuildConfig.TELEGRAM_APP_HASH,\n            // ...other parameters\n        )\n    }\n}\n```\n\n4. Send authentication information with coroutine calls:\n\n```kotlin\ntelegramFlow.setAuthenticationPhoneNumber(phone, null)\ntelegramFlow.checkAuthenticationCode(code)\ntelegramFlow.checkAuthenticationPassword(password)\n```\n\n## Collecting updates\nEvery TDLib update has a matching flow extension. Example: tracking user presence changes.\n\n```kotlin\ntelegramFlow.userStatusFlow().collect { status -\u003e\n    val user = telegramFlow.getUser(status.userId)\n    // update UI with latest user status\n}\n```\n\nFor updates that only wrap a single value, the flow returns the inner type directly, e.g. `authorizationStateFlow()` emits `TdApi.AuthorizationState` instances.\n\n## Calling Telegram functions\nEach TDLib function is exposed as a suspending extension on `TelegramFlow`:\n\n```kotlin\nsuspend fun fetchSelf(): TdApi.User = telegramFlow.getMe()\n```\n\nExplore the full API surface in the [generated docs](https://tdlibx.github.io/td-ktx/docs/libtd-ktx/).\n\n## Samples\nA minimal Compose sample lives in [`sample/app`](sample/app). It wires `TelegramFlow` with Hilt, demonstrates handling the authorization flow, and renders online users with Navigation Compose.\n\n## License\nThis project is distributed under the Apache 2.0 License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdlibx%2Ftd-ktx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftdlibx%2Ftd-ktx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdlibx%2Ftd-ktx/lists"}