You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
InsanusMokrassar e5a48e9684 rework of multipart files with fixes in new sticker sets 1 week ago
src rework of multipart files with fixes in new sticker sets 1 week ago cleanup 'extension' suffix in readmes 1 year ago
build.gradle update kdocs 2 weeks ago

TelegramBotAPI API extensions

Maven Central

What is it?

It is wrapper library for TelegramBotAPI Core. Here you can find extensions for RequestsExecutor, which are more look like Telegram Bot API requests and in the same time have more obvious signatures to help understand some restrictions in Telegram system.


This library always compatible with original tgbotapi.core library version

How to implement library?

Common ways to implement this library are presented here. In some cases it will require additional steps like inserting of additional libraries (like kotlin stdlib). In the examples will be used variable telegrambotapi-extensions-api.version, which must be set up by developer.

Maven Central


Dependency config presented here:



To use last versions you will need to add one line in repositories block of your build.gradle:


And add next line to your dependencies block:

implementation "dev.inmo:tgbotapi.api:$telegrambotapi_extensions_api_version"

or for old gradle:

compile "dev.inmo:tgbotapi.api:$telegrambotapi_extensions_api_version"

Example of usage and comparison with TelegramBotAPI

Here presented review table for comparison of api from original TelegramBotAPI and extensions-api library. First of all, this library allow to create bot instance in a new way:

val bot = telegramBot("IT IS YOUR TOKEN")

There are a lot of signature for this. For example, you can create bot with next code:

val bot = telegramBot("IT IS YOUR TOKEN") {
    proxy = ProxyBuilder.socks("", 1080)

In all examples supposed that you have created bot.

tgbotapi.core tgbotapi.api
bot.execute(GetMe) bot.getMe()
bot.execute(SendTextMessage(someChatId, text)) bot.sendTextMessage(chat, text)


Currently, these paragraphs almost outdated due to the fact that extensions for listening of updates and webhooks were replaced into tgbotapi.utils. But, most part of information below is correct with small fixes and adding of tgbotapi.utils dependency.

Usually, it is more comfortable to use filter object to get separated types of updates:

val filter = FlowsUpdatesFilter(100)

In this case you will be able:

  • Separate types of incoming updates (even media groups)
  • Simplify launch of getting updates:
    scope = CoroutineScope(Dispatchers.Default)
  • Use filter flows to comfortable filter, map and do other operations with the whole getting updates process:
filter.messageFlow.mapNotNull { as? ContentMessage<*>
}.onEach {

Alternative way

There is an alternative way to get updates. In fact it is almost the same, but could be more useful for some cases:

val filter = bot.startGettingOfUpdates(
    scope = CoroutineScope(Dispatchers.Default)
) { // Here as reveiver will be FlowsUpdatesFilter
    messageFlow.mapNotNull { as? ContentMessage<*>
    }.onEach {