@mani-sh-reddy/ts-telegram-bot-type-definitions
v1.0.0
Published
Complete TypeScript type definitions for Telegram Bot API 9.2
Maintainers
Readme
@mani-sh-reddy/ts-telegram-bot-type-definitions
Complete, production-ready TypeScript type definitions for the Telegram Bot API 9.2.
Features
✅ 200+ complete type definitions - All core types from Telegram Bot API 9.2
✅ Well-organized - Grouped into logical sections (Messages, Media, Users/Chats, Keyboards, etc.)
✅ Type-safe discriminated unions - MessageOrigin, ChatMember, BackgroundType, etc.
✅ Zero dependencies - Pure TypeScript types, no runtime code
✅ Full inline documentation - JSDoc comments throughout
✅ All new features - Business accounts, paid media, gifts, boosts, stories, and more
Installation
npm install @mani-sh-reddy/ts-telegram-bot-type-definitionsQuick Start
import {
Update,
Message,
User,
Chat,
CallbackQuery
} from '@mani-sh-reddy/ts-telegram-bot-type-definitions';
function handleUpdate(update: Update) {
if (update.message) {
const msg: Message = update.message;
const sender: User | undefined = msg.from;
const chat: Chat = msg.chat;
const text: string | undefined = msg.text;
console.log(`Message from ${sender?.first_name}: ${text}`);
}
if (update.callback_query) {
const query: CallbackQuery = update.callback_query;
const data: string | undefined = query.data;
}
}Type Categories
Core Types
Update- Incoming update from TelegramUser- Telegram userChat- Chat (private, group, supergroup, channel)Message- Message in chatWebhookInfo- Webhook status
Message Content
MessageEntity- Special entities (mention, hashtag, URL, etc.)TextQuote- Quoted message partsExternalReplyInfo- Replies from other chatsReplyParameters- Reply message references
Media Types
PhotoSize,Animation,Audio,DocumentVideo,VideoNote,VoiceSticker,GameContact,Location,VenuePaidMediaInfo- Paid media contentPoll,Checklist- Polls and checklists
User & Chat
ChatMember- Chat membership status (creator, admin, member, restricted, left, kicked)ChatMemberUpdated- Changes to membershipChatPermissions- Default permissionsChatLocation- Chat locationChatPhoto,Birthdate,BusinessIntro,BusinessLocation
Reactions & Messages
ReactionType- Emoji, custom emoji, or paid reactionsMessageReactionUpdated- Reaction changesChatBoost- Chat boost informationGift,UniqueGift- Gift objects
Keyboard & Buttons
ReplyKeyboardMarkup,ReplyKeyboardRemoveInlineKeyboardMarkup,InlineKeyboardButtonKeyboardButtonwith request optionsLoginUrl,WebAppInfo
Inline Queries
InlineQuery- Inline queryChosenInlineResult- Selected inline resultInlineQueryResult- 20+ different result typesInputMessageContent- Input message variations
Payments
Invoice,ShippingOption,LabeledPriceSuccessfulPayment,RefundedPaymentShippingQuery,PreCheckoutQuery
Business Features
BusinessConnection,BusinessMessagesDeletedSuggestedPostInfo,SuggestedPostApproved/Declined/PaidDirectMessagePriceChanged
Callback & Commands
CallbackQuery- Callback button pressedBotCommand,BotCommandScopeMenuButton
Misc
PassportData- Telegram Passport dataStarTransaction,StarTransactions- Telegram Star paymentsTransactionPartner- Payment sources/recipients
API Response Wrapper
All API responses can be typed with:
import { TelegramApiResponse } from '@mani-sh-reddy/ts-telegram-bot-type-definitions';
const response: TelegramApiResponse<{ ok: boolean }> = {
ok: true,
result: { ok: true }
};
if (response.ok && response.result) {
// Use result safely
}Version History
1.0.0 (Current)
- Initial release with full Telegram Bot API 9.2 support
- 200+ type definitions
- All core features included
Contributing
Found a bug or want to add more types? Contributions are welcome!
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
MIT - See LICENSE file for details
Support
For issues or questions:
- GitHub Issues: ts-telegram-bot-type-definitions/issues
- Check Telegram Bot API Docs
