{"id":13764781,"url":"https://github.com/tg-bot-api/bot-api-base","last_synced_at":"2026-01-11T16:49:55.907Z","repository":{"id":33896757,"uuid":"162029989","full_name":"tg-bot-api/bot-api-base","owner":"tg-bot-api","description":"Clear and simple Telegram bot API","archived":false,"fork":false,"pushed_at":"2022-05-17T23:00:03.000Z","size":3508,"stargazers_count":224,"open_issues_count":3,"forks_count":70,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-05-09T23:38:51.425Z","etag":null,"topics":["php","php-telegram-bot","telegram","telegram-bot","telegram-bot-api","telegram-bot-php","telegram-php","telegram-php-bot"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tg-bot-api.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-16T18:39:26.000Z","updated_at":"2025-02-02T04:47:50.000Z","dependencies_parsed_at":"2022-07-08T04:38:05.800Z","dependency_job_id":null,"html_url":"https://github.com/tg-bot-api/bot-api-base","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tg-bot-api%2Fbot-api-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tg-bot-api%2Fbot-api-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tg-bot-api%2Fbot-api-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tg-bot-api%2Fbot-api-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tg-bot-api","download_url":"https://codeload.github.com/tg-bot-api/bot-api-base/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253480380,"owners_count":21915246,"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","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":["php","php-telegram-bot","telegram","telegram-bot","telegram-bot-api","telegram-bot-php","telegram-php","telegram-php-bot"],"created_at":"2024-08-03T16:00:28.641Z","updated_at":"2026-01-11T16:49:55.901Z","avatar_url":"https://github.com/tg-bot-api.png","language":"PHP","funding_links":[],"categories":["Bots"],"sub_categories":["Bot Libs"],"readme":"# Telegram Bot Api Base\n\n[![Telegram bot api][ico-bot-api]][link-bot-api]\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![build][ico-ci]][link-ci]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![PHP Version \u003e= 7.2][ico-php-v]][link-php-7-2]\n[![Symfony Recipe][ico-symfony-recipe]][link-symfony-recipe]\n\n[![Quality Gate Status][sonar-gate-status-icon]][sonar-path]\n[![Bugs][sonar-bugs-icon]][sonar-path]\n[![Duplicated Lines (%)][sonar-duplicated-lines-icon]][sonar-path]\n[![Security Rating][sonar-security-rating-icon]][sonar-path]\n\n#### Supported Telegram Bot API 5.0 (November 4, 2020)\n\n## Installation\n\nVia Composer\n\n``` bash\ncomposer require tg-bot-api/bot-api-base --prefer-dist\n```\n\n## Usage\n\nWe support all psr17 and psr18 implementations, but we will use guzzle6 for example\n```bash\ncomposer require php-http/guzzle6-adapter http-interop/http-factory-guzzle --prefer-dist\n```\n\n```php\n$botKey = '\u003cbot key\u003e';\n\n$requestFactory = new Http\\Factory\\Guzzle\\RequestFactory();\n$streamFactory = new Http\\Factory\\Guzzle\\StreamFactory();\n$client = new Http\\Adapter\\Guzzle6\\Client();\n\n$apiClient = new \\TgBotApi\\BotApiBase\\ApiClient($requestFactory, $streamFactory, $client);\n$bot = new \\TgBotApi\\BotApiBase\\BotApi($botKey, $apiClient, new \\TgBotApi\\BotApiBase\\BotApiNormalizer());\n\n$userId = '\u003cuser id\u003e';\n\n$bot-\u003esend(\\TgBotApi\\BotApiBase\\Method\\SendMessageMethod::create($userId, 'Hi'));\n```\n\nYou can configure it to work in symfony, for example, in [this way](https://gist.github.com/greenplugin/09179bee606aa01b1ee00d049ab78fc4).\n\nIf you want to use your own api server - you can set url as 4th param in bot api\n\n```php \n$bot = new \\TgBotApi\\BotApiBase\\BotApi('\u003cbot key\u003e', $apiClient, new \\TgBotApi\\BotApiBase\\BotApiNormalizer(), '\u003cyour-domain\u003e');\n```\n\n### Allowed methods:\n\n|Method|Allowed type|response|\n|:--|:--|:--|\n|`add`|AddStickerToSetMethod|bool|\n|`answer`|AnswerCallbackQueryMethod, AnswerInlineQueryMethod, AnswerPreCheckoutQueryMethod, AnswerShippingQueryMethod|bool|\n|`create`|CreateNewStickerSetMethod|bool|\n|`delete`|DeleteChatPhotoMethod, DeleteChatStickerSetMethod, DeleteMessageMethod, DeleteStickerFromSetMethod, DeleteWebhookMethod|bool|\n|`edit`|EditMessageCaptionMethod, EditMessageLiveLocationMethod, EditMessageMediaMethod, EditMessageReplyMarkupMethod, EditMessageTextMethod|bool|\n|`forward`|ForwardMessageMethod|MessageType|\n|`kick`|KickChatMemberMethod|bool|\n|`leave`|LeaveChatMethod|bool|\n|`pin`|PinChatMessageMethod|bool|\n|`promote`|PromoteChatMemberMethod|bool|\n|`restrict`|RestrictChatMemberMethod|bool|\n|`send`|SendPhotoMethod, SendAudioMethod, SendDocumentMethod, SendVideoMethod, SendAnimationMethod, SendVoiceMethod, SendVideoNoteMethod, SendGameMethod, SendInvoiceMethod, SendLocationMethod, SendVenueMethod, SendContactMethod, SendStickerMethod, SendMessageMethod, SendPollMethod, SendDiceMethod|MessageType|\n|`set`|SetChatDescriptionMethod, SetChatPhotoMethod, SetChatStickerSetMethod, SetChatTitleMethod, SetGameScoreMethod, SetStickerPositionInSetMethod, SetWebhookMethod, SetPassportDataErrorsMethod, SetChatPermissionsMethod, SetChatAdministratorCustomTitleMethod, SetMyCommandMethod, SetStickerSetThumbMethod|bool|\n|`stop`|StopMessageLiveLocationMethod|bool|\n|`stopPoll`|StopPollMethod|Poll|\n|`unban`|UnbanChatMemberMethod|bool|\n|`unpin`|UnpinChatMessageMethod, UnpinAllChatMessagesMethod|bool|\n|`upload`|UploadStickerFileMethod|FileType|\n|`exportChatInviteLink`|ExportChatInviteLinkMethod|string|\n|`sendChatAction`|SendChatActionMethod|bool|\n|`getUpdates`|GetUpdatesMethod|UpdateType[]|\n|`getMe`|GetMeMethod|UserType|\n|`getMyCommands`|GetMyCommandsMethod|BotCommandType|\n|`getUserProfilePhotos`|GetUserProfilePhotosMethod|UserProfilePhotosType|\n|`getWebhookInfo`|GetWebhookInfoMethod|WebhookInfoType|\n|`getChatMembersCount`|GetChatMembersCountMethod|int|\n|`getChat`|GetChatMethod|ChatType|\n|`getChatAdministrators`|GetChatAdministratorsMethod|ChatMemberType[]|\n|`getChatMember`|GetChatMemberMethod|ChatMemberType|\n|`getChatMenuButton`|GetChatMenuButtonMethod|MenuButtonType|\n|`getGameHighScores`|GetGameHighScoresMethod|GameHighScoreType[]|\n|`getStickerSet`|GetStickerSetMethod|StickerSetType|\n|`getFile`|GetFileMethod|FileType|\n|`sendMediaGroup`|SendMediaGroupMethod|MessageType[]|\n|`getAbsoluteFilePath`|FileType|string|\n|`logOut`|LogOutMethod|bool|\n|`close`|CloseMethod|bool|\n|`copyMessage`|CopyMessageMethod|MessageIdType|\n|`call($method, [string $type])`|any method class, [optional expected type]|array or excepted type object|\n\nImplemented all methods and types referenced by [official Api](https://core.telegram.org/bots/api)\n\nYou can use  `BotApiComplete` instance as helper to call \nall methods from [official Api](https://core.telegram.org/bots/api) like this:\n\n```php\n$botKey = '\u003cbot key\u003e';\n\n$requestFactory = new Http\\Factory\\Guzzle\\RequestFactory()\n$streamFactory = new Http\\Factory\\Guzzle\\StreamFactory();\n$client = new Http\\Adapter\\Guzzle6\\Client();\n\n$apiClient = new \\TgBotApi\\BotApiBase\\ApiClient($requestFactory, $streamFactory, $client);\n$bot = new \\TgBotApi\\BotApiBase\\BotApiComplete($botKey, $apiClient, new \\TgBotApi\\BotApiBase\\BotApi\\BotApiNormalizer());\n\n$userId = '\u003cuser id\u003e';\n\n$bot-\u003esendMessage(\\TgBotApi\\BotApiBase\\Method\\SendMessageMethod::create($userId, 'Hi'));\n```\n[Learn api](https://tg-bot-api.github.io/bot-api-base/api/)\n### Fetching webhooks\n\nMethod `fetch()` of WebhookFetcher handling Psr\\Http\\Message\\RequestInterface or string and always returns instance of UpdateType or throwing BadRequestException.\n\n```php\n$fetcher = new \\TgBotApi\\BotApiBase\\WebhookFetcher(new \\TgBotApi\\BotApiBase\\BotApiNormalizer());\n$update = $fetcher-\u003efetch($request);\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email wformps@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Greenplugin][link-author-1]\n- [Big-Shark][link-author-2]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-php-v]: https://img.shields.io/travis/php-v/tg-bot-api/bot-api-base.svg?style=flat-square\n[ico-bot-api]: https://img.shields.io/badge/Bot%20API-5.0-blue.svg?style=flat-square\n[ico-version]: https://img.shields.io/packagist/v/tg-bot-api/bot-api-base.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-ci]: https://github.com/tg-bot-api/bot-api-base/workflows/Build/badge.svg\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/tg-bot-api/bot-api-base.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/tg-bot-api/bot-api-base.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/tg-bot-api/bot-api-base.svg?style=flat-square\n[ico-last-commit]: https://img.shields.io/github/last-commit/tg-bot-api/bot-api-base.svg?style=flat-square\n[ico-symfony-recipe]: https://img.shields.io/badge/Symfony%20Recipe-available-brightgreen\n\n[sonar-gate-status-icon]: https://sonarcloud.io/api/project_badges/measure?project=tg-bot-api_bot-api-base\u0026metric=alert_status\n[sonar-bugs-icon]: https://sonarcloud.io/api/project_badges/measure?project=tg-bot-api_bot-api-base\u0026metric=bugs\n[sonar-duplicated-lines-icon]: https://sonarcloud.io/api/project_badges/measure?project=tg-bot-api_bot-api-base\u0026metric=duplicated_lines_density\n[sonar-security-rating-icon]: https://sonarcloud.io/api/project_badges/measure?project=tg-bot-api_bot-api-base\u0026metric=security_rating\n[sonar-bugs-icon]: https://sonarcloud.io/api/project_badges/measure?project=tg-bot-api_bot-api-base\u0026metric=bugs\n\n\n[link-bot-api]: https://core.telegram.org/bots/api\n[link-packagist]: https://packagist.org/packages/tg-bot-api/bot-api-base\n[link-scrutinizer]: https://scrutinizer-ci.com/g/tg-bot-api/bot-api-base/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/tg-bot-api/bot-api-base\n[link-downloads]: https://packagist.org/packages/tg-bot-api/bot-api-base\n[link-author-1]: https://github.com/greenplugin\n[link-author-2]: https://github.com/Big-Shark\n[link-contributors]: ../../contributors\n[link-symfony-recipe]: https://github.com/symfony/recipes-contrib/tree/master/tg-bot-api/bot-api-base/1.0\n[link-php-7-2]: https://www.php.net/releases/7_2_0.php\n[sonar-path]: https://sonarcloud.io/dashboard?id=tg-bot-api_bot-api-base\n[link-ci]: https://github.com/tg-bot-api/bot-api-base/actions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftg-bot-api%2Fbot-api-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftg-bot-api%2Fbot-api-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftg-bot-api%2Fbot-api-base/lists"}