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.
BackgroundFillFreeformGradient
Represents a background fill where the background is a freeform gradient that rotates after every message in the chat.
BackgroundFillGradient
Represents a background fill where the background is a gradient fill.
BackgroundFillSolid
Represents a background fill where the background is filled using the selected color.
BackgroundType
This object describes the type of a background.
BackgroundTypeChatTheme
Represents a background type where the background is taken directly from a built-in chat theme.
BackgroundTypeFill
Represents a background type where the background is automatically filled based on selected colors.
BackgroundTypePattern
Represents a background type where the background is a pattern combined with a background fill.
BackgroundTypeWallpaper
Represents a background type where the background is a wallpaper in JPEG format.
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.
BotCommandScopeAllChatAdministrators
Represents the scope of bot commands, covering all group and supergroup chat administrators.
BotCommandScopeAllGroupChats
Represents the scope of bot commands, covering all group and supergroup chats.
BotCommandScopeChat
Represents the scope of bot commands, covering a specific chat.
BotCommandScopeChatAdministrators
Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
BotCommandScopeChatMember
Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
BotCommandScopeDefault
Represents the scope of bot commands, covering all private chats.
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
ChatBoostSourceGiftCode
The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each such code boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription.
ChatBoostSourceGiveaway
The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription.
ChatBoostSourcePremium
The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscription to another user.
ChatBoostUpdated
This object represents a boost added to a chat or changed.
ChatFullInfo
This object represents a chat.
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.
ChatMemberAdministrator
Represents a chat member that owns the chat and has all administrator privileges.
ChatMemberBanned
Represents a ChatMember that was banned in the chat and can't return to the chat or view chat messages.
ChatMemberLeft
Represents a chat member that isn't currently a member of the chat, but may join it themselves.
ChatMemberMember
Represents a chat member that has no additional privileges or restrictions.
ChatMemberOwner
Represents a chat member that owns the chat and has all administrator privileges.
ChatMemberRestricted
Represents a chat member that is under certain restrictions in the chat. Supergroups only.
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
ForceReply
Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
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.
InlineKeyboardMarkup
This object represents an inline keyboard that appears right next to the message it belongs to.
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.
InputContactMessageContent
Represents the content of a contact message to be sent as the result of an inline query.
InputInvoiceMessageContent
Represents the content of an invoice message to be sent as the result of an inline query.
InputLocationMessageContent
Represents the content of a location message to be sent as the result of an inline query.
InputMedia
This object represents the content of a media message to be sent. It should be one of
InputMediaAnimation
Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.
InputMediaAudio
Represents an audio file to be treated as music to be sent.
InputMediaDocument
Represents a general file to be sent.
InputMediaPhoto
Represents a photo to be sent.
InputMediaVideo
Represents a video to be sent.
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:
InputPaidMedia
This object describes the paid media to be sent. Currently, it can be one of InputPaidMediaPhoto or InputPaidMediaVideo.
InputPaidMediaPhoto
The paid media to send is a photo.
InputPaidMediaVideo
The paid media to send is a video.
InputPollOption
Represents an input poll option.
InputSticker
This object describes a sticker to be added to a sticker set.
InputTextMessageContent
Represents the content of a text message to be sent as the result of an inline query.
InputVenueMessageContent
Represents the content of a venue message to be sent as the result of an inline query.
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 or MenuButtonWebApp or MenuButtonDefault.
Represents a menu button, which opens the bot's list of commands.
Describes that no specific value for the menu button was set.
Represents a menu button, which launches a Web App.
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
MessageOriginChannel
This object represents a message that was originally sent to a channel chat.
MessageOriginChat
This object represents a message that was originally sent on behalf of a chat to a group chat.
MessageOriginHiddenUser
This object represents a message that was originally sent by an unknown user.
MessageOriginUser
This object represents a message that was originally sent by a known user.
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. Currently, it can be one of PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo.
PaidMediaInfo
Describes the paid media added to a message.
PaidMediaPhoto
The paid media is a photo.
PaidMediaPreview
The paid media isn't available before the payment.
PaidMediaPurchased
Represents a paid media purchase made by a user.
PaidMediaVideo
The paid media is a video.
PassportData
Describes Telegram Passport data shared with the bot by the user.
PassportElementError
This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user.
PassportElementErrorDataField
Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes.
PassportElementErrorFile
Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes.
PassportElementErrorFiles
Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes.
PassportElementErrorFrontSide
Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes.
PassportElementErrorReverseSide
Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes.
PassportElementErrorSelfie
Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes.
PassportElementErrorTranslationFile
Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes.
PassportElementErrorTranslationFiles
Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change.
PassportElementErrorUnspecified
Represents an issue in an unspecified place. The error is considered resolved when new data is added.
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. Currently, it can be one of
ReactionTypeCustomEmoji
The reaction is based on a custom emoji.
ReactionTypeEmoji
The reaction is based on an emoji.
ReactionTypePaid
The reaction is paid.
RefundedPayment
This object contains basic information about a refunded payment.
ReplyKeyboardMarkup
This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
ReplyKeyboardRemove
Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup).
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. Currently, it can be one of RevenueWithdrawalStatePending, RevenueWithdrawalStateSucceeded, RevenueWithdrawalStateFailed.
RevenueWithdrawalStateFailed
The withdrawal failed and the transaction was refunded.
RevenueWithdrawalStatePending
The withdrawal is in progress.
RevenueWithdrawalStateSucceeded
The withdrawal succeeded.
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. Currently, it can be one of TransactionPartnerFragment, TransactionPartnerUser, TransactionPartnerOther.
TransactionPartnerAffiliateProgram
Describes the affiliate program that issued the affiliate commission received via this transaction.
TransactionPartnerFragment
Describes a withdrawal transaction with Fragment.
TransactionPartnerOther
Describes a transaction with an unknown source or recipient.
TransactionPartnerTelegramAds
Describes a withdrawal transaction to the Telegram Ads platform.
TransactionPartnerTelegramApi
Describes a transaction with payment for paid broadcasting via Telegram API.
TransactionPartnerUser
Describes a transaction with a user.
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.