{"id":15033617,"url":"https://github.com/telegrambot/api","last_synced_at":"2025-04-08T23:19:13.798Z","repository":{"id":1016266,"uuid":"38112540","full_name":"TelegramBot/Api","owner":"TelegramBot","description":"Native PHP Wrapper for Telegram BOT API","archived":false,"fork":false,"pushed_at":"2024-08-29T14:23:33.000Z","size":866,"stargazers_count":1088,"open_issues_count":52,"forks_count":325,"subscribers_count":51,"default_branch":"master","last_synced_at":"2024-10-29T15:35:17.676Z","etag":null,"topics":["api-wrapper","bot-api","sdk","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TelegramBot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2015-06-26T13:26:04.000Z","updated_at":"2024-10-29T08:08:51.000Z","dependencies_parsed_at":"2023-07-05T15:16:48.683Z","dependency_job_id":"9c90851c-26c2-41be-83f8-57ec9e398ba4","html_url":"https://github.com/TelegramBot/Api","commit_stats":{"total_commits":481,"total_committers":48,"mean_commits":"10.020833333333334","dds":"0.33887733887733884","last_synced_commit":"fcc024143015fbb522ae602f307cdd562833befb"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelegramBot%2FApi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelegramBot%2FApi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelegramBot%2FApi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelegramBot%2FApi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TelegramBot","download_url":"https://codeload.github.com/TelegramBot/Api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247941824,"owners_count":21022062,"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":["api-wrapper","bot-api","sdk","telegram-bot"],"created_at":"2024-09-24T20:21:59.677Z","updated_at":"2025-04-08T23:19:13.779Z","avatar_url":"https://github.com/TelegramBot.png","language":"PHP","readme":"# PHP Telegram Bot Api\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/telegram-bot/api.svg?style=flat-square)](https://packagist.org/packages/telegram-bot/api)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Total Downloads](https://img.shields.io/packagist/dt/telegram-bot/api.svg?style=flat-square)](https://packagist.org/packages/telegram-bot/api)\n\nAn extended native php wrapper for [Telegram Bot API](https://core.telegram.org/bots/api) without requirements. Supports all methods and types of responses.\n\n## Bots: An introduction for developers\n\u003eBots are special Telegram accounts designed to handle messages automatically. Users can interact with bots by sending them command messages in private or group chats.\n\n\u003eYou control your bots using HTTPS requests to [bot API](https://core.telegram.org/bots/api).\n\n\u003eThe Bot API is an HTTP-based interface created for developers keen on building bots for Telegram.\nTo learn how to create and set up a bot, please consult [Introduction to Bots](https://core.telegram.org/bots) and [Bot FAQ](https://core.telegram.org/bots/faq).\n\n## Installation\n\nVia Composer\n\n``` bash\n$ composer require telegram-bot/api\n```\n\n## Usage\n\nSee example [DevAnswerBot](https://github.com/TelegramBot/DevAnswerBot) (russian).\n\n### API Wrapper\n#### Send message\n``` php\n$bot = new \\TelegramBot\\Api\\BotApi('YOUR_BOT_API_TOKEN');\n\n$bot-\u003esendMessage($chatId, $messageText);\n```\n#### Send document\n```php\n$bot = new \\TelegramBot\\Api\\BotApi('YOUR_BOT_API_TOKEN');\n\n$document = new \\CURLFile('document.txt');\n\n$bot-\u003esendDocument($chatId, $document);\n```\n#### Send message with reply keyboard\n```php\n$bot = new \\TelegramBot\\Api\\BotApi('YOUR_BOT_API_TOKEN');\n\n$keyboard = new \\TelegramBot\\Api\\Types\\ReplyKeyboardMarkup(array(array(\"one\", \"two\", \"three\")), true); // true for one-time keyboard\n\n$bot-\u003esendMessage($chatId, $messageText, null, false, null, $keyboard);\n```\n#### Send message with inline keyboard\n```php\n$bot = new \\TelegramBot\\Api\\BotApi('YOUR_BOT_API_TOKEN');\n\n$keyboard = new \\TelegramBot\\Api\\Types\\Inline\\InlineKeyboardMarkup(\n            [\n                [\n                    ['text' =\u003e 'link', 'url' =\u003e 'https://core.telegram.org']\n                ]\n            ]\n        );\n        \n$bot-\u003esendMessage($chatId, $messageText, null, false, null, $keyboard);\n```\n#### Send media group\n```php\n$bot = new \\TelegramBot\\Api\\BotApi('YOUR_BOT_API_TOKEN');\n\n$media = new \\TelegramBot\\Api\\Types\\InputMedia\\ArrayOfInputMedia();\n$media-\u003eaddItem(new TelegramBot\\Api\\Types\\InputMedia\\InputMediaPhoto('https://avatars3.githubusercontent.com/u/9335727'));\n$media-\u003eaddItem(new TelegramBot\\Api\\Types\\InputMedia\\InputMediaPhoto('https://avatars3.githubusercontent.com/u/9335727'));\n// Same for video\n// $media-\u003eaddItem(new TelegramBot\\Api\\Types\\InputMedia\\InputMediaVideo('http://clips.vorwaerts-gmbh.de/VfE_html5.mp4'));\n$bot-\u003esendMediaGroup($chatId, $media);\n```\n\n#### Client\n\n```php\nrequire_once \"vendor/autoload.php\";\n\ntry {\n    $bot = new \\TelegramBot\\Api\\Client('YOUR_BOT_API_TOKEN');\n\n    //Handle /ping command\n    $bot-\u003ecommand('ping', function ($message) use ($bot) {\n        $bot-\u003esendMessage($message-\u003egetChat()-\u003egetId(), 'pong!');\n    });\n    \n    //Handle text messages\n    $bot-\u003eon(function (\\TelegramBot\\Api\\Types\\Update $update) use ($bot) {\n        $message = $update-\u003egetMessage();\n        $id = $message-\u003egetChat()-\u003egetId();\n        $bot-\u003esendMessage($id, 'Your message: ' . $message-\u003egetText());\n    }, function () {\n        return true;\n    });\n    \n    $bot-\u003erun();\n\n} catch (\\TelegramBot\\Api\\Exception $e) {\n    $e-\u003egetMessage();\n}\n```\n\n#### Local Bot API Server\n\nFor using custom [local bot API server](https://core.telegram.org/bots/api#using-a-local-bot-api-server)\n\n```php\nuse TelegramBot\\Api\\Client;\n$token = 'YOUR_BOT_API_TOKEN';\n$bot = new Client($token, null, null, 'http://localhost:8081');\n```\n\n#### Third-party Http Client\n\n```php\nuse Symfony\\Component\\HttpClient\\HttpClient;\nuse TelegramBot\\Api\\BotApi;\nuse TelegramBot\\Api\\Http\\SymfonyHttpClient;\n$token = 'YOUR_BOT_API_TOKEN';\n$bot = new Client($token, null, new SymfonyHttpClient(HttpClient::create()););\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email mail@igusev.ru instead of using the issue tracker.\n\n## Credits\n\n- [Ilya Gusev](https://github.com/iGusev)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelegrambot%2Fapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelegrambot%2Fapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelegrambot%2Fapi/lists"}