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.17(2mo ago)12111.9k↓31.8%8[1 issues](https://github.com/phptg/bot-api/issues)BSD-3-ClausePHPCI passing

Since Jun 10Pushed 2mo 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 1mo ago

READMEChangelog (10)Dependencies (19)Versions (35)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)](https://github.com/phptg/bot-api/actions/workflows/build.yml)[![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 9.5 (March 1, 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: InputFile::fromLocalFile('/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)
- [Resource readers](docs/resource-readers.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

49

—

FairBetter than 95% of packages

Maintenance86

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.4% 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 ~21 days

Recently: every ~5 days

Total

31

Last Release

78d 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 (188 commits)")[![injektion](https://avatars.githubusercontent.com/u/3210129?v=4)](https://github.com/injektion "injektion (1 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)")[![rossaddison](https://avatars.githubusercontent.com/u/8538339?v=4)](https://github.com/rossaddison "rossaddison (1 commits)")[![vudaltsov](https://avatars.githubusercontent.com/u/2552865?v=4)](https://github.com/vudaltsov "vudaltsov (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.8k22.6M232](/packages/openai-php-client)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

963.1M35](/packages/getbrevo-brevo-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[phptg/bot-api

PHP library for working with Telegram API

1218.5k4](/packages/phptg-bot-api)[wordpress/php-ai-client

A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.

26236.6k14](/packages/wordpress-php-ai-client)[mozex/anthropic-php

Anthropic PHP is a supercharged community-maintained PHP API client that allows you to interact with Anthropic API.

46365.1k13](/packages/mozex-anthropic-php)

PHPackages © 2026

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