{"id":20945112,"url":"https://github.com/vjik/telegram-bot-api","last_synced_at":"2025-04-06T09:06:00.682Z","repository":{"id":241867304,"uuid":"807799569","full_name":"vjik/telegram-bot-api","owner":"vjik","description":"PHP library to interact with Telegram Bot API","archived":false,"fork":false,"pushed_at":"2025-03-23T14:55:03.000Z","size":1137,"stargazers_count":60,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T09:51:38.648Z","etag":null,"topics":["telegam-bot-api","telegram","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vjik.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-29T19:49:46.000Z","updated_at":"2025-03-22T19:25:03.000Z","dependencies_parsed_at":"2024-07-23T11:04:17.177Z","dependency_job_id":"ed734477-499c-4d46-9b17-5ea0d0591695","html_url":"https://github.com/vjik/telegram-bot-api","commit_stats":null,"previous_names":["vjik/php-telegram-bot-api"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vjik%2Ftelegram-bot-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vjik%2Ftelegram-bot-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vjik%2Ftelegram-bot-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vjik%2Ftelegram-bot-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vjik","download_url":"https://codeload.github.com/vjik/telegram-bot-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457799,"owners_count":20941906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["telegam-bot-api","telegram","telegram-bot"],"created_at":"2024-11-18T23:46:41.524Z","updated_at":"2025-04-06T09:06:00.657Z","avatar_url":"https://github.com/vjik.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegram Bot API for PHP\n\n[![Latest Stable Version](https://poser.pugx.org/vjik/telegram-bot-api/v)](https://packagist.org/packages/vjik/telegram-bot-api)\n[![Total Downloads](https://poser.pugx.org/vjik/telegram-bot-api/downloads)](https://packagist.org/packages/vjik/telegram-bot-api)\n[![Build status](https://github.com/vjik/telegram-bot-api/actions/workflows/build.yml/badge.svg)](https://github.com/vjik/telegram-bot-api/actions/workflows/build.yml)\n[![Coverage Status](https://coveralls.io/repos/github/vjik/telegram-bot-api/badge.svg)](https://coveralls.io/github/vjik/telegram-bot-api)\n[![Mutation score](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fvjik%2Ftelegram-bot-api%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/vjik/telegram-bot-api/master)\n[![Static analysis](https://github.com/vjik/telegram-bot-api/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/vjik/telegram-bot-api/actions/workflows/static.yml?query=branch%3Amaster)\n\nThe package provides a simple and convenient way to interact with the Telegram Bot API.\n\n✔️ Telegram Bot API 8.3 (February 12, 2025) is **fully supported**.\n\n## Requirements\n\n- PHP 8.2 or higher.\n\n## Installation\n\nThe package can be installed with [Composer](https://getcomposer.org/download/):\n\n```shell\ncomposer require vjik/telegram-bot-api\n```\n\n## General usage\n\nTo make requests to the Telegram Bot API, you need to create an instance of the `TelegramBotApi` class.\n\n```php\nuse Vjik\\TelegramBot\\Api\\TelegramBotApi;\n\n// API\n$api = new TelegramBotApi(\n    // Telegram bot authentication token\n    '110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw',\n);\n```\n\nNow you can use the `$api` instance to interact with the Telegram Bot API. Method names are the same as in \nthe [Telegram Bot API documentation](https://core.telegram.org/bots/api). For example:\n\n```php\nuse Vjik\\TelegramBot\\Api\\Type\\InputFile\n\n// Specify a URL for outgoing webhook\n$api-\u003esetWebhook('https://example.com/webhook');\n\n// Send text message\n$api-\u003esendMessage(\n    chatId: 22351, \n    text: 'Hello, world!',\n);\n\n// Send local photo\n$api-\u003esendPhoto(\n    chatId: 22351, \n    photo: InputFile::fromLocalFile('/path/to/photo.jpg'),\n);\n```\n\nThe result will be either a `FailResult` instance (occurring on an error) or an object of the corresponding type \n(occurring on success). For example:\n\n```php\n// Result is an array of `Vjik\\TelegramBot\\Api\\Update\\Update` objects\n$updates = $api-\u003egetUpdates();\n```\n\n## Documentation\n\n### `TelegramBotApi`\n\n`TelegramBotApi` constructor parameters:\n\n- `$token` (required) — Telegram bot authentication token;\n- `$baseUrl` — the base URL for Telegram Bot API requests (default `https://api.telegram.org`).\n- `$transport` — the [transport](docs/transport.md) to make requests to Telegram Bot API (cURL will be used by default).\n- `$logger` — the [PSR-3](https://www.php-fig.org/psr/psr-3/) compatible logger to log requests to Telegram Bot API and\n  response handling errors. See [logging](docs/logging.md) for more information.\n\nMethod names are the same as in the [Telegram Bot API documentation](https://core.telegram.org/bots/api).\n\n### Files\n\n#### File URL\n\nUse `TelegramBotApi::makeFileUrl()` method to make a URL for downloading a file from the Telegram server. For example:\n\n```php\n/**\n * @var \\Vjik\\TelegramBot\\Api\\TelegramBotApi $api\n * @var \\Vjik\\TelegramBot\\Api\\Type\\File $file \n */\n \n// By `File` instance\n$url = $api-\u003emakeFileUrl($file);\n\n// By file path is taken from the Telegram response\n$url = $api-\u003emakeFileUrl('photos/file_2');\n```\n\n#### File downloading\n\nUse `TelegramBotApi::downloadFile()` and `TelegramBotApi::downloadFileTo()` methods to download a file from the Telegram\nserver. For example:\n\n```php\n/**\n * @var \\Vjik\\TelegramBot\\Api\\TelegramBotApi $api\n * @var \\Vjik\\TelegramBot\\Api\\Type\\File $file\n */\n \n// Get file content by `File` instance\n$fileContent = $api-\u003edownloadFile($file);\n\n// Get file content by file path\n$fileContent = $api-\u003edownloadFile('photos/file_2');\n\n// Download and save file by `File` instance\n$fileContent = $api-\u003edownloadFileTo($file, '/local/path/to/file.jpg');\n\n// Download and save file by file path\n$fileContent = $api-\u003edownloadFileTo('photos/file_2', '/local/path/to/file.jpg');\n```\n\n### Guides\n\n- [Transport](docs/transport.md)\n- [Logging](docs/logging.md)\n- [Webhook handling](docs/webhook-handling.md)\n- [Custom requests](docs/custom-requests.md)\n- [Internals](docs/internals.md)\n\nIf you have any questions or problems with this package, use [author telegram chat](https://t.me/predvoditelev_chat) for communication.\n\n## License\n\nThe `vjik/telegram-bot-api` is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\n## Credits\n\nThe package is inspired by [Botasis](https://github.com/botasis) code originally created \nby [Viktor Babanov](https://github.com/viktorprogger).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvjik%2Ftelegram-bot-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvjik%2Ftelegram-bot-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvjik%2Ftelegram-bot-api/lists"}