PHPackages                             tg-bot-api/bot-api-base - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tg-bot-api/bot-api-base

ActiveLibrary[API Development](/categories/api)

tg-bot-api/bot-api-base
=======================

Clear and simple Telegram bot API

1.8.0(4y ago)22278.8k↓19.3%71[3 issues](https://github.com/tg-bot-api/bot-api-base/issues)2MITPHPPHP &gt;7.3

Since Jan 11Pushed 4y ago16 watchersCompare

[ Source](https://github.com/tg-bot-api/bot-api-base)[ Packagist](https://packagist.org/packages/tg-bot-api/bot-api-base)[ Docs](https://github.com/tg-bot-api/telegram-bot-api)[ RSS](/packages/tg-bot-api-bot-api-base/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (31)Used By (2)

Telegram Bot Api Base
=====================

[](#telegram-bot-api-base)

[![Telegram bot api](https://camo.githubusercontent.com/234c17f8ef385dc8d661ef4b990c18d71e767c53a188957e400e0f915dd41950/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f426f742532304150492d352e302d626c75652e7376673f7374796c653d666c61742d737175617265)](https://core.telegram.org/bots/api)[![Latest Version on Packagist](https://camo.githubusercontent.com/ba9ac8c5b5eba1018df590e64514f3b069f93bb6764dfeeaaa0606e00dfdc3e5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74672d626f742d6170692f626f742d6170692d626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tg-bot-api/bot-api-base)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Coverage Status](https://camo.githubusercontent.com/ea62927783a886c7595c91c4150f79fd421d62285b136c7e18ef0601909ae58d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f74672d626f742d6170692f626f742d6170692d626173652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tg-bot-api/bot-api-base/code-structure)[![build](https://github.com/tg-bot-api/bot-api-base/workflows/Build/badge.svg)](https://github.com/tg-bot-api/bot-api-base/actions)[![Quality Score](https://camo.githubusercontent.com/b7645e1892921f4e87949fbc5f73e46b04e873844a5fb61e1bf0c0951745990c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74672d626f742d6170692f626f742d6170692d626173652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tg-bot-api/bot-api-base)[![PHP Version >= 7.2](https://camo.githubusercontent.com/9f430df0fa0443dcd26470565a68079c57572a1e1a69902b790b28860068d2e1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7068702d762f74672d626f742d6170692f626f742d6170692d626173652e7376673f7374796c653d666c61742d737175617265)](https://www.php.net/releases/7_2_0.php)[![Symfony Recipe](https://camo.githubusercontent.com/c4880bdd4dfdd6a0d1d49538e4c0d0318e77c1ecfd05fdea2347ade5ee5a8075/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792532305265636970652d617661696c61626c652d627269676874677265656e)](https://github.com/symfony/recipes-contrib/tree/master/tg-bot-api/bot-api-base/1.0)

[![Quality Gate Status](https://camo.githubusercontent.com/a2e9028b6a31050cc332f68f2f98c3f3027c704ee24c4fa9b3e2f100618a4519/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d74672d626f742d6170695f626f742d6170692d62617365266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=tg-bot-api_bot-api-base)[![Bugs](https://camo.githubusercontent.com/234d50420796a377cc9c3064ae03bddf5ebccc0e0b492fd1db1781ab679359cd/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d74672d626f742d6170695f626f742d6170692d62617365266d65747269633d62756773)](https://sonarcloud.io/dashboard?id=tg-bot-api_bot-api-base)[![Duplicated Lines (%)](https://camo.githubusercontent.com/74438a109c8057d2e2fcb47150de163ffa88b591714734e3a8fd77060f4c188d/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d74672d626f742d6170695f626f742d6170692d62617365266d65747269633d6475706c6963617465645f6c696e65735f64656e73697479)](https://sonarcloud.io/dashboard?id=tg-bot-api_bot-api-base)[![Security Rating](https://camo.githubusercontent.com/bd03d469f64bc584398e4b44716e6b60fdc257cdee832852a8be5bb8c30a1f02/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d74672d626f742d6170695f626f742d6170692d62617365266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/dashboard?id=tg-bot-api_bot-api-base)

#### Supported Telegram Bot API 5.0 (November 4, 2020)

[](#supported-telegram-bot-api-50-november-4-2020)

Installation
------------

[](#installation)

Via Composer

```
composer require tg-bot-api/bot-api-base --prefer-dist
```

Usage
-----

[](#usage)

We support all psr17 and psr18 implementations, but we will use guzzle6 for example

```
composer require php-http/guzzle6-adapter http-interop/http-factory-guzzle --prefer-dist
```

```
$botKey = '';

$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
$client = new Http\Adapter\Guzzle6\Client();

$apiClient = new \TgBotApi\BotApiBase\ApiClient($requestFactory, $streamFactory, $client);
$bot = new \TgBotApi\BotApiBase\BotApi($botKey, $apiClient, new \TgBotApi\BotApiBase\BotApiNormalizer());

$userId = '';

$bot->send(\TgBotApi\BotApiBase\Method\SendMessageMethod::create($userId, 'Hi'));
```

You can configure it to work in symfony, for example, in [this way](https://gist.github.com/greenplugin/09179bee606aa01b1ee00d049ab78fc4).

If you want to use your own api server - you can set url as 4th param in bot api

```
$bot = new \TgBotApi\BotApiBase\BotApi('', $apiClient, new \TgBotApi\BotApiBase\BotApiNormalizer(), '');
```

### Allowed methods:

[](#allowed-methods)

MethodAllowed typeresponse`add`AddStickerToSetMethodbool`answer`AnswerCallbackQueryMethod, AnswerInlineQueryMethod, AnswerPreCheckoutQueryMethod, AnswerShippingQueryMethodbool`create`CreateNewStickerSetMethodbool`delete`DeleteChatPhotoMethod, DeleteChatStickerSetMethod, DeleteMessageMethod, DeleteStickerFromSetMethod, DeleteWebhookMethodbool`edit`EditMessageCaptionMethod, EditMessageLiveLocationMethod, EditMessageMediaMethod, EditMessageReplyMarkupMethod, EditMessageTextMethodbool`forward`ForwardMessageMethodMessageType`kick`KickChatMemberMethodbool`leave`LeaveChatMethodbool`pin`PinChatMessageMethodbool`promote`PromoteChatMemberMethodbool`restrict`RestrictChatMemberMethodbool`send`SendPhotoMethod, SendAudioMethod, SendDocumentMethod, SendVideoMethod, SendAnimationMethod, SendVoiceMethod, SendVideoNoteMethod, SendGameMethod, SendInvoiceMethod, SendLocationMethod, SendVenueMethod, SendContactMethod, SendStickerMethod, SendMessageMethod, SendPollMethod, SendDiceMethodMessageType`set`SetChatDescriptionMethod, SetChatPhotoMethod, SetChatStickerSetMethod, SetChatTitleMethod, SetGameScoreMethod, SetStickerPositionInSetMethod, SetWebhookMethod, SetPassportDataErrorsMethod, SetChatPermissionsMethod, SetChatAdministratorCustomTitleMethod, SetMyCommandMethod, SetStickerSetThumbMethodbool`stop`StopMessageLiveLocationMethodbool`stopPoll`StopPollMethodPoll`unban`UnbanChatMemberMethodbool`unpin`UnpinChatMessageMethod, UnpinAllChatMessagesMethodbool`upload`UploadStickerFileMethodFileType`exportChatInviteLink`ExportChatInviteLinkMethodstring`sendChatAction`SendChatActionMethodbool`getUpdates`GetUpdatesMethodUpdateType\[\]`getMe`GetMeMethodUserType`getMyCommands`GetMyCommandsMethodBotCommandType`getUserProfilePhotos`GetUserProfilePhotosMethodUserProfilePhotosType`getWebhookInfo`GetWebhookInfoMethodWebhookInfoType`getChatMembersCount`GetChatMembersCountMethodint`getChat`GetChatMethodChatType`getChatAdministrators`GetChatAdministratorsMethodChatMemberType\[\]`getChatMember`GetChatMemberMethodChatMemberType`getChatMenuButton`GetChatMenuButtonMethodMenuButtonType`getGameHighScores`GetGameHighScoresMethodGameHighScoreType\[\]`getStickerSet`GetStickerSetMethodStickerSetType`getFile`GetFileMethodFileType`sendMediaGroup`SendMediaGroupMethodMessageType\[\]`getAbsoluteFilePath`FileTypestring`logOut`LogOutMethodbool`close`CloseMethodbool`copyMessage`CopyMessageMethodMessageIdType`call($method, [string $type])`any method class, \[optional expected type\]array or excepted type objectImplemented all methods and types referenced by [official Api](https://core.telegram.org/bots/api)

You can use `BotApiComplete` instance as helper to call all methods from [official Api](https://core.telegram.org/bots/api) like this:

```
$botKey = '';

$requestFactory = new Http\Factory\Guzzle\RequestFactory()
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
$client = new Http\Adapter\Guzzle6\Client();

$apiClient = new \TgBotApi\BotApiBase\ApiClient($requestFactory, $streamFactory, $client);
$bot = new \TgBotApi\BotApiBase\BotApiComplete($botKey, $apiClient, new \TgBotApi\BotApiBase\BotApi\BotApiNormalizer());

$userId = '';

$bot->sendMessage(\TgBotApi\BotApiBase\Method\SendMessageMethod::create($userId, 'Hi'));
```

[Learn api](https://tg-bot-api.github.io/bot-api-base/api/)

### Fetching webhooks

[](#fetching-webhooks)

Method `fetch()` of WebhookFetcher handling Psr\\Http\\Message\\RequestInterface or string and always returns instance of UpdateType or throwing BadRequestException.

```
$fetcher = new \TgBotApi\BotApiBase\WebhookFetcher(new \TgBotApi\BotApiBase\BotApiNormalizer());
$update = $fetcher->fetch($request);
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Greenplugin](https://github.com/greenplugin)
- [Big-Shark](https://github.com/Big-Shark)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 78.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~48 days

Recently: every ~171 days

Total

26

Last Release

1462d ago

Major Versions

0.4.0-beta → 1.0.02019-05-01

PHP version history (2 changes)0.1.0-betaPHP &gt;7.2

1.7.0PHP &gt;7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fde4d6eff4f730855b74c1ccb976b8969e5b5d0c8b6836e8861b94f419702a0?d=identicon)[greenplugin](/maintainers/greenplugin)

---

Top Contributors

[![greenplugin](https://avatars.githubusercontent.com/u/15276608?v=4)](https://github.com/greenplugin "greenplugin (180 commits)")[![Big-Shark](https://avatars.githubusercontent.com/u/646054?v=4)](https://github.com/Big-Shark "Big-Shark (42 commits)")[![Uterok](https://avatars.githubusercontent.com/u/20558885?v=4)](https://github.com/Uterok "Uterok (2 commits)")[![xepozz](https://avatars.githubusercontent.com/u/6815714?v=4)](https://github.com/xepozz "xepozz (1 commits)")[![gusaln](https://avatars.githubusercontent.com/u/7484242?v=4)](https://github.com/gusaln "gusaln (1 commits)")[![cybernet](https://avatars.githubusercontent.com/u/125879?v=4)](https://github.com/cybernet "cybernet (1 commits)")[![jan-di](https://avatars.githubusercontent.com/u/23323185?v=4)](https://github.com/jan-di "jan-di (1 commits)")

---

Tags

phpphp-telegram-bottelegramtelegram-bottelegram-bot-apitelegram-bot-phptelegram-phptelegram-php-botbottelegramtelegram bottelegram bot apitelegram phpphp-bottg-bot-apiphp-telegram-bot

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tg-bot-api-bot-api-base/health.svg)

```
[![Health](https://phpackages.com/badges/tg-bot-api-bot-api-base/health.svg)](https://phpackages.com/packages/tg-bot-api-bot-api-base)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[luzrain/telegram-bot-api

PHP Wrapper for Telegram Bot API

1032.8k1](/packages/luzrain-telegram-bot-api)[telegram-bot-sdk/telegram-bot-sdk

The Telegram Bot API PHP SDK

32480.5k](/packages/telegram-bot-sdk-telegram-bot-sdk)[bushlanov-dev/max-bot-api-client-php

Max Bot API Client library

281.6k](/packages/bushlanov-dev-max-bot-api-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
