{"id":43401230,"url":"https://github.com/raminsa/telegram-bot-api","last_synced_at":"2026-02-02T15:20:03.399Z","repository":{"id":45838293,"uuid":"514834398","full_name":"raminsa/telegram-bot-api","owner":"raminsa","description":"Golang Telegram Bot API ","archived":false,"fork":false,"pushed_at":"2024-07-07T12:12:01.000Z","size":378,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-07-07T13:34:16.812Z","etag":null,"topics":["golang","telegram","telegram-api","telegram-bot","telegram-bot-api"],"latest_commit_sha":null,"homepage":"https://core.telegram.org/bots","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raminsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-17T12:15:27.000Z","updated_at":"2024-07-07T13:34:27.272Z","dependencies_parsed_at":"2024-04-27T16:34:02.524Z","dependency_job_id":"92784e0a-b2d2-49ef-88b9-b2f444ef8caa","html_url":"https://github.com/raminsa/telegram-bot-api","commit_stats":{"total_commits":70,"total_committers":3,"mean_commits":"23.333333333333332","dds":"0.18571428571428572","last_synced_commit":"39bcc656e14e963565a27de217ed213ebea2f7c1"},"previous_names":["raminsa/telegram_api"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/raminsa/telegram-bot-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raminsa%2Ftelegram-bot-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raminsa%2Ftelegram-bot-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raminsa%2Ftelegram-bot-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raminsa%2Ftelegram-bot-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raminsa","download_url":"https://codeload.github.com/raminsa/telegram-bot-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raminsa%2Ftelegram-bot-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29014016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T14:58:54.169Z","status":"ssl_error","status_checked_at":"2026-02-02T14:58:51.285Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","telegram","telegram-api","telegram-bot","telegram-bot-api"],"created_at":"2026-02-02T15:20:02.251Z","updated_at":"2026-02-02T15:20:03.391Z","avatar_url":"https://github.com/raminsa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegram Bot API\n\nThe Telegram Bot API provides an HTTP API for creating Telegram Bots.\n\nIf you've got any questions about bots or would like to report an issue with your bot, kindly contact us at @BotSupport in Telegram.\n\nPlease note that only global Bot API issues that affect all bots are suitable for this repository.\n\nTo learn how to use it, please see our [examples](https://github.com/raminsa/telegram-bot-api/tree/main/examples).\n\nBot API 7.7 recent changes [July 7, 2024](https://core.telegram.org/bots/api#july-7-2024).\n\n## Table of Contents\n- [Installation](#installation)\n- [Documentation](#documentation)\n- [Example](#example)\n- [Custom Client](#custom-client)\n- [Debug](#debug)\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n`go get github.com/raminsa/telegram-bot-api`.\n\n\u003ca name=\"documentation\"\u003e\u003c/a\u003e\n## Documentation\nSee [Bots: An introduction for developers](https://core.telegram.org/bots) for a brief description of Telegram Bots and their features.\n\nSee the [Telegram Bot API documentation](https://core.telegram.org/bots/api) for a description of the Bot API interface and a complete list of available classes, methods and updates.\n\nSee the [Telegram Bot API server build instruction generator](https://tdlib.github.io/telegram-bot-api/build.html) for detailed instructions on how to build the Telegram Bot API server.\n\nSubscribe to [@BotNews](https://t.me/botnews) to be the first to know about the latest updates and join the discussion in [@BotTalk](https://t.me/bottalk).\n\n\n\u003ca name=\"example\"\u003e\u003c/a\u003e\n## Example\n\nuse get update method (simple):\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/raminsa/telegram-bot-api/telegram\"\n)\n\nfunc main() {\n\ttg, err := telegram.New(\"BotToken\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tgetUpdates := tg.NewGetUpdates()\n\tgetUpdates.Offset = 1\n\tgetUpdates.Timeout = 60\n\tgetUpdates.Limit = 100\n\tupdates := tg.GetUpdatesChan(getUpdates)\n\tfor update := range updates {\n\t\tfmt.Println(update.UpdateID, getUpdates.Offset)\n\t\tif update.UpdateID \u003e= getUpdates.Offset {\n\t\t\tgetUpdates.Offset = update.UpdateID + 1\n\t\t}\n\t\tif update.Message != nil {\n\t\t\tfmt.Println(update.Message.Text)\n\t\t}\n\t}\n}\n```\n\nuse webhook method (http):\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/raminsa/telegram-bot-api/telegram\"\n)\n\nfunc main() {\n\tfmt.Println(\"start at port:\", \"BotPortNumber\")\n\terr := http.ListenAndServe(\"BotPortNumber\", http.HandlerFunc(handleWebhook))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc handleWebhook(w http.ResponseWriter, r *http.Request) {\n\tupdate, err := telegram.HandleUpdate(r)\n\tif err != nil {\n\t\terr = telegram.HandleUpdateError(w, err)\n\t\tif err != nil {\n\t\t\t//handle err\n\t\t}\n\t\treturn\n\t}\n\n\tif update.Message != nil {\n\t\tfmt.Println(update.Message.Text)\n\t}\n}\n```\n\nuse webhook method (https):\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/raminsa/telegram-bot-api/telegram\"\n)\n\nfunc main() {\n\tfmt.Println(\"start at port:\", \"BotPortNumber\")\n\terr := http.ListenAndServeTLS(\"BotPortNumber\", \"BotCertFile\", \"BotKeyFile\", http.HandlerFunc(handleWebhook))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc handleWebhook(w http.ResponseWriter, r *http.Request) {\n\tupdate, err := telegram.HandleUpdate(r)\n\tif err != nil {\n\t\terr := telegram.HandleUpdateError(w, err)\n\t\tif err != nil {\n\t\t\t//handle err\n\t\t}\n\t\treturn\n\t}\n\n\tif update.Message != nil {\n\t\tfmt.Println(update.Message.Text)\n\t}\n}\n```\n\nto generate your cert file use this. See [self-signed](https://core.telegram.org/bots/self-signed) guide for details.:\n\n    openssl req -newkey rsa:2048 -sha256 -nodes -keyout \u003cfile.key\u003e -x509 -days 36500 -out \u003cfile.pem\u003e -subj \"/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=\u003cserver_address\u003e\"\n\n\nuse a channel to handle all requests (Avoid ReadTimeoutExpired error), http.ListenAndServe() supports concurrency:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/raminsa/telegram-bot-api/telegram\"\n\t\"github.com/raminsa/telegram-bot-api/types\"\n)\n\nfunc main() {\n\tfmt.Println(\"start at port:\", \"BotPortNumber\")\n\tupdates := listenForWebhook(100)\n\tgo http.ListenAndServeTLS(\"BotPortNumber\", \"BotCertFile\", \"BotKeyFile\", nil)\n\tfor update := range updates {\n\t\tif update.Message != nil {\n\t\t\tfmt.Println(update.Message.Text)\n\t\t}\n\t}\n}\n\nfunc listenForWebhook(maxWebhookConnections int) types.UpdatesChannel {\n\tch := make(chan types.Update, maxWebhookConnections)\n\thttp.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tif update, err := telegram.HandleUpdate(r); err != nil {\n\t\t\treturn\n\t\t} else {\n\t\t\tch \u003c- *update\n\t\t}\n\t})\n\n\treturn ch\n}\n```\n\n\u003ca name=\"custom-client\"\u003e\u003c/a\u003e\n## Custom Client\nuse client with custom options:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/raminsa/telegram-bot-api/telegram\"\n)\n\nfunc main() {\n\tclient := telegram.Client()\n\tclient.BaseUrl = \"baseUrl\"\n\tclient.Proxy = \"proxy\"\n\tclient.ForceV4 = true\n\tclient.DisableSSLVerify = true\n\tclient.ForceAttemptHTTP2 = true\n\ttg, err := telegram.NewWithCustomClient(\"BotToken\", client)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tme, err := tg.GetMe()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Println(\"botID:\", me.ID, \"botUsername:\", me.UserName)\n}\n```\n\n\u003ca name=\"debug\"\u003e\u003c/a\u003e\n## Debug\n\nuse debug option and write to local file:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/raminsa/telegram-bot-api/telegram\"\n)\n\nfunc main() {\n\ttg, err := telegram.NewWithBaseUrl(\"BotToken\", \"baseUrl\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t//active debug mode\n\ttg.Bot.Debug = true\n\n\tme, err := tg.GetMe()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Println(\"botID:\", me.ID, \"botUsername:\", me.UserName)\n\n\t//access debug log\n\t//method 1: write to console\n\tfmt.Println(tg.GetLoggerFile())\n\n\t//method 2: write to file\n\terr = tg.WriteLoggerFile(\"fileName\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framinsa%2Ftelegram-bot-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framinsa%2Ftelegram-bot-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framinsa%2Ftelegram-bot-api/lists"}