PHPackages                             alxmsl/telegrambotclient - 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. alxmsl/telegrambotclient

ActiveLibrary[API Development](/categories/api)

alxmsl/telegrambotclient
========================

Powerful client for Telegram Bot API

v1.0.4(10y ago)5781[1 issues](https://github.com/alxmsl/TelegramBotClient/issues)Apache-2.0PHP

Since Jul 7Pushed 10y ago4 watchersCompare

[ Source](https://github.com/alxmsl/TelegramBotClient)[ Packagist](https://packagist.org/packages/alxmsl/telegrambotclient)[ RSS](/packages/alxmsl-telegrambotclient/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

TelegramBotClient
=================

[](#telegrambotclient)

[![License](https://camo.githubusercontent.com/06d0f8b0f237cb93c5b0bb1871b7b1e45e208c674ef33ceb1c0c94d2c843319c/68747470733a2f2f706f7365722e707567782e6f72672f616c786d736c2f74656c656772616d626f74636c69656e742f6c6963656e7365)](https://packagist.org/packages/alxmsl/telegrambotclient)[![Latest Stable Version](https://camo.githubusercontent.com/63f2025fe33c5b27b8743fc314b18642ae16c3df49f8f83fbb801010f452e4c3/68747470733a2f2f706f7365722e707567782e6f72672f616c786d736c2f74656c656772616d626f74636c69656e742f76657273696f6e)](https://packagist.org/packages/alxmsl/telegrambotclient)[![Total Downloads](https://camo.githubusercontent.com/df46ab9515a963c3fa6d44fb47fd318a8ae6b05df805255f1c89f6aee2cf0e51/68747470733a2f2f706f7365722e707567782e6f72672f616c786d736c2f74656c656772616d626f74636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/alxmsl/telegrambotclient)

[![Build Status](https://camo.githubusercontent.com/ba443912020c4d2328cae8ba566d684a5106801adb51bbf2ffb9a2f2efea868b/68747470733a2f2f7472617669732d63692e6f72672f616c786d736c2f54656c656772616d426f74436c69656e742e737667)](https://travis-ci.org/alxmsl/TelegramBotClient)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2d7f5759d71d3034e3332fc1c03eb36ea77fe5bbf9f2b42c48a90ab584fa0f69/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c786d736c2f54656c656772616d426f74436c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alxmsl/TelegramBotClient/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/1b218578412abb215064a953cb4e05fa59f425908c710252ed61d3fd3c88c991/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c786d736c2f54656c656772616d426f74436c69656e742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alxmsl/TelegramBotClient/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/9350916b96664b82ad4ef53f18917207438752522345c45993053fdfbb41d6a7/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3536303161326336663566326562303031613030306164652f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/5601a2c6f5f2eb001a000ade)

Powerful client for [Telegram Bot API](https://core.telegram.org/bots)

Advantages
----------

[](#advantages)

1. Lightweight. You could use only two classes for work: [API client](/source/Client.php) and [response](/source/Response.php)
2. Powerful. Same time you could use all 16 Bot API [types](https://core.telegram.org/bots/api#available-types) and all 13 Bot API [methods](https://core.telegram.org/bots/api#available-methods)
3. `composer` support makes installation simplified
4. Independent namespace helps to use Bot API client on different projects and frameworks
5. [CLI utility](/bin/call.php) helps you to test Bot API interactions

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

[](#installation)

For simplified usage all what you need is require packet via composer

```
    $ composer require alxmsl/telegrambotclient

```

In third-party projects, require packet in your `composer.json`

```
    "alxmsl/telegrambotclient": "*"

```

...and update composer: `composer update`

Usages
------

[](#usages)

First what you need is client instance. Just create it

```
    use alxmsl\Telegram\Bot\Client;
    $Client = new Client('123456789:Y0uR5EcREtT0KEn');

```

....then you could call bot methods directly and got API response string

```
    $result = $Client->call(, );
    printf("%s\n", $result);

```

...or use methods wrappers

```
    $updates = $Client->getUpdates(0, 1);
    var_dump($updates);

```

Method wrappers helps you to return specific result types as described in [API documentation](https://core.telegram.org/bots/api#available-types). For example, using `getUpdates` you be returned array of [Update](/source/Type/Update.php) instances, `sendMessage` wrapper returns you [Message](/source/Type/Message.php) object etc.

```
    use alxmsl\Telegram\Bot\Client;
    use alxmsl\Telegram\Bot\Type\Message;

    $Client  = new Client('123456789:Y0uR5EcREtT0KEn');
    $Message = $Client->sendMessage(34567, 'hello');
    ($Message instanceof Message); // that's TRUE

```

When something wrong, wrapper throws `UnsuccessfulException`. For example code

```
    $Client = new Client('123456789:Br0KEnT0kEN');
    try {
        $Message = $Client->getMe();
    } catch (UnsuccessfulException $Ex) {
        printf("%s\n%s", $Ex->getCode(), $Ex->getMessage());
    }

```

is showed you

```
401
Error: Unauthorized

```

Console usage
-------------

[](#console-usage)

You could use script `call.php` to call Telegram Bot API directly

```
    $ php bin/call.php -h
    Using: /usr/local/bin/php bin/call.php [-h|--help] -m|--method [-p|--parameters] -t|--token
    -h, --help  - show help
    -m, --method  - bot method name
    -p, --parameters  - method calls parameters
    -t, --token  - authentication token

```

Using utility you could test your bot's authentication token

```
    $ php bin/call.php -t='123456789:Y0uR5EcREtT0KEn' -m='getMe'
    {"ok":true,"result":{"id":123456789,"first_name":"alxmslClientBot","username":"alxmslClientBot"}}

```

When something wrong^ utility will show you error response from Bot API

```
    $ php bin/call.php -t='123456789:Br0KEnT0kEN' -m='getMe'
    {"ok":false,"error_code":401,"description":"Error: Unauthorized"}

```

... got updates etc.

```
    $ php bin/call.php -t='123456789:Y0uR5EcREtT0KEn' -m='getUpdates' -p='{"limit":1}'
    {"ok":true,"result":[{"update_id":7654321,"message":{"message_id":2,"from":{"id":34567,"first_name":"Alexey","last_name":"Maslov"},"chat":{"id":34567,"first_name":"Alexey","last_name":"Maslov"},"date":1435870467,"text":"\/start"}}]}

```

Tests
-----

[](#tests)

For completely tests running just call `phpunit` command

```
    $ phpunit
    PHPUnit 4.7.5 by Sebastian Bergmann and contributors.

    Runtime:	PHP 5.5.23

    ................

    Time: 190 ms, Memory: 9.00Mb

    OK (16 tests, 784 assertions)

```

License
-------

[](#license)

Copyright 2015 Alexey Maslov

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

```
http://www.apache.org/licenses/LICENSE-2.0

```

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~33 days

Total

5

Last Release

3834d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/950057?v=4)[Alexey Maslov](/maintainers/alxmsl)[@alxmsl](https://github.com/alxmsl)

---

Top Contributors

[![alxmsl](https://avatars.githubusercontent.com/u/950057?v=4)](https://github.com/alxmsl "alxmsl (59 commits)")

---

Tags

apibottelegrambot api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alxmsl-telegrambotclient/health.svg)

```
[![Health](https://phpackages.com/badges/alxmsl-telegrambotclient/health.svg)](https://phpackages.com/packages/alxmsl-telegrambotclient)
```

###  Alternatives

[longman/telegram-bot

PHP Telegram bot

4.0k2.1M50](/packages/longman-telegram-bot)[telegram-bot/api

PHP Wrapper for Telegram Bot API

1.2k2.4M29](/packages/telegram-bot-api)[kuvardin/telegram-bots-api

SDK for Telegram bots API

145.5k](/packages/kuvardin-telegram-bots-api)[zelenin/telegram-bot-api

Telegram Bot API Client

5917.2k](/packages/zelenin-telegram-bot-api)

PHPackages © 2026

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