PHPackages                             phenogram/scraper - 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. phenogram/scraper

ActiveLibrary[API Development](/categories/api)

phenogram/scraper
=================

Utility to scrape Telegram bot API documentation page and convert it into PHP classes.

1.0.0(1y ago)081LGPL-3.0-or-laterPHPPHP &gt;=8.0

Since Sep 1Pushed 1mo agoCompare

[ Source](https://github.com/phenogram/scraper)[ Packagist](https://packagist.org/packages/phenogram/scraper)[ RSS](/packages/phenogram-scraper/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (14)Versions (2)Used By (0)

Telegram bot API Scraper
========================

[](#telegram-bot-api-scraper)

PHP bin to scrape Telegram bot API documentation page and convert it into PHP classes to use in [Phenogram low level binding](https://github.com/phenogram/bindings)

Fork motivation
---------------

[](#fork-motivation)

### Promoted properties

[](#promoted-properties)

The main reason is I like PHP 8 promoted properties, so in this repo the stubs are generated like that.

old:

```
class BotCommand implements TypeInterface
{
    /** @var string Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores. */
    public string $command;

    /** @var string Description of the command; 1-256 characters. */
    public string $description;
}
```

new:

```
/**
 * This object represents a bot command.
 */
class BotCommand implements TypeInterface
{
    /**
     * @param string $command     Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.
     * @param string $description description of the command; 1-256 characters
     */
    public function __construct(
        public string $command,
        public string $description,
    ) {
    }
}
```

### Change API type from Trait with abstract methods to a class utilizing the new Client interface

[](#change-api-type-from-trait-with-abstract-methods-to-a-class-utilizing-the-new-client-interface)

Traits are good, but I just don't think it's appropriate to use it in this case. And I think my approach allows for more flexibility.

old:

```
...
Trait API
{
    abstract public function sendRequest(string $method, array $args): mixed;
...
```

new:

```
// TelegramBotApi.php
// ...
class TelegramBotApi
{
	public function __construct(
		protected TelegramBotApiClientInterface $client,
	) {
	}
```

```
// TelegramBotApiClientInterface.php
// ...
interface TelegramBotApiClientInterface
{
	function sendRequest(string $method, array $args): mixed;
}
```

### Misc.

[](#misc)

1. Changed class/file names
2. Add comments to type classes
3. Sort class params from required to optional
4. Code style

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

[](#installation)

Install the library with composer:

```
  $ composer require phenogram/scraper
```

Using from command line
-----------------------

[](#using-from-command-line)

Once installed, you can use the CLI to interact with the library.

For basic help and command list:

```
  $ vendor/bin/tgscraper help
```

### JSON

[](#json)

Extract the latest schema in a human-readable JSON:

```
  $ vendor/bin/tgscraper app:export-schema --readable botapi.json
```

Or, if you want a Postman-compatible JSON (thanks to [davtur19](https://github.com/davtur19/TuriBotGen/blob/master/postman.php)):

```
  $ vendor/bin/tgscraper app:export-schema --postman botapi_postman.json
```

### YAML

[](#yaml)

Extract the latest schema in YAML format:

```
  $ vendor/bin/tgscraper app:export-schema --yaml botapi.yaml
```

### OpenAPI

[](#openapi)

Extract the latest OpenAPI schema in JSON format:

```
  $ vendor/bin/tgscraper app:export-schema --openapi botapi_openapi.json
```

Or, if you prefer YAML:

```
  $ vendor/bin/tgscraper app:export-schema --openapi --yaml botapi_openapi.yaml
```

### Stubs

[](#stubs)

*Note: since Telegram may change the page format at any time, do **NOT** rely on the automagically generated stubs from this library, **ALWAYS** review the code!*

TGScraper can also generate class stubs that you can use in your library. A sample implementation is available in the [Sysbot Telegram module](https://github.com/Sysbot-org/Sysbot-tg).

Create stubs in the `out/` directory using `Phenogram\Telegram` as namespace prefix:

```
  $ vendor/bin/tgscraper app:create-stubs --namespace-prefix "Phenogram\Telegram" out
```

### All versions

[](#all-versions)

If you want to generate all schemas and stubs for every Bot API version, you can!

Here's an example on how to export everything to the `out/` directory, with schemas in human-readable format and using `Phenogram\Telegram` as namespace prefix for the stubs:

```
  $ vendor/bin/tgscraper app:dump-schemas -r --namespace-prefix "Phenogram\Telegram" out
```

Custom format
-------------

[](#custom-format)

If you're interested in the custom format generated by TGScraper, you can find its schema [here](docs/schema.json).

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance66

Regular maintenance activity

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.5% 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

Unknown

Total

1

Last Release

717d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/311e425711f60c09486c23252696fbe4dfa77e9b0dd5517bc89b288ac2f58655?d=identicon)[shanginn](/maintainers/shanginn)

---

Top Contributors

[![sys-001](https://avatars.githubusercontent.com/u/28715512?v=4)](https://github.com/sys-001 "sys-001 (53 commits)")[![shanginn](https://avatars.githubusercontent.com/u/3357943?v=4)](https://github.com/shanginn "shanginn (46 commits)")[![davtur19](https://avatars.githubusercontent.com/u/13476215?v=4)](https://github.com/davtur19 "davtur19 (2 commits)")

---

Tags

code-generationopenapiphpscrapertelegram

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phenogram-scraper/health.svg)

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)[laravel/framework

The Laravel Framework.

34.9k556.2M21.5k](/packages/laravel-framework)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19467.3M1.9k](/packages/drupal-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M674](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k6.0M778](/packages/sylius-sylius)

PHPackages © 2026

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