PHPackages                             demonzarov/igusev-telegram-bot-php-sdk - 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. demonzarov/igusev-telegram-bot-php-sdk

AbandonedArchivedLibrary[API Development](/categories/api)

demonzarov/igusev-telegram-bot-php-sdk
======================================

PHP Wrapper for Telegram Bot API

01.3kPHP

Since Oct 28Pushed 3y agoCompare

[ Source](https://github.com/demonzarov/igusev-telegram-bot-php-sdk)[ Packagist](https://packagist.org/packages/demonzarov/igusev-telegram-bot-php-sdk)[ RSS](/packages/demonzarov-igusev-telegram-bot-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Fork todo:
==========

[](#fork-todo)

- Add parsing of all fields of VideoNote

PHP Telegram Bot Api
====================

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/138001fd8cc6931e0a940d2dd831349d6bebbcbf255cccf52b5fd0a933252d65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74656c656772616d2d626f742f6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/telegram-bot/api)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/e25d624320cdb80fada9cfa0c378726b368dc6d440b55179ad0dd477f77a39a5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f54656c656772616d426f742f4170692f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/TelegramBot/Api)[![Coverage Status](https://camo.githubusercontent.com/4de92800fbf4529b39334f01a558d71159248ea2dae3968595ae9ae2ea90aac0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f74656c656772616d626f742f6170692e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/telegrambot/api/code-structure)[![Quality Score](https://camo.githubusercontent.com/09d0e60b320c3860ce73b183a76d282b3cbcdb0304981d641f4e616986e6394b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74656c656772616d626f742f6170692e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/telegrambot/api)[![Total Downloads](https://camo.githubusercontent.com/bc844cb26485029a6ca0f8c47c5c28e23939015d844358ef98384eb0001013d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74656c656772616d2d626f742f6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/telegram-bot/api)

An extended native php wrapper for [Telegram Bot API](https://core.telegram.org/bots/api) without requirements. Supports all methods and types of responses.

Bots: An introduction for developers
------------------------------------

[](#bots-an-introduction-for-developers)

> Bots are special Telegram accounts designed to handle messages automatically. Users can interact with bots by sending them command messages in private or group chats.

> You control your bots using HTTPS requests to [bot API](https://core.telegram.org/bots/api).

> The Bot API is an HTTP-based interface created for developers keen on building bots for Telegram. To learn how to create and set up a bot, please consult [Introduction to Bots](https://core.telegram.org/bots) and [Bot FAQ](https://core.telegram.org/bots/faq).

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

[](#installation)

Via Composer

```
$ composer require telegram-bot/api
```

Usage
-----

[](#usage)

See example [DevAnswerBot](https://github.com/TelegramBot/DevAnswerBot) (russian).

### API Wrapper

[](#api-wrapper)

#### Send message

[](#send-message)

```
$bot = new \TelegramBot\Api\BotApi('YOUR_BOT_API_TOKEN');

$bot->sendMessage($chatId, $messageText);
```

#### Send document

[](#send-document)

```
$bot = new \TelegramBot\Api\BotApi('YOUR_BOT_API_TOKEN');

$document = new \CURLFile('document.txt');

$bot->sendDocument($chatId, $document);
```

#### Send message with reply keyboard

[](#send-message-with-reply-keyboard)

```
$bot = new \TelegramBot\Api\BotApi('YOUR_BOT_API_TOKEN');

$keyboard = new \TelegramBot\Api\Types\ReplyKeyboardMarkup(array(array("one", "two", "three")), true); // true for one-time keyboard

$bot->sendMessage($chatId, $messageText, null, false, null, $keyboard);
```

#### Send message with inline keyboard

[](#send-message-with-inline-keyboard)

```
$bot = new \TelegramBot\Api\BotApi('YOUR_BOT_API_TOKEN');

$keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup(
            [
                [
                    ['text' => 'link', 'url' => 'https://core.telegram.org']
                ]
            ]
        );

$bot->sendMessage($chatId, $messageText, null, false, null, $keyboard);
```

#### Send media group

[](#send-media-group)

```
$bot = new \TelegramBot\Api\BotApi('YOUR_BOT_API_TOKEN');

$media = new \TelegramBot\Api\Types\InputMedia\ArrayOfInputMedia();
$media->addItem(new TelegramBot\Api\Types\InputMedia\InputMediaPhoto('https://avatars3.githubusercontent.com/u/9335727'));
$media->addItem(new TelegramBot\Api\Types\InputMedia\InputMediaPhoto('https://avatars3.githubusercontent.com/u/9335727'));
// Same for video
// $media->addItem(new TelegramBot\Api\Types\InputMedia\InputMediaVideo('http://clips.vorwaerts-gmbh.de/VfE_html5.mp4'));
$bot->sendMediaGroup($chatId, $media);
```

#### Client

[](#client)

```
require_once "vendor/autoload.php";

try {
    $bot = new \TelegramBot\Api\Client('YOUR_BOT_API_TOKEN');
    // or initialize with botan.io tracker api key
    // $bot = new \TelegramBot\Api\Client('YOUR_BOT_API_TOKEN', 'YOUR_BOTAN_TRACKER_API_KEY');

    //Handle /ping command
    $bot->command('ping', function ($message) use ($bot) {
        $bot->sendMessage($message->getChat()->getId(), 'pong!');
    });

    //Handle text messages
    $bot->on(function (\TelegramBot\Api\Types\Update $update) use ($bot) {
        $message = $update->getMessage();
        $id = $message->getChat()->getId();
        $bot->sendMessage($id, 'Your message: ' . $message->getText());
    }, function () {
        return true;
    });

    $bot->run();

} catch (\TelegramBot\Api\Exception $e) {
    $e->getMessage();
}
```

### Botan SDK (not supported more)

[](#botan-sdk-not-supported-more)

[Botan](http://botan.io) is a telegram bot analytics system based on [Yandex.Appmetrica](http://appmetrica.yandex.com/). In this document you can find how to setup Yandex.Appmetrica account, as well as examples of Botan SDK usage.

### Creating an account

[](#creating-an-account)

- Register at
- After registration you will be prompted to create Application. Please use @YourBotName as a name.
- Save an API key from settings page, you will use it as a token for Botan API calls.
- Download lib for your language, and use it as described below. Don`t forget to insert your token!

Since we are only getting started, you may discover that some existing reports in AppMetriсa aren't properly working for Telegram bots, like Geography, Gender, Age, Library, Devices, Traffic sources and Network sections. We will polish that later.

SDK usage
---------

[](#sdk-usage)

#### Standalone

[](#standalone)

```
$tracker = new \TelegramBot\Api\Botan('YOUR_BOTAN_TRACKER_API_KEY');

$tracker->track($message, $eventName);
```

#### API Wrapper

[](#api-wrapper-1)

```
$bot = new \TelegramBot\Api\BotApi('YOUR_BOT_API_TOKEN', 'YOUR_BOTAN_TRACKER_API_KEY');

$bot->track($message, $eventName);
```

You can use method 'getUpdates()'and all incoming messages will be automatically tracked as `Message`-event.

#### Client

[](#client-1)

```
$bot = new \TelegramBot\Api\Client('YOUR_BOT_API_TOKEN', 'YOUR_BOTAN_TRACKER_API_KEY');
```

*All registered commands are automatically tracked as command name*

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

[](#change-log)

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

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Ilya Gusev](https://github.com/iGusev)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.7% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bfa3efadefa1708f19066e65665cc02ed34b537923e75288b26da4bdf27701e2?d=identicon)[demonzarov](/maintainers/demonzarov)

---

Top Contributors

[![iGusev](https://avatars.githubusercontent.com/u/1555767?v=4)](https://github.com/iGusev "iGusev (346 commits)")[![TheMY3](https://avatars.githubusercontent.com/u/9335727?v=4)](https://github.com/TheMY3 "TheMY3 (28 commits)")[![MyZik](https://avatars.githubusercontent.com/u/12817320?v=4)](https://github.com/MyZik "MyZik (20 commits)")[![uc-itcom](https://avatars.githubusercontent.com/u/21470696?v=4)](https://github.com/uc-itcom "uc-itcom (9 commits)")[![POPSuL](https://avatars.githubusercontent.com/u/683358?v=4)](https://github.com/POPSuL "POPSuL (5 commits)")[![lopatinas](https://avatars.githubusercontent.com/u/4607426?v=4)](https://github.com/lopatinas "lopatinas (5 commits)")[![vitorbari](https://avatars.githubusercontent.com/u/1184252?v=4)](https://github.com/vitorbari "vitorbari (4 commits)")[![hb220](https://avatars.githubusercontent.com/u/6212880?v=4)](https://github.com/hb220 "hb220 (4 commits)")[![muhammadmp97](https://avatars.githubusercontent.com/u/17279395?v=4)](https://github.com/muhammadmp97 "muhammadmp97 (3 commits)")[![BoShurik](https://avatars.githubusercontent.com/u/1428848?v=4)](https://github.com/BoShurik "BoShurik (3 commits)")[![demonzarov](https://avatars.githubusercontent.com/u/8440810?v=4)](https://github.com/demonzarov "demonzarov (3 commits)")[![nikserg](https://avatars.githubusercontent.com/u/5680589?v=4)](https://github.com/nikserg "nikserg (2 commits)")[![SergeAx](https://avatars.githubusercontent.com/u/3264530?v=4)](https://github.com/SergeAx "SergeAx (2 commits)")[![Scarboroid](https://avatars.githubusercontent.com/u/8564676?v=4)](https://github.com/Scarboroid "Scarboroid (1 commits)")[![SergeyTrifonov](https://avatars.githubusercontent.com/u/4227170?v=4)](https://github.com/SergeyTrifonov "SergeyTrifonov (1 commits)")[![stelzek](https://avatars.githubusercontent.com/u/188165?v=4)](https://github.com/stelzek "stelzek (1 commits)")[![7eodorus](https://avatars.githubusercontent.com/u/38510234?v=4)](https://github.com/7eodorus "7eodorus (1 commits)")[![vlydev](https://avatars.githubusercontent.com/u/2308269?v=4)](https://github.com/vlydev "vlydev (1 commits)")[![Aj-github-cmd](https://avatars.githubusercontent.com/u/55585727?v=4)](https://github.com/Aj-github-cmd "Aj-github-cmd (1 commits)")[![akeinhell](https://avatars.githubusercontent.com/u/1063877?v=4)](https://github.com/akeinhell "akeinhell (1 commits)")

### Embed Badge

![Health badge](/badges/demonzarov-igusev-telegram-bot-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/demonzarov-igusev-telegram-bot-php-sdk/health.svg)](https://phpackages.com/packages/demonzarov-igusev-telegram-bot-php-sdk)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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