PHPackages                             prog-time/max-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. prog-time/max-php-sdk

ActiveLibrary[API Development](/categories/api)

prog-time/max-php-sdk
=====================

PHP SDK for the Max messenger Bot API

1.1.4(2mo ago)45201MITPHPPHP ^8.1CI passing

Since Feb 21Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/prog-time/max-php-sdk)[ Packagist](https://packagist.org/packages/prog-time/max-php-sdk)[ Docs](https://github.com/prog-time/max-php-sdk)[ RSS](/packages/prog-time-max-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (15)Versions (9)Used By (0)

Max Bot PHP SDK
===============

[](#max-bot-php-sdk)

PHP SDK for the [Max](https://max.ru) messenger Bot API.

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

[](#requirements)

- PHP 8.1+
- Composer

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

[](#installation)

```
composer require prog-time/max-php-sdk
```

Quick start
-----------

[](#quick-start)

```
use MaxBotApi\MaxClient;
use MaxBotApi\Config;

$client = new MaxClient(new Config('your-bot-token'));

$client->messages->send(text: 'Hello!', chatId: 123456789);
```

Configuration
-------------

[](#configuration)

```
$config = new Config(
    token:   'your-bot-token',              // required
    baseUrl: 'https://platform-api.max.ru', // optional, default value
    timeout: 10,                            // optional, seconds, default 10
);
```

---

Resources
---------

[](#resources)

### Bot

[](#bot)

```
$bot = $client->bot->me();

echo $bot->name;
echo $bot->userId;
echo $bot->username;
```

---

### Messages

[](#messages)

**Send a message**

```
// to a chat
$message = $client->messages->send(text: 'Hello!', chatId: 123456789);

// to a user (direct message)
$message = $client->messages->send(text: 'Hello!', userId: 987654321);

// with Markdown formatting
$message = $client->messages->send(
    text:   '**Bold** and _italic_',
    chatId: 123456789,
    format: 'markdown',
);
```

**Get messages**

```
$messages = $client->messages->list(chatId: 123456789, count: 20);

$message = $client->messages->get('message-id');
```

**Edit and delete**

```
$client->messages->edit(messageId: 'message-id', text: 'Updated text');

$client->messages->delete('message-id');
```

**Answer a callback (inline button)**

```
$client->messages->answerCallback(
    callbackId:   $update->payload['callback']['callback_id'],
    notification: 'Button pressed!',
);
```

---

### Chats

[](#chats)

```
$chats = $client->chats->list(count: 50);

$chat  = $client->chats->get(chatId: 123456789);

$client->chats->update(chatId: 123456789, title: 'New title');

$client->chats->sendAction(chatId: 123456789, action: 'typing_on');

$client->chats->pinMessage(chatId: 123456789, messageId: 'message-id');
$client->chats->unpinMessage(chatId: 123456789);

$client->chats->delete(chatId: 123456789);
```

Available sender actions: `typing_on`, `sending_photo`, `sending_video`, `sending_audio`, `sending_file`, `mark_seen`.

---

### Chat members

[](#chat-members)

```
$members = $client->chatMembers->list(chatId: 123456789);
$admins  = $client->chatMembers->listAdmins(chatId: 123456789);

$client->chatMembers->add(chatId: 123456789, userIds: [111, 222]);
$client->chatMembers->remove(chatId: 123456789, userId: 111);
$client->chatMembers->remove(chatId: 123456789, userId: 111, block: true);

$client->chatMembers->addAdmin(chatId: 123456789, userId: 111);
$client->chatMembers->removeAdmin(chatId: 123456789, userId: 111);

$me = $client->chatMembers->getMe(chatId: 123456789);
$client->chatMembers->leaveChat(chatId: 123456789);
```

---

### Subscriptions (webhooks)

[](#subscriptions-webhooks)

```
// Subscribe
$client->subscriptions->subscribe(
    url:         'https://example.com/webhook',
    updateTypes: ['message_created', 'bot_started'],
    secret:      'my-secret',
);

// List active subscriptions
$subscriptions = $client->subscriptions->list();

// Unsubscribe
$client->subscriptions->unsubscribe();
```

**Long polling** (development only):

```
$updates = $client->subscriptions->getUpdates(limit: 10, timeout: 30);

foreach ($updates as $update) {
    echo $update->updateType . PHP_EOL;
    // $update->payload contains all event-specific fields
}
```

---

### Uploads

[](#uploads)

**Send an image**

```
use MaxBotApi\Resources\Uploads;

$token = $client->uploads->uploadFile('/path/to/photo.jpg', Uploads::TYPE_IMAGE);

$client->messages->send(
    text:        'Here is your image!',
    chatId:      123456789,
    attachments: [
        ['type' => 'image', 'payload' => ['token' => $token]],
    ],
);
```

**Send a file (PDF, ZIP, DOCX, …)**

```
$token = $client->uploads->uploadFile('/path/to/document.pdf', Uploads::TYPE_FILE);

$client->messages->send(
    text:        'Here is the document.',
    chatId:      123456789,
    attachments: [
        ['type' => 'file', 'payload' => ['token' => $token]],
    ],
);
```

**Send a video or audio**

For video and audio, the server processes the file asynchronously. If you send the message too quickly you will receive an `attachment.not.ready` error — use exponential back-off:

```
$token = $client->uploads->uploadFile('/path/to/movie.mp4', Uploads::TYPE_VIDEO);

$delay    = 2;
$maxTries = 5;

for ($attempt = 1; $attempt messages->send(
            text:        'Check out this video!',
            chatId:      123456789,
            attachments: [
                ['type' => 'video', 'payload' => ['token' => $token]],
            ],
        );
        break;
    } catch (\MaxBotApi\Exceptions\ApiException $e) {
        if ($e->getMessage() === 'attachment.not.ready' && $attempt < $maxTries) {
            sleep($delay);
            $delay *= 2;
        } else {
            throw $e;
        }
    }
}
```

**Send multiple images at once**

```
$attachments = [];
foreach (['/path/photo1.jpg', '/path/photo2.jpg'] as $path) {
    $token         = $client->uploads->uploadFile($path, Uploads::TYPE_IMAGE);
    $attachments[] = ['type' => 'image', 'payload' => ['token' => $token]];
}

$client->messages->send(text: 'Here are the photos!', chatId: 123456789, attachments: $attachments);
```

**Low-level: get the upload URL only**

```
$result = $client->uploads->getUploadUrl(Uploads::TYPE_IMAGE);
// $result->url   — upload the file here with your own HTTP client
// $result->token — for video/audio: use this as the attachment token
```

Available types: `Uploads::TYPE_IMAGE`, `TYPE_VIDEO`, `TYPE_AUDIO`, `TYPE_FILE`.

---

Webhooks
--------

[](#webhooks)

```
use MaxBotApi\Webhook;

$data   = Webhook::parse();
$update = \MaxBotApi\DTO\Update::fromArray($data);

switch ($update->updateType) {
    case 'message_created':
        $message = $update->payload['message'];
        break;

    case 'bot_started':
        $user = $update->payload['user'];
        break;

    case 'message_callback':
        $callback = $update->payload['callback'];
        break;
}
```

Supported update types: `message_created`, `message_callback`, `message_edited`, `message_removed`, `bot_started`, `bot_stopped`, `bot_added`, `bot_removed`, `user_added`, `user_removed`, `chat_title_changed`, `message_chat_created`, `message_construction_request`, `message_constructed`.

---

Error handling
--------------

[](#error-handling)

```
use MaxBotApi\Exceptions\RateLimitException;
use MaxBotApi\Exceptions\ApiException;
use MaxBotApi\Exceptions\NetworkException;

try {
    $client->messages->send(text: 'Hello!', chatId: 123456789);

} catch (RateLimitException $e) {
    // HTTP 429 — retry after the specified delay
    sleep($e->retryAfter ?? 60);

} catch (ApiException $e) {
    // HTTP 4xx / 5xx — API returned an error
    echo $e->getMessage();
    echo $e->getCode(); // HTTP status code

} catch (NetworkException $e) {
    // Connection failure, timeout, DNS error
    echo $e->getMessage();
}
```

Exception hierarchy:

```
\RuntimeException
├── MaxBotApi\Exceptions\ApiException        — HTTP 4xx / 5xx
│   └── MaxBotApi\Exceptions\RateLimitException  — HTTP 429, has $retryAfter
└── MaxBotApi\Exceptions\NetworkException    — network-level errors

```

---

License
-------

[](#license)

MIT

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance83

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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 ~9 days

Total

6

Last Release

86d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/afb5b1ee820ff47f1e77906d1424c21ed6d58369a706b965a7f2558c13bcb6d4?d=identicon)[prog-time](/maintainers/prog-time)

---

Top Contributors

[![prog-time](https://avatars.githubusercontent.com/u/40496434?v=4)](https://github.com/prog-time "prog-time (36 commits)")

---

Tags

maxphpsdkapisdkbotMessengermaxmax-bot

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/prog-time-max-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/prog-time-max-php-sdk/health.svg)](https://phpackages.com/packages/prog-time-max-php-sdk)
```

###  Alternatives

[bushlanov-dev/max-bot-api-client-php

Max Bot API Client library

486.3k](/packages/bushlanov-dev-max-bot-api-client-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[nutgram/nutgram

The Telegram bot library that doesn't drive you nuts

737290.3k8](/packages/nutgram-nutgram)[keboola/storage-api-client

Keboola Storage API PHP Client

10405.9k39](/packages/keboola-storage-api-client)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

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