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

Abandoned → [phptg/bot-api](/?search=phptg%2Fbot-api)Library[API Development](/categories/api)

vjik/telegram-bot-api
=====================

PHP library for working with Telegram API

0.21.1(3w ago)12712.2k↓55.3%10[1 issues](https://github.com/phptg/bot-api/issues)BSD-3-ClausePHPCI passing

Since Jun 10Pushed 5d ago2 watchersCompare

[ Source](https://github.com/phptg/bot-api)[ Packagist](https://packagist.org/packages/vjik/telegram-bot-api)[ Fund](https://boosty.to/vjik)[ Fund](https://pay.cloudtips.ru/p/192ce69b)[ RSS](/packages/vjik-telegram-bot-api/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (33)Versions (42)Used By (0)

 [ ![PHPTG](logo.png) ](https://github.com/phptg)Telegram Bot API for PHP
========================

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

[![Latest Stable Version](https://camo.githubusercontent.com/eb1d229d923e5e8b4d0e913a20d732513f7b40cb701bf5b5db97af43e5c9a371/68747470733a2f2f706f7365722e707567782e6f72672f70687074672f626f742d6170692f76)](https://packagist.org/packages/phptg/bot-api)[![Total Downloads](https://camo.githubusercontent.com/85219313d2370bf99c4362bdec9cea4c3a107c16c8bff647e900f5c4bf5a5694/68747470733a2f2f706f7365722e707567782e6f72672f70687074672f626f742d6170692f646f776e6c6f616473)](https://packagist.org/packages/phptg/bot-api)[![Build status](https://github.com/phptg/bot-api/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/phptg/bot-api/actions/workflows/build.yml?query=branch%3Amaster)[![Coverage Status](https://camo.githubusercontent.com/3cae9ce69d308f7e9853d2fce1ead848d1bc097ac48f6939f8af0580ec97e919/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f70687074672f626f742d6170692f62616467652e737667)](https://coveralls.io/github/phptg/bot-api)[![Mutation score](https://camo.githubusercontent.com/413004bab56eba854925afd4d2b14a115a987d1822519b2437a4cbc1080cd38e/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532467068707467253246626f742d6170692532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/phptg/bot-api/master)[![Static analysis](https://github.com/phptg/bot-api/actions/workflows/psalm.yml/badge.svg?branch=master)](https://github.com/phptg/bot-api/actions/workflows/psalm.yml?query=branch%3Amaster)

The package provides a simple and convenient way to interact with the Telegram Bot API.

✔️ Telegram Bot API 10.1 (June 11, 2026) is **fully supported**.

♻️ **Zero dependencies** — no third-party libraries, only native PHP.

Important

This project is developed and maintained by [Sergei Predvoditelev](https://github.com/vjik). Community support helps keep the project actively developed and well maintained. You can support the project using the following services:

- [Boosty](https://boosty.to/vjik)
- [CloudTips](https://pay.cloudtips.ru/p/192ce69b)

Thank you for your support ❤️

Requirements
------------

[](#requirements)

- PHP (64-bit) 8.2 - 8.5.

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

[](#installation)

The package can be installed with [Composer](https://getcomposer.org/download/):

```
composer require phptg/bot-api
```

General usage
-------------

[](#general-usage)

To make requests to the Telegram Bot API, you need to create an instance of the `TelegramBotApi` class.

```
use Phptg\BotApi\TelegramBotApi;

// API
$api = new TelegramBotApi(
    // Telegram bot authentication token
    '110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw',
);
```

Now you can use the `$api` instance to interact with the Telegram Bot API. Method names are the same as in the [Telegram Bot API documentation](https://core.telegram.org/bots/api). For example:

```
use Phptg\BotApi\Type\InputFile

// Specify a URL for outgoing webhook
$api->setWebhook('https://example.com/webhook');

// Send text message
$api->sendMessage(
    chatId: 22351,
    text: 'Hello, world!',
);

// Send local photo
$api->sendPhoto(
    chatId: 22351,
    photo: new InputFile('/path/to/photo.jpg'),
);
```

The result will be either a `FailResult` instance (occurring on an error) or an object of the corresponding type (occurring on success). For example:

```
// Result is an array of `Phptg\BotApi\Update\Update` objects
$updates = $api->getUpdates();
```

Documentation
-------------

[](#documentation)

### `TelegramBotApi`

[](#telegrambotapi)

`TelegramBotApi` constructor parameters:

- `$token` (required) — Telegram bot authentication token;
- `$baseUrl` — the base URL for Telegram Bot API requests (default `https://api.telegram.org`).
- `$transport` — the [transport](docs/transport.md) to make requests to Telegram Bot API ([cURL](docs/transport.md#curl)or [native](docs/transport.md#native) transport will be used by default).
- `$logger` — the [PSR-3](https://www.php-fig.org/psr/psr-3/) compatible logger to log requests to Telegram Bot API and response handling errors. See [logging](docs/logging.md) for more information.

Method names are the same as in the [Telegram Bot API documentation](https://core.telegram.org/bots/api).

### Files

[](#files)

#### File URL

[](#file-url)

Use `TelegramBotApi::makeFileUrl()` method to make a URL for downloading a file from the Telegram server. For example:

```
/**
 * @var \Phptg\BotApi\TelegramBotApi $api
 * @var \Phptg\BotApi\Type\File $file
 */

// By `File` instance
$url = $api->makeFileUrl($file);

// By file path is taken from the Telegram response
$url = $api->makeFileUrl('photos/file_2');
```

#### File downloading

[](#file-downloading)

Use `TelegramBotApi::downloadFile()` method to download a file from the Telegram server. The method returns a `DownloadedFile` instance with `getStream()`, `getBody()` and `saveTo()` methods. For example:

```
/**
 * @var \Phptg\BotApi\TelegramBotApi $api
 * @var \Phptg\BotApi\Type\File $file
 */

// Get file content as string
$content = $api->downloadFile($file)->getBody();

// Get file content as stream
$stream = $api->downloadFile('photos/file_2')->getStream();

// Download and save file
$api->downloadFile($file)->saveTo('/local/path/to/file.jpg');
```

### Guides

[](#guides)

- [Transport](docs/transport.md)
- [Logging](docs/logging.md)
- [Webhook handling](docs/webhook-handling.md)
- [Custom requests](docs/custom-requests.md)
- [Internals](docs/internals.md)

If you have any questions or problems with this package, use [author telegram chat](https://t.me/predvoditelev_chat) for communication.

License
-------

[](#license)

The `phptg/bot-api` is free software. It is released under the terms of the BSD License. Please see [`LICENSE`](./LICENSE) for more information.

Credits
-------

[](#credits)

The package is inspired by [Botasis](https://github.com/botasis) code originally created by [Viktor Babanov](https://github.com/viktorprogger).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance97

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

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

###  Release Activity

Cadence

Every ~20 days

Total

37

Last Release

22d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/53e5ee1dedd50f71e4aeeac2929f786cdfb400359d4776e6cd806388d0d5df2c?d=identicon)[vjik](/maintainers/vjik)

---

Top Contributors

[![vjik](https://avatars.githubusercontent.com/u/525501?v=4)](https://github.com/vjik "vjik (200 commits)")[![vudaltsov](https://avatars.githubusercontent.com/u/2552865?v=4)](https://github.com/vudaltsov "vudaltsov (2 commits)")[![ionov-e](https://avatars.githubusercontent.com/u/82158159?v=4)](https://github.com/ionov-e "ionov-e (1 commits)")[![polopolaw](https://avatars.githubusercontent.com/u/21076418?v=4)](https://github.com/polopolaw "polopolaw (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![semhoun](https://avatars.githubusercontent.com/u/54236487?v=4)](https://github.com/semhoun "semhoun (1 commits)")[![userator](https://avatars.githubusercontent.com/u/305457?v=4)](https://github.com/userator "userator (1 commits)")[![rossaddison](https://avatars.githubusercontent.com/u/8538339?v=4)](https://github.com/rossaddison "rossaddison (1 commits)")[![injektion](https://avatars.githubusercontent.com/u/3210129?v=4)](https://github.com/injektion "injektion (1 commits)")

---

Tags

telegam-bot-apitelegramtelegram-botapibottelegram

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k28.0M318](/packages/openai-php-client)[tempest/framework

The PHP framework that gets out of your way.

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

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

1003.9M50](/packages/getbrevo-brevo-php)[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)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)

PHPackages © 2026

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