PHPackages                             021/telegram-validation - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. 021/telegram-validation

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

021/telegram-validation
=======================

A library for validating Telegram callbacks

v5.0.1(2y ago)0265[1 PRs](https://github.com/021-projects/telegram-validation/pulls)MITPHPPHP ^8.1|^8.2|^8.3

Since Mar 31Pushed 2y agoCompare

[ Source](https://github.com/021-projects/telegram-validation)[ Packagist](https://packagist.org/packages/021/telegram-validation)[ Docs](https://github.com/021-projects/telegram-validation)[ Patreon](https://www.patreon.com/user?u=99188087)[ RSS](/packages/021-telegram-validation/feed)WikiDiscussions 5.x Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

021/telegram-validation
=======================

[](#021telegram-validation)

[![Testing Status](https://github.com/021-projects/telegram-validation/workflows/PHP%20CI/badge.svg)](https://github.com/021-projects/telegram-validation/actions)[![Minimum PHP Version](https://camo.githubusercontent.com/5ba31c24b770cbb27a0781a735ee3eaf7d3b5fc9167916f2e611d6bc2e68b067/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f3032312f74656c656772616d2d76616c69646174696f6e2f706870)](https://packagist.org/packages/021/telegram-validation)[![Latest version](https://camo.githubusercontent.com/1784c74a64dd34c0cf636d226ff13782b145462d8a44eed16541a5d86155cf6e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f3032312f74656c656772616d2d76616c69646174696f6e)](https://packagist.org/packages/021/telegram-validation)[![License](https://camo.githubusercontent.com/6759c6e8850533b7b9cce17e984251a08185ef89853e53adb94eafa275015a46/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f3032312f74656c656772616d2d76616c69646174696f6e)](https://packagist.org/packages/021/telegram-validation)

This library helps verify callbacks from Telegram.

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

[](#installation)

Install via [Composer](https://getcomposer.org/):

```
composer require 021/telegram-validation
```

Using
-----

[](#using)

### Validation

[](#validation)

#### Web App Init Data

[](#web-app-init-data)

Mechanism: [Validating data received via the Mini App](https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app)

```
$token = 'YOUR_BOT_TOKEN';

// Short with helper function
use function Telegram\Validation\Helpers\validate_wa_init_data;

$isValid = validate_wa_init_data('query_id=...', $token);

// Expanded with class
use Telegram\Validation\WebAppInitData;

$validator = new WebAppInitData($token);
$isValid = $validator->validate('query_id=...');
```

#### Login Widget

[](#login-widget)

Mechanism: [Checking authorization](https://core.telegram.org/widgets/login#checking-authorization)

```
$token = 'YOUR_BOT_TOKEN';
$input = ['auth_date' => 666, /*...*/]; // request input

// Short with helper function
use function Telegram\Validation\Helpers\validate_login_widget;

$isValid = validate_login_widget($input, $token);

// Expanded with class
use Telegram\Validation\LoginWidget;

$validator = new LoginWidget($token);
$isValid = $validator->validate($input);
```

### Parsing

[](#parsing)

021/telegram-validation also provides classes to parse the data to objects.

#### Web App Init Data

[](#web-app-init-data-1)

```
$token = 'YOUR_BOT_TOKEN';
/**
 * @link https://core.telegram.org/bots/webapps#webappinitdata
 * @var \Telegram\Validation\Entities\WebAppInitData $webAppInitData
 */
$webAppInitData;

// Short with helper function
use function Telegram\Validation\Helpers\parse_wa_init_data;

$webAppInitData = parse_wa_init_data('query_id=...', $token);

// Expanded with class
use Telegram\Validation\WebAppInitData;

$validator = new WebAppInitData($token);
$webAppInitData = $validator->extract('query_id=...');

// Accessing fields
echo $webAppInitData->queryId; // query_id
echo $webAppInitData->chat->username; // chat.username
echo $webAppInitData->chatType; // chat_type
// ... any other fields
```

#### Login Widget

[](#login-widget-1)

```
$token = 'YOUR_BOT_TOKEN';
$input = ['auth_date' => 666, /*...*/]; // request input
/**
 * @link https://core.telegram.org/widgets/login#receiving-authorization-data
 * @var \Telegram\Validation\Entities\LoginWidgetCallback $loginWidget
 */
$loginWidget;

// Short with helper function
use function Telegram\Validation\Helpers\parse_login_widget;
$loginWidget = parse_login_widget($input, $token);

// Expanded with class
use Telegram\Validation\LoginWidget;

$validator = new LoginWidget($token);
$loginWidget = $validator->extract($input);

// Accessing fields
echo $loginWidget->firstName; // first_name
echo $loginWidget->lastName; // last_name
/** @var \Carbon\CarbonInterface $carbon */
$carbon = $loginWidget->authDate; // auth_date
```

Security
--------

[](#security)

If you discover a security vulnerability in 021/telegram-validation, please [create an issue](https://github.com/021-projects/telegram-validation/issues) with a detailed description. All security vulnerabilities will be fixed immediately. [Pull requests](https://github.com/021-projects/telegram-validation/fork) are also welcome.

Assistance
----------

[](#assistance)

We will be glad if you join the development and improvement of the project. You can [create an issue](https://github.com/021-projects/telegram-validation/issues) and/or a [pull request](https://github.com/021-projects/telegram-validation/fork).

License
-------

[](#license)

021/telegram-validation - is open source software available under the [MIT](LICENSE). See the [license file](LICENSE) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.3% 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 ~4 days

Total

4

Last Release

766d ago

Major Versions

4.x-dev → v5.0.02024-04-12

PHP version history (2 changes)4.x-devPHP ^8.2

v5.0.0PHP ^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/850e7a3d7b73d4aca00b33bfd13c33b97a8bec35d3b889d50cc0eec3b26eb337?d=identicon)[021-projects](/maintainers/021-projects)

---

Top Contributors

[![CrazyTapok-bit](https://avatars.githubusercontent.com/u/61122611?v=4)](https://github.com/CrazyTapok-bit "CrazyTapok-bit (131 commits)")[![021-projects](https://avatars.githubusercontent.com/u/20326979?v=4)](https://github.com/021-projects "021-projects (14 commits)")

---

Tags

validationauthAuthenticationauthorizationlogintelegramverificationwebapp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/021-telegram-validation/health.svg)

```
[![Health](https://phpackages.com/badges/021-telegram-validation/health.svg)](https://phpackages.com/packages/021-telegram-validation)
```

###  Alternatives

[tg/tgwebvalid

An easy way to validate Telegram Login Widget and Telegram Mini App users on your website using PHP

6821.7k1](/packages/tg-tgwebvalid)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.0M3](/packages/auth0-login)[auth0/symfony

Symfony SDK for Auth0 Authentication and Management APIs.

128738.1k](/packages/auth0-symfony)[auth0/wordpress

WordPress Plugin for Auth0

17419.5k](/packages/auth0-wordpress)[hydrat-agency/laravel-2fa

This package allow you to enable two-factor authentication in your Laravel applications. It stores tokens locally and notify users about their token via mail, SMS or any custom channel. Includes native conditionnal check to trigger or not 2FA, using known devices, IP addresses or IP locations.

1616.4k](/packages/hydrat-agency-laravel-2fa)

PHPackages © 2026

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