{"id":22737943,"url":"https://github.com/simonscholz/telegram-bot-java-api","last_synced_at":"2025-09-04T05:17:05.798Z","repository":{"id":80922407,"uuid":"122269903","full_name":"SimonScholz/telegram-bot-java-api","owner":"SimonScholz","description":"This library contains the bot api and a retrofit client to get the data","archived":false,"fork":false,"pushed_at":"2018-11-22T22:37:19.000Z","size":135,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T04:54:17.389Z","etag":null,"topics":["domain","java","java-8","retrofit2","spring","telegram","telegram-bot","telegram-bot-api"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SimonScholz.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-02-20T23:29:45.000Z","updated_at":"2025-03-14T20:16:50.000Z","dependencies_parsed_at":"2023-02-28T22:16:02.213Z","dependency_job_id":null,"html_url":"https://github.com/SimonScholz/telegram-bot-java-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SimonScholz/telegram-bot-java-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonScholz%2Ftelegram-bot-java-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonScholz%2Ftelegram-bot-java-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonScholz%2Ftelegram-bot-java-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonScholz%2Ftelegram-bot-java-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SimonScholz","download_url":"https://codeload.github.com/SimonScholz/telegram-bot-java-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonScholz%2Ftelegram-bot-java-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273555459,"owners_count":25126316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"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":["domain","java","java-8","retrofit2","spring","telegram","telegram-bot","telegram-bot-api"],"created_at":"2024-12-10T22:18:44.466Z","updated_at":"2025-09-04T05:17:05.787Z","avatar_url":"https://github.com/SimonScholz.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Telegram Bot Java API \n\nimage:https://travis-ci.org/SimonScholz/telegram-bot-java-api.svg?branch=master[\"Build Status\", link=\"https://travis-ci.org/SimonScholz/telegram-bot-java-api\"]\nimage:https://codecov.io/gh/SimonScholz/telegram-bot-java-api/branch/master/graph/badge.svg[\"Code Coverage Status\", link=\"https://codecov.io/gh/SimonScholz/telegram-bot-java-api\"]\n\nThis library contains the bot api and a retrofit client with a Jackson converter to get the data.\n\nThe domain objects are configured to work properly with Jackson, but should also work fine using GSON.\n\nJackson is used by default by the Spring framework so it works very well in a Spring or Spring Boot environment.\n\nSee https://github.com/SimonScholz/telegram-bot-spring-dmi-wheater and my other telegram repositories for examples.\n\n== Using Retrofit as rest client\n\n[source,java]\n----\npackage de.simonscholz.telegram.bot.api;\n\nimport com.jakewharton.retrofit2.adapter.reactor.ReactorCallAdapterFactory;\n\nimport de.simonscholz.telegram.bot.api.domain.File;\nimport de.simonscholz.telegram.bot.api.domain.Message;\nimport de.simonscholz.telegram.bot.api.domain.TelegramListResponse;\nimport de.simonscholz.telegram.bot.api.domain.TelegramObjectResponse;\nimport de.simonscholz.telegram.bot.api.domain.Update;\nimport reactor.core.publisher.Mono;\nimport retrofit2.Retrofit;\nimport retrofit2.Retrofit.Builder;\nimport retrofit2.converter.jackson.JacksonConverterFactory;\nimport retrofit2.http.Field;\nimport retrofit2.http.FormUrlEncoded;\nimport retrofit2.http.GET;\nimport retrofit2.http.POST;\nimport retrofit2.http.Query;\n\npublic interface TelegramBotClient {\n\n\t/**\n\t * This method creates a TelegramBotClient instance with the given parameters\n\t * and uses the {@link JacksonConverterFactory} for converting JSON to POJOs and\n\t * the {@link ReactorCallAdapterFactory} to get io reactor types as return\n\t * values.\n\t * \n\t * @param baseUrl\n\t *            url of the bot api, usually https://api.telegram.org/bot\n\t * @param botToken\n\t *            the secret token for the bot, which can be obtained from BotFather\n\t * @return\n\t * \n\t * @see https://core.telegram.org/bots/api#authorizing-your-bot\n\t */\n\tstatic TelegramBotClient createReactorJackson(String baseUrl, String botToken) {\n\t\tBuilder builder = new Retrofit.Builder().addConverterFactory(JacksonConverterFactory.create())\n\t\t\t\t.addCallAdapterFactory(ReactorCallAdapterFactory.create());\n\n\t\treturn builder.baseUrl(baseUrl + botToken + \"/\").build().create(TelegramBotClient.class);\n\t}\n\n\t@POST(\"sendMessage\")\n\t@FormUrlEncoded\n\tMono\u003cMessage\u003e sendMessage(@Field(\"chat_id\") long chatId, @Field(\"text\") String text);\n\n\t@POST(\"sendPhoto\")\n\t@FormUrlEncoded\n\tMono\u003cMessage\u003e sendPhoto(@Field(\"chat_id\") long chatId, @Field(\"photo\") String photoUrl);\n\n\t@GET(\"getUpdates\")\n\tMono\u003cTelegramListResponse\u003cUpdate\u003e\u003e getUpdates();\n\n\t@GET(\"getUpdates\")\n\tMono\u003cTelegramListResponse\u003cUpdate\u003e\u003e getUpdates(@Query(\"offset\") int offset);\n\n\t@GET(\"getFile\")\n\tMono\u003cTelegramObjectResponse\u003cFile\u003e\u003e getFile(@Query(\"file_id\") String fileId);\n\n\t@GET(\"getChatMembersCount\")\n\tMono\u003cTelegramObjectResponse\u003cInteger\u003e\u003e getChatMembersCount(@Query(\"chat_id\") String chatId);\n}\n----\n\n== How to use the API\n\nYou can create a TelegramBotClient instance like this:\n\n[source, java]\n----\nString apiUrl = \"https://api.telegram.org/bot\";\nString botToken = \"*** your bot api token ***\";\n\nTelegramBotClient.createReactorJson(apiUrl, botToken);\n\n----\n\n*** your bot api token *** can be obtained from the BotFahther bot.\n\nSee https://core.telegram.org/bots/api#authorizing-your-bot\n\nIn a Spring environment the url and token can be saved as environment variables and be obtained in a configuration class, which creates a TelegramBotClient bean like this:\n\n[source, java]\n----\n\t@Bean\n\tpublic TelegramBotClient getTelegramBotClientDmiWeather(@Value(\"${bot.api.url}\") String apiUrl,\n\t\t\t@Value(\"${bot.dmiweather.token}\") String botToken) {\n\t\treturn TelegramBotClient.createReactorJson(apiUrl, botToken);\n\t}\n----\n\n== Contributing\n\nFeedback is highly appreciated and pull requests are appreciated even more.\n\nI know this library does not contain all domain objects and not all API methods, but it fits for the needs of my Telegram bots. \n\nSo please feel free to ask for enhancements or offer pull requeusts for missing features.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonscholz%2Ftelegram-bot-java-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonscholz%2Ftelegram-bot-java-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonscholz%2Ftelegram-bot-java-api/lists"}