telegram library

Telegram Models

This library contains all the models used by the Telegram API.

Learn more about the Telegram API at https://core.telegram.org/bots/api#available-types

Classes

AffiliateInfo
Contains information about the affiliate that received a commission via this transaction.
Animation
This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
Audio
This object represents an audio file to be treated as music by the Telegram clients.
BackgroundFill
This object describes the way a background is filled based on the selected colors. Currently, it can be one of
BackgroundType
This object describes the type of a background.
Birthdate
Represents a user's birthdate.
BotCommand
This object represents a bot command.
BotCommandScope
This object represents the scope to which bot commands are applied.
BotDescription
This object represents the bot's description.
BotName
This object represents the bot's name.
BotShortDescription
This object represents the bot's short description.
BusinessConnection
Represents the connection of the bot with a business account.
BusinessIntro
Represents an introduction to a business.
BusinessLocation
Represents the location of a business.
BusinessMessagesDeleted
Represents an object received when messages are deleted from a connected business account.
BusinessOpeningHours
Represents the opening hours of a business.
BusinessOpeningHoursInterval
Represents an interval of opening hours for a business.
CallbackGame
A placeholder, currently holds no information. Use BotFather to set up your game.
CallbackQuery
This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.
Chat
This object represents a chat.
ChatAdministratorRights
Represents the rights of an administrator in a chat.
ChatBackground
This object represents a chat background.
ChatBoost
This object contains information about a chat boost.
ChatBoostAdded
This object represents a service message about a user boosting a chat.
ChatBoostRemoved
This object represents a boost removed from a chat.
ChatBoostSource
This object describes the source of a chat boost. It can be one of
ChatBoostUpdated
This object represents a boost added to a chat or changed.
ChatFullInfo
This object represents a chat with full information.
Represents an invite link for a chat.
ChatJoinRequest
Represents a join request sent to a chat.
ChatLocation
Represents a location to which a chat is connected.
ChatMember
This object contains information about one member of a chat.
ChatMemberUpdated
This object represents changes in the status of a chat member.
ChatPermissions
Describes actions that a non-administrator user is allowed to take in a chat.
ChatPhoto
This object represents a chat photo.
ChatShared
This object contains information about the chat whose identifier was shared with the bot using a KeyboardButtonRequestChat button.
ChosenInlineResult
Represents a result of an inline query that was chosen by the user and sent to their chat partner.
Contact
This object represents a phone contact.
CopyTextButton
This object represents an inline keyboard button that copies specified text to the clipboard.
Dice
This object represents an animated emoji that displays a random value.
Document
This object represents a general file (as opposed to photos, voice messages and audio files).
EncryptedCredentials
Describes data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.
EncryptedPassportElement
Describes documents or other Telegram Passport elements shared with the bot by the user.
ExternalReplyInfo
Contains information about a message that is being replied to, which may come from another chat or forum topic.
File
This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/BOT_TOKEN/FILE_PATH. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile.
ForumTopic
This object represents a forum topic.
ForumTopicClosed
This object represents a service message about a forum topic closed in the chat. Currently holds no information.
ForumTopicCreated
This object represents a service message about a new forum topic created in the chat.
ForumTopicEdited
This object represents a service message about an edited forum topic.
ForumTopicReopened
This object represents a service message about a forum topic reopened in the chat. Currently holds no information.
Game
This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.
GameHighScore
This object represents one row of the high scores table for a game.
GeneralForumTopicHidden
This object represents a service message about General forum topic hidden in the chat. Currently holds no information.
GeneralForumTopicUnhidden
This object represents a service message about General forum topic unhidden in the chat. Currently holds no information.
Gift
Represents a gift that can be sent by the bot.
Gifts
Represents a list of gifts.
Giveaway
This object represents a message about a scheduled giveaway.
GiveawayCompleted
This object represents a service message about the completion of a giveaway without public winners.
GiveawayCreated
This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.
GiveawayWinners
This object represents a message about the completion of a giveaway with public winners.
InaccessibleMessage
This object describes a message that was deleted or is otherwise inaccessible to the bot.
InlineKeyboardButton
This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
InlineQuery
This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
InlineQueryResult
This object represents one result of an inline query. Telegram clients currently support results of the following 20 types:
InlineQueryResultArticle
Represents a link to an article or web page.
InlineQueryResultAudio
Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
InlineQueryResultCachedAudio
Represents a link to an MP3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
InlineQueryResultCachedDocument
Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file.
InlineQueryResultCachedGif
Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation.
InlineQueryResultCachedMpeg4Gif
Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
InlineQueryResultCachedPhoto
Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
InlineQueryResultCachedSticker
Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker.
InlineQueryResultCachedVideo
Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
InlineQueryResultCachedVoice
Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message.
InlineQueryResultContact
Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.
InlineQueryResultDocument
Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.
InlineQueryResultGame
Represents a Game.
InlineQueryResultGif
Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
InlineQueryResultLocation
Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location.
InlineQueryResultMpeg4Gif
Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
InlineQueryResultPhoto
Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
InlineQueryResultsButton
This object represents a button to be shown above inline query results. You must use exactly one of the optional fields.
InlineQueryResultVenue
Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.
InlineQueryResultVideo
Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
InlineQueryResultVoice
Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message.
InputMedia
This object represents the content of a media message to be sent. It should be one of
InputMessageContent
This object represents the content of a message to be sent as a result of an inline query. Telegram clients currently support the following 5 types:
InputMessageContentConverter
Converts the ID to JSON
InputPaidMedia
This object describes the paid media to be sent. Currently, it can be one of InputPaidMediaPhoto or InputPaidMediaVideo.
InputPollOption
Represents an input poll option.
InputSticker
This object describes a sticker to be added to a sticker set.
Invoice
This object contains basic information about an invoice.
KeyboardButton
This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields web_app, request_contact, request_location, and request_poll are mutually exclusive.
KeyboardButtonPollType
This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed.
KeyboardButtonRequestChat
This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.
KeyboardButtonRequestUsers
This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed.
LabeledPrice
This object represents a portion of the price for goods or services.
LinkPreviewOptions
Describes the options used for link preview generation.
Location
This object represents a point on the map.
LoginURL
This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in.
MaskPosition
This object describes the position on faces where a mask should be placed by default.
MaybeInaccessibleMessage
This object describes a message that can be inaccessible to the bot. It can be one of
This object describes the bot's menu button in a private chat. It should be one of MenuButtonCommands, MenuButtonWebApp, or MenuButtonDefault.
Message
This object represents a message.
MessageAutoDeleteTimerChanged
This object represents a service message about a change in auto-delete timer settings.
MessageEntity
This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
MessageId
This object represents a unique message identifier.
MessageOrigin
This object describes the origin of a message. It can be one of
MessageReactionCountUpdated
Represents reaction changes on a message with anonymous reactions.
MessageReactionUpdated
Represents a change of a reaction on a message performed by a user.
OrderInfo
This object represents information about an order.
PaidMedia
This object describes paid media. It can be one of
PaidMediaInfo
Describes the paid media added to a message.
PaidMediaPurchased
Represents a paid media purchase made by a user.
PassportData
Describes Telegram Passport data shared with the bot by the user.
PassportElementError
This object represents an error in the Telegram Passport element. It can be one of:
PassportFile
This object represents a file uploaded to Telegram Passport. Currently, all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB.
PhotoSize
This object represents one size of a photo or a file / sticker thumbnail.
Poll
This object contains information about a poll.
PollAnswer
This object represents an answer of a user in a non-anonymous poll.
PollOption
This object contains information about one answer option in a poll.
PreCheckoutQuery
This object contains information about an incoming pre-checkout query.
PreparedInlineMessage
Describes an inline message to be sent by a user of a Mini App.
ProximityAlertTriggered
This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user.
ReactionCount
Represents a reaction added to a message along with the number of times it was added.
ReactionType
This object describes the type of a reaction. It can be one of
RefundedPayment
This object contains basic information about a refunded payment.
ReplyMarkup
Represents a ReplyMarkup that can be used to send a message with custom keyboard, instructions to hide keyboard or to force a reply from the user.
ReplyParameters
Describes reply parameters for the message that is being sent.
ResponseParameters
Describes why a request was unsuccessful.
RevenueWithdrawalState
This object describes the state of a revenue withdrawal operation. It can be one of:
SentWebAppMessage
Describes an inline message sent by a Web App on behalf of a user.
SharedUser
Represents information about a user that was shared with the bot using a KeyboardButtonRequestUser button.
ShippingAddress
This object represents a shipping address.
ShippingOption
This object represents one shipping option.
ShippingQuery
This object contains information about an incoming shipping query.
StarTransaction
This object describes a Telegram Star transaction.
StarTransactions
This object represents a list of Telegram Star transactions.
Sticker
This object represents a sticker.
StickerSet
This object represents a sticker set.
Story
This object represents a message about a forwarded story in the chat.
SuccessfulPayment
This object contains basic information about a successful payment.
SwitchInlineQueryChosenChat
This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.
TextQuote
Contains information about the quoted part of a message that is replied to by the given message.
TransactionPartner
This object describes the source of a transaction, or its recipient for outgoing transactions. It can be one of:
Update
This object represents an incoming update.
User
This object represents a Telegram user or bot.
UserChatBoosts
This object represents a list of boosts added to a chat by a user.
UserProfilePhotos
This object represent a user's profile pictures.
UsersShared
This object contains information about the users whose identifiers were shared with the bot using a KeyboardButtonRequestUsers button.
Venue
This object represents a venue.
Video
This object represents a video file.
VideoChatEnded
This object represents a service message about a video chat ended in the chat.
VideoChatParticipantsInvited
This object represents a service message about new members invited to a video chat.
VideoChatScheduled
This object represents a service message about a video chat scheduled in the chat.
VideoChatStarted
This object represents a service message about a video chat started in the chat. Currently holds no information.
VideoNote
This object represents a video message (available in Telegram apps as of v.4.0).
Voice
This object represents a voice note.
WebAppData
Describes data sent from a Web App to the bot.
WebAppInfo
Describes a Web App.
WebhookInfo
Describes the current status of a webhook.
WithChat
The base class for all the models that have a chat.
WithID
The base class for all the models that have a user.
WithUser
The base class for all the models that have a user.
WriteAccessAllowed
This object represents a service message about a user allowing a bot added to the attachment menu to write messages.

Extensions

AnimationExt on Animation
Extension on Animation
AudioExt on Audio
Extension for Audio to add durationTime getter
ChatInviteLinkExt on ChatInviteLink
Extension to provide additional functionality
ChatJoinRequestExt on ChatJoinRequest
Extension to provide additional functionality
ChatMemberUpdatedExt on ChatMemberUpdated
Extension to get DateTime from date field
MessageAutoDeleteTimerChangedDurationExt on MessageAutoDeleteTimerChanged
Extension over MessageAutoDeleteTimerChanged model
MessageExt on Message
Extension to add overrides for MaybeInaccessibleMessage interface
PassportFileExt on PassportFile
Extension on PassportFile
PollExtension on Poll
Extension methods for Poll
UpdateExt on Update
Extenson on Update
VideoChatEndedExt on VideoChatEnded
Extension over the VideoChatEnded
VideoChatScheduledExt on VideoChatScheduled
Extension for VideoChatScheduled
VideoExt on Video
Extension on Video
VideoNoteExt on VideoNote
Extension to add duration getter
VoiceDurationExt on Voice
Extensions for the Voice model.