ptgb
A complete, pure-Dart client for the Telegram Bot API. Typed methods for every endpoint, plus keyboards, media, webhooks, payments, stickers, and Telegram Business accounts — no raw JSON required.
import 'package:ptgb/ptgb.dart';
Future<void> main() async {
final bot = Bot(); // loads your token from a .env file
await for (final update in bot.poll()) {
if (update.text == '/start') {
await bot.sendMessage(update.chatId!, 'Hello from ptgb!');
}
}
}
Getting Started
Install the package, authenticate your bot, and receive your first update.
Examples
Forty runnable programs, from an echo bot to a full "god mode" bot.
API Reference
Every one of the 186 typed Bot methods, grouped by feature.
FAQ
Common questions about tokens, polling vs. webhooks, and errors.
Why ptgb
- Full API coverage — messaging, media, chat & forum administration, inline mode, payments & Telegram Stars, stickers, games, Telegram Business accounts, Stories, and Web Apps.
- Two update sources — long-polling out of the box (
Bot.poll) or your own webhook server (Bot.serveWebhook). - Typed helpers, not raw JSON for keyboards (
InlineKeyboardMarkup,ReplyKeyboardMarkup), media (InputMedia*), and permissions (ChatPermissions,ChatAdministratorRights). - Telegram Mini App support — verify a Web App’s signed
initDatawithBot.verifyWebAppInitData. - A low-level escape hatch (
Bot.call) for any Bot API method that doesn’t have a typed wrapper yet.
Install
dart pub add ptgb
- Package: ptgb on pub.dev
- Repository: psdkjoon/ptgb
- License: MIT
- Requires: Dart SDK
^3.5.0