PHPackages                             nullform/tgstat-client - 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. nullform/tgstat-client

ActiveLibrary[API Development](/categories/api)

nullform/tgstat-client
======================

TGStat API client

v1.2.0(7mo ago)1114MITPHPPHP &gt;=7.2

Since Dec 6Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/nullform/tgstat-client)[ Packagist](https://packagist.org/packages/nullform/tgstat-client)[ Docs](https://github.com/nullform/tgstat-client)[ RSS](/packages/nullform-tgstat-client/feed)WikiDiscussions master Synced 1w ago

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

TGStat API client
=================

[](#tgstat-api-client)

Non official PHP client for TGStat API ().

Documentation for working with the Telegram Analytics API:

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

[](#installation)

```
composer require nullform/tgstat-client

```

You can get your personal token here:

Usage
-----

[](#usage)

### Basic

[](#basic)

```
use Nullform\TGStatClient;

$client = new TGStatClient\Client($token);
$client->sandbox(true);
$client->timeout(10);
$client->userAgent('TGStatClient');

try {
    // API request statistics
    $usage_stat = $client->callUsageStat();
} catch (\Exception $exception) {
    $error = $exception->getMessage();
}
```

### Usage statistics

[](#usage-statistics)

```
$usage_stat = $client->callUsageStat();
```

### Search for posts

[](#search-for-posts)

```
$params = new TGStatClient\Params\PostsSearchParams();

$params->q = 'Jazz | "Jazz music"'; // Extended syntax
$params->hideDeleted = 1;
$params->peerType = 'channel';
$params->extended = 1;
$params->extendedSyntax = 1;
$params->limit = 3;

$posts = $client->callPostsSearch($params);
```

### Words mentions by channels

[](#words-mentions-by-channels)

```
$params = new TGStatClient\Params\WordsMentionsByChannelsParams();

$params->q = 'Jazz music';
$params->strongSearch = 1;

$mentions = $client->callWordsMentionsByChannels($params);
```

### Last request info

[](#last-request-info)

You can allways get last request instance by `Client::lastRequest()`.

```
$request = $client->lastRequest();
```

### Last response info

[](#last-response-info)

You can allways get last response instance by `Client::lastResponse()`.

```
$status = $client->lastResponse()->status;
$http_status = $client->lastResponse()->getHttpStatus();
$is_from_cache = $client->lastResponse()->from_cache;

if ($client->lastResponse()->getError()) {
    $error = $client->lastResponse()->getError()->message;
}
```

### Caching

[](#caching)

You can cache API responses if you use PSR-6 or PSR-16 caching in your project. Just pass to `Client::caching()` your cache repository instance, TTL and prefix.

If the cache instance is passed, each successful response will be stored to the cache for the `$ttl` seconds. With repeated requests with the same parameters, the response will be taken from the cache.

```
// Set PSR-6 or PSR-16 cache instance, TTL (60) and cache keys prefix (tgstat_client_)
$client->caching($cache, 60, 'tgstat_client_');
```

### Logging

[](#logging)

You can log your API calls by passing your own function to `Client::logFunction()`. Passed function will be called on every TGStat API call. The function takes an instance of `\Nullform\TGStatClient\Client` as a parameter. For example:

```
$log_func = function (TGStatClient\Client $client) {
    file_put_contents('tgstat-client-log.log', print_r($client->lastResponse(), true));
};

$client = new TGStatClient\Client($token);
$client->logFunction($log_func);

$stat = $client->callUsageStat();
```

Or you can just override the `Client::log()` method that is called on every TGStat API call.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance65

Regular maintenance activity

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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

Recently: every ~338 days

Total

19

Last Release

210d ago

Major Versions

v0.3.4 → v1.0.02023-08-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/04a9894c87cf7ea2b58fc41be2ebbb1a999e1906d209e146b0fc2fd9dd9b7b2e?d=identicon)[nullform](/maintainers/nullform)

---

Top Contributors

[![nullform](https://avatars.githubusercontent.com/u/4964609?v=4)](https://github.com/nullform "nullform (25 commits)")

---

Tags

apiclienttgstattgstat.ru

### Embed Badge

![Health badge](/badges/nullform-tgstat-client/health.svg)

```
[![Health](https://phpackages.com/badges/nullform-tgstat-client/health.svg)](https://phpackages.com/packages/nullform-tgstat-client)
```

###  Alternatives

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69333.0M114](/packages/algolia-algoliasearch-client-php)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)

PHPackages © 2026

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