PHPackages                             luzrain/telegram-bot-api - 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. luzrain/telegram-bot-api

ActiveLibrary[API Development](/categories/api)

luzrain/telegram-bot-api
========================

PHP Wrapper for Telegram Bot API

v3.16.1(3mo ago)1037.3k↓33%51MITPHPPHP &gt;=8.2CI passing

Since May 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/luzrain/telegram-bot-api)[ Packagist](https://packagist.org/packages/luzrain/telegram-bot-api)[ Docs](https://github.com/luzrain/TelegramBotApi)[ RSS](/packages/luzrain-telegram-bot-api/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (10)Versions (31)Used By (1)

Telegram Bot API Client for PHP
===============================

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

[![Bot Api 10.1](https://camo.githubusercontent.com/a0d80746073610cfce4dc3f6965b121d9ab99fd03b0129d0d7bb22787fcd70a7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f426f742532304150492d31302e312d3030383863632e7376673f7374796c653d666c6174)](https://core.telegram.org/bots/api-changelog#june-11-2026)[![PHP >=8.2](https://camo.githubusercontent.com/5256b34e50b0e6c5e5e84333f02b9cbfeee7af9b166dc891949f96008753a7e7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d382e322d3737376262332e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/5256b34e50b0e6c5e5e84333f02b9cbfeee7af9b166dc891949f96008753a7e7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d382e322d3737376262332e7376673f7374796c653d666c6174)[![Tests Status](https://camo.githubusercontent.com/140d920a52076ca8d6c1c9e3007dbb6a4329b5e93ddee318bd0ba2b826a8b56c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c757a7261696e2f74656c656772616d2d626f742d6170692f74657374732e79616d6c3f6272616e63683d6d6173746572266c6162656c3d5465737473)](https://camo.githubusercontent.com/140d920a52076ca8d6c1c9e3007dbb6a4329b5e93ddee318bd0ba2b826a8b56c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c757a7261696e2f74656c656772616d2d626f742d6170692f74657374732e79616d6c3f6272616e63683d6d6173746572266c6162656c3d5465737473)[![Downloads](https://camo.githubusercontent.com/9a7e5b25116327545b17d5daf3fe6b009b99293cb333416da9ceef495ded6dcf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c757a7261696e2f74656c656772616d2d626f742d6170693f6c6162656c3d446f776e6c6f61647326636f6c6f723d663238643161)](https://camo.githubusercontent.com/9a7e5b25116327545b17d5daf3fe6b009b99293cb333416da9ceef495ded6dcf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c757a7261696e2f74656c656772616d2d626f742d6170693f6c6162656c3d446f776e6c6f61647326636f6c6f723d663238643161)

A lightweight, object-oriented PHP wrapper for the [Telegram Bot API](https://core.telegram.org/bots/api), with full support for all available methods and types. For details on each method and its parameters, refer to the official [Telegram Bot API documentation](https://core.telegram.org/bots/api#available-methods).

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

[](#installation)

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

Bot API
-------

[](#bot-api)

The Telegram Bot Client is not tied to Guzzle or any specific HTTP client.
It relies on the [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP client and [PSR-17](https://www.php-fig.org/psr/psr-17/) HTTP Factories abstractions.

Note

Using named parameters is recommended, since parameter order and counts can vary between releases.

#### Example Initializing the BotApi with Guzzle HTTP Client

[](#example-initializing-the-botapi-with-guzzle-http-client)

```
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
use Luzrain\TelegramBotApi\BotApi;

$httpFactory = new HttpFactory();
$httpClient = new Client(['http_errors' => false]);

$bot = new BotApi(
    requestFactory: $httpFactory,
    streamFactory: $httpFactory,
    client: $httpClient,
    token: 'API_TOKEN',
);
```

#### Send Message

[](#send-message)

```
use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type;

/**
 * @var Type\Message $response
 */
$response = $bot->call(new Method\SendMessage(
    chatId: 123456789,
    text: 'Example text',
));
```

#### Send Message with Reply Keyboard

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

```
use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type;

$replyKeyboard = new Type\ReplyKeyboardMarkup(
    oneTimeKeyboard: true,
    resizeKeyboard: true,
    keyboard: Type\KeyboardButtonArrayBuilder::create()
        ->addButton(new Type\KeyboardButton(text: 'Button 1'))
        ->addButton(new Type\KeyboardButton(text: 'Button 2'))
        ->addBreak()
        ->addButton(new Type\KeyboardButton(text: 'Web App', webApp: new Type\WebAppInfo('https://github.com/')))
        ->addButton(new Type\KeyboardButton(text: 'Create Poll', requestPoll: new Type\KeyboardButtonPollType())),
);

// For keyboard remove
// $replyKeyboard = new Type\ReplyKeyboardRemove();

/**
 * @var Type\Message $response
 */
$response = $bot->call(new Method\SendMessage(
    chatId: 123456789,
    text: 'Example text',
    replyMarkup: $replyKeyboard,
));
```

#### Send Message with Inline Keyboard

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

```
use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type;

$inlineKeyboard = new Type\InlineKeyboardMarkup(
    inlineKeyboard: Type\InlineKeyboardButtonArrayBuilder::create()
        ->addButton(new Type\InlineKeyboardButton(text: 'Url button', url: 'https://google.com'))
        ->addButton(new Type\InlineKeyboardButton(text: 'Callback button', callbackData: 'callback_data'))
        ->addBreak()
        ->addButton(new Type\InlineKeyboardButton(text: 'Iinline query', switchInlineQueryCurrentChat: 'test')),
);

/**
 * @var Type\Message $response
 */
$response = $bot->call(new Method\SendMessage(
    chatId: 123456789,
    text: 'Example text',
    replyMarkup: $inlineKeyboard ,
));
```

#### Send photo/video/document

[](#send-photovideodocument)

```
use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type;

/**
 * Upload image from local filesystem
 * @var Type\Message $response
 */
$response = $bot->call(new Method\SendPhoto(
    chatId: 123456789,
    photo: new Type\InputFile('/home/user/img/15311661465960.jpg'),
));

/**
 * Send image from the Internet
 * @var Type\Message $response
 */
$response = $bot->call(new Method\SendPhoto(
    chatId: 123456789,
    photo: 'https://avatars3.githubusercontent.com/u/9335727',
));

/**
 * Upload Document
 * @var Type\Message $response
 */
$response = $bot->call(new Method\SendDocument(
    chatId: 123456789,
    document: new Type\InputFile('/home/user/files/file.zip'),
    thumbnail: new Type\InputFile('/home/user/img/thumb.jpg'),
    caption: 'Test file',
));

/**
 * You can also use these methods:
 * SendPhoto, SendAudio, SendDocument, SendVideo, SendAnimation, SendVoice, SendVideoNote
 */
```

#### Send Media Group

[](#send-media-group)

```
use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type;

/**
 * @var Type\Message[] $response
 */
$response = $bot->call(new Method\SendMediaGroup(
    chatId: 123456789,
    media: [
        new Type\InputMediaPhoto(
            media: new Type\InputFile('/home/user/img/15311661465960.jpg'),
            caption: 'Test media 1',
        ),
        new Type\InputMediaPhoto(
            media: new Type\InputFile('/home/user/img/16176321866250.png'),
            caption: 'Test media 2',
        ),
    ],
));
```

Client Api
----------

[](#client-api)

#### Webhook Client

[](#webhook-client)

```
use Luzrain\TelegramBotApi\ClientApi;
use Luzrain\TelegramBotApi\Event;
use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type;

$client = new ClientApi();

// Handle any type of update
$client->on(new Event\Update(function(Type\Update $update) {
    // Any update received
}));

// Handle /ping command
$client->on(new Event\Command('/ping', function(Type\Message $message) {
    /**
     * You can return any Method object from here, and it will be sent as an answer to the webhook.
     * Be aware that your cannot send methods with uploading local files from here, use BotApi instead.
     */
    return new Method\SendMessage(
        chatId: $message->chat->id,
        text: 'pong!',
    );
}));

// Handle text messages
$client->on(new Event\TextMessage(function(Type\Message $message) {
    return new Method\SendMessage(
        chatId: $message->chat->id,
        text: 'Your message: ' . $message->text,
    );
}));

$client->run();
```

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance79

Regular maintenance activity

Popularity37

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 52% 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 ~70 days

Total

30

Last Release

112d ago

Major Versions

v1.0.0 → v2.0.02023-06-28

v2.x-dev → v3.0.02024-03-01

PHP version history (3 changes)v1.0.0PHP &gt;=8.0.0

v2.0.0PHP ^8.2

v2.3.1PHP &gt;=8.2

### Community

Maintainers

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

---

Top Contributors

[![iGusev](https://avatars.githubusercontent.com/u/1555767?v=4)](https://github.com/iGusev "iGusev (346 commits)")[![luzrain](https://avatars.githubusercontent.com/u/25800964?v=4)](https://github.com/luzrain "luzrain (217 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)")[![lopatinas](https://avatars.githubusercontent.com/u/4607426?v=4)](https://github.com/lopatinas "lopatinas (5 commits)")[![POPSuL](https://avatars.githubusercontent.com/u/683358?v=4)](https://github.com/POPSuL "POPSuL (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)")[![SergeAx](https://avatars.githubusercontent.com/u/3264530?v=4)](https://github.com/SergeAx "SergeAx (2 commits)")[![nikserg](https://avatars.githubusercontent.com/u/5680589?v=4)](https://github.com/nikserg "nikserg (2 commits)")[![flaksp](https://avatars.githubusercontent.com/u/12474739?v=4)](https://github.com/flaksp "flaksp (1 commits)")[![McArrow](https://avatars.githubusercontent.com/u/39399?v=4)](https://github.com/McArrow "McArrow (1 commits)")[![7eodorus](https://avatars.githubusercontent.com/u/38510234?v=4)](https://github.com/7eodorus "7eodorus (1 commits)")[![div-production](https://avatars.githubusercontent.com/u/19323493?v=4)](https://github.com/div-production "div-production (1 commits)")[![Nightprince](https://avatars.githubusercontent.com/u/12217476?v=4)](https://github.com/Nightprince "Nightprince (1 commits)")[![palehin](https://avatars.githubusercontent.com/u/14148595?v=4)](https://github.com/palehin "palehin (1 commits)")[![pembrock](https://avatars.githubusercontent.com/u/1942441?v=4)](https://github.com/pembrock "pembrock (1 commits)")

---

Tags

telegramtelegram-bottelegram-bot-apibottelegrambot apitelegram bottelegram bot api

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/luzrain-telegram-bot-api/health.svg)

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[mollie/mollie-api-php

Mollie API client library for PHP. Mollie is a European Payment Service provider and offers international payment methods such as Mastercard, VISA, American Express and PayPal, and local payment methods such as iDEAL, Bancontact, SOFORT Banking, SEPA direct debit, Belfius Direct Net, KBC Payment Button and various gift cards such as Podiumcadeaukaart and fashioncheque.

60216.0M85](/packages/mollie-mollie-api-php)[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.9M94](/packages/irazasyed-telegram-bot-sdk)[tg-bot-api/bot-api-base

Clear and simple Telegram bot API

22281.9k2](/packages/tg-bot-api-bot-api-base)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[telegram-bot/api

PHP Wrapper for Telegram Bot API

1.2k2.5M32](/packages/telegram-bot-api)

PHPackages © 2026

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