Типы Tg API

Библиотека типов данных, с которыми работает Tg API.

Типы Tg API отражают структурную организацию типов официального API Telegram. Подробнее можно ознакомиться с Telegram Bot API.

pydantic model tg_api.tg_types.CallbackQuery[source]

Bases: BaseModel, ValidableMixin

This object represents an incoming callback query from a callback button in an inline keyboard.

See here: https://core.telegram.org/bots/api#callbackquery

field chat_instance: str | None = None

Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.

Validated by:
field data: str | None = None

Optional. Data associated with the callback button. Be aware that the message originated the query can contain no callback buttons with this data.

Validated by:
field from_: User [Required] (alias 'from')

Sender.

Validated by:
field game_short_name: str | None = None

Optional. Short name of a Game to be returned, serves as the unique identifier for the game.

Validated by:
field id: str [Required]

Unique identifier for this query.

Validated by:
field inline_message_id: str | None = None

Optional. Identifier of the message sent via the bot in inline mode, that originated the query.

Validated by:
field message: Message | None = None

Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old.

Validated by:
answer(text=None, show_alert=False, url=None, cache_time=None, raise_for_invalid_query=False)[source]

Send answer to CallbackQuery (sync).

Parameters:
  • self (CallbackQuery) – CallbackQuery which will be answered.

  • text (str | None) – Text of the notification.

  • show_alert (bool | None) – Should an alert be shown by the client instead of a notification or not.

  • url (str | None) – URL that will be opened by the user’s client.

  • cache_time (int | None) – The maximum amount of time in seconds that the result of the callback query may be cached client-side.

  • raise_for_invalid_query (bool | None) – Defines if TgHttpStatusError should be raised on the ‘query is too old or invalid’ error. By default this type of Telegram error will be ignored.

Raises:

TgHttpStatusError – Exception raised if Telegram responds with error. By default the ‘query is too old or invalid’ error will be ignored and cause no exception.

Return type:

AnswerCallbackQueryResponse

async async_answer(text=None, show_alert=False, url=None, cache_time=None, raise_for_invalid_query=False)[source]

Send answer to CallbackQuery (async).

Parameters:
  • self (CallbackQuery) – CallbackQuery which will be answered.

  • text (str | None) – Text of the notification.

  • show_alert (bool | None) – Should an alert be shown by the client instead of a notification or not.

  • url (str | None) – URL that will be opened by the user’s client.

  • cache_time (int | None) – The maximum amount of time in seconds that the result of the callback query may be cached client-side.

  • raise_for_invalid_query (bool | None) – Defines if TgHttpStatusError should be raised on the ‘query is too old or invalid’ error. By default this type of Telegram error will be ignored.

Raises:

TgHttpStatusError – Exception raised if Telegram responds with error. By default the ‘query is too old or invalid’ error will be ignored and cause no exception.

Return type:

AnswerCallbackQueryResponse

validator check_callback_query  »  all fields[source]
Parameters:

tg_request (dict) –

Return type:

dict | None

pydantic model tg_api.tg_types.Chat[source]

Bases: BaseModel, ValidableMixin

This model represents a chat.

See here: https://core.telegram.org/bots/api#chat

field active_usernames: list[str] | None = None

Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat.

field bio: str | None = None

Optional. Bio of the other party in a private chat. Returned only in getChat.

field can_set_sticker_set: bool | None = None

Optional. True, if the bot can change the group sticker set. Returned only in getChat.

field description: str | None = None

Optional. Description, for groups, supergroups and channel chats. Returned only in getChat.

field emoji_status_custom_emoji_id: str | None = None

Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat.

field first_name: str | None = None

Optional. First name of the other party in a private chat.

field has_aggressive_anti_spam_enabled: bool | None = None

Optional. True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in getChat.

field has_hidden_members: bool | None = None

Optional. True, if non-administrators can only get the list of bots and administrators in the chat. Returned only in getChat.

field has_private_forwards: bool | None = None

Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user. Returned only in getChat.

field has_protected_content: bool | None = None

Optional. True, if messages from the chat can’t be forwarded to other chats. Returned only in getChat.

field has_restricted_voice_and_video_messages: bool | None = None

Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in getChat.

field id: int [Required]

Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.

field is_forum: bool | None = None

Optional. True, if the supergroup chat is a forum (has topics enabled).

field join_by_request: bool | None = None

Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat.

field join_to_send_messages: bool | None = None

Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat.

field last_name: str | None = None

Optional. Last name of the other party in a private chat.

field linked_chat_id: int | None = None

Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa;for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat.

field message_auto_delete_time: int | None = None

Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.

field permissions: dict[str, Any] | None = None

Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.

field photo: dict[str, Any] | None = None

Optional. Chat photo. Returned only in getChat.

field pinned_message: Message | None = None

Optional. The most recent pinned message (by sending date). Returned only in getChat.

field slow_mode_delay: int | None = None

Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. Returned only in getChat.

field sticker_set_name: str | None = None

Optional. For supergroups, name of group sticker set. Returned only in getChat.

field title: str | None = None

Optional. Title, for supergroups, channels and group chats.

field type: str [Required]

Type of chat, can be either “private”, “group”, “supergroup” or “channel”.

field username: str | None = None

Optional. Username, for private chats, supergroups and channels if available.

Bases: BaseModel, ValidableMixin

Represents an invite link for a chat.

See here: https://core.telegram.org/bots/api#chatinvitelink

field creates_join_request: bool [Required]

True, if users joining the chat via the link need to be approved by chat administrators.

field creator: User [Required]

Creator of the link.

field expire_date: int | None = None

Optional. Point in time (Unix timestamp) when the link will expire or has been expired.

The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”.

field is_primary: bool [Required]

True, if the link is primary.

field is_revoked: bool [Required]

True, if the link is revoked.

field member_limit: int | None = None

Optional. The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999.

field name: str | None = None

Optional. Invite link name.

field pending_join_request_count: int | None = None

Optional. Number of pending join requests created using this link.

pydantic model tg_api.tg_types.ChatJoinRequest[source]

Bases: BaseModel, ValidableMixin

Represents a join request sent to a chat.

See here: https://core.telegram.org/bots/api#chatjoinrequest

field bio: str | None = None

Optional. Bio of the user.

field chat: Chat [Required]

Chat to which the request was sent.

field date: int [Required]

Date the request was sent in Unix time.

field from_: User [Required] (alias 'from')

User that sent the join request.

Optional. Chat invite link that was used by the user to send the join request.

field user_chat_id: int [Required]

Identifier of a private chat with the user who sent the join request. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot can use this identifier for 5 minutes to send messages until the join request is processed, assuming no other administrator contacted the user.

pydantic model tg_api.tg_types.ChatMemberAdministrator[source]

Bases: BaseModel, ValidableMixin

Represents a join request sent to a chat.

See here: https://core.telegram.org/bots/api#chatmemberadministrator

field can_be_edited: bool [Required]

True, if the bot is allowed to edit administrator privileges of that user.

field can_change_info: bool [Required]

True, if the user is allowed to change the chat title, photo and other settings.

field can_delete_messages: bool [Required]

True, if the administrator can delete messages of other users.

field can_edit_messages: bool [Required]

Optional. True, if the administrator can edit messages of other users and can pin messages; channels only.

field can_invite_users: bool [Required]

True, if the user is allowed to invite new users to the chat.

field can_manage_chat: bool [Required]

True, if the administrator can access the chat event log, boost list in channels, see channel members, report spam messages, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege.

field can_manage_topics: bool [Required]

Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only.

field can_manage_video_chats: bool [Required]

True, if the administrator can manage video chats.

field can_pin_messages: bool [Required]

Optional. True, if the user is allowed to pin messages; groups and supergroups only.

field can_post_messages: bool [Required]

Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only.

field can_promote_members: bool [Required]

True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user).

field can_restrict_members: bool [Required]

True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics.

field custom_title: bool [Required]

Optional. Custom title for this user.

field is_anonymous: bool [Required]

True, if the user’s presence in the chat is hidden.

field status: str [Required]

The member’s status in the chat, always “administrator”.

field user: User [Required]

Information about the user.

pydantic model tg_api.tg_types.ChatMemberBanned[source]

Bases: BaseModel, ValidableMixin

Represents a join request sent to a chat.

See here: https://core.telegram.org/bots/api#chatmemberbanned

field status: str [Required]

The member’s status in the chat, always “kicked”.

field until_date: int [Required]

Date when restrictions will be lifted for this user; Unix time. If 0, then the user is banned forever.

field user: User [Required]

Information about the user.

pydantic model tg_api.tg_types.ChatMemberLeft[source]

Bases: BaseModel, ValidableMixin

Represents a join request sent to a chat.

See here: https://core.telegram.org/bots/api#chatmemberleft

field status: str [Required]

The member’s status in the chat, always “left”.

field user: User [Required]

Information about the user.

pydantic model tg_api.tg_types.ChatMemberMember[source]

Bases: BaseModel, ValidableMixin

Represents a join request sent to a chat.

See here: https://core.telegram.org/bots/api#chatmembermember

field status: str [Required]

The member’s status in the chat, always “member”.

field user: User [Required]

Information about the user.

pydantic model tg_api.tg_types.ChatMemberOwner[source]

Bases: BaseModel, ValidableMixin

Represents a join request sent to a chat.

See here: https://core.telegram.org/bots/api#chatmemberowner

field custom_title: str [Required]

Optional. Custom title for this user.

field is_anonymous: bool [Required]

True, if the user’s presence in the chat is hidden.

field status: str [Required]

The member’s status in the chat, always “creator”.

field user: User [Required]

Information about the user.

pydantic model tg_api.tg_types.ChatMemberRestricted[source]

Bases: BaseModel, ValidableMixin

Represents a join request sent to a chat.

See here: https://core.telegram.org/bots/api#chatmemberrestricted

field can_add_web_page_previews: bool [Required]

True, if the user is allowed to add web page previews to their messages.

field can_change_info: bool [Required]

True, if the user is allowed to change the chat title, photo and other settings.

field can_invite_users: bool [Required]

True, if the user is allowed to invite new users to the chat.

field can_manage_topics: bool [Required]

True, if the user is allowed to create forum topics.

field can_pin_messages: bool [Required]

True, if the user is allowed to pin messages.

field can_send_audios: bool [Required]

True, if the user is allowed to send audios.

field can_send_documents: bool [Required]

True, if the user is allowed to send documents.

field can_send_messages: bool [Required]

True, if the user is allowed to send text messages, contacts, invoices, locations and venues.

field can_send_other_messages: bool [Required]

True, if the user is allowed to send animations, games, stickers and use inline bots.

field can_send_photos: bool [Required]

True, if the user is allowed to send photos.

field can_send_polls: bool [Required]

True, if the user is allowed to send polls.

field can_send_video_notes: bool [Required]

True, if the user is allowed to send video notes.

field can_send_videos: bool [Required]

True, if the user is allowed to send videos.

field can_send_voice_notes: bool [Required]

True, if the user is allowed to send voice notes.

field is_member: bool [Required]

True, if the user is a member of the chat at the moment of the request.

field status: str [Required]

The member’s status in the chat, always “restricted”.

field until_date: bool [Required]

Date when restrictions will be lifted for this user; Unix time. If 0, then the user is restricted forever.

field user: User [Required]

Information about the user.

pydantic model tg_api.tg_types.ChatMemberUpdated[source]

Bases: BaseModel, ValidableMixin

This object represents changes in the status of a chat member.

See here: https://core.telegram.org/bots/api#chatmemberupdated

field chat: Chat [Required]

Chat the user belongs to.

field date: int [Required]

Date the change was done in Unix time.

field from_: User [Required] (alias 'from')

Performer of the action, which resulted in the change.

Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.

field new_chat_member: ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned [Required]

New information about the chat member.

field old_chat_member: ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned [Required]

Previous information about the chat member.

Optional. True, if the user joined the chat via a chat folder invite link.

pydantic model tg_api.tg_types.ChosenInlineResult[source]

Bases: BaseModel, ValidableMixin

Represents a result of an inline query that was chosen by the user and sent to their chat partner.

Note: It is necessary to enable inline feedback via @BotFather in order to receive these objects in updates. See here: https://core.telegram.org/bots/api#choseninlineresult

field from_: User [Required] (alias 'from')

The user that chose the result.

field inline_message_id: str | None = None

Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message.

field location: Location | None = None

Optional. Sender location, only for bots that require user location.

field query: str | None = None

The query that was used to obtain the result.

field result_id: str [Required]

The unique identifier for the result that was chosen

pydantic model tg_api.tg_types.ForceReply[source]

Bases: BaseModel, ValidableMixin

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.

See here: https://core.telegram.org/bots/api#forcereply

field force_reply: bool [Required]

Shows reply interface to the user, as if they manually selected the bot’s message and tapped ‘Reply’.

field input_field_placeholder: bool | None = None

Optional. The placeholder to be shown in the input field when the reply is active; 1-64 characters.

field selective: bool | None = None

Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply (has reply_to_message_id), sender of the original message.

pydantic model tg_api.tg_types.InlineKeyboardButton[source]

Bases: BaseModel, ValidableMixin

This model represents one button of an inline keyboard.

See here: https://core.telegram.org/bots/api#inlinekeyboardbutton

field callback_data: str | None = None

Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes

field callback_game: Any | None = None

Optional. Description of the game that will be launched when the user presses the button. NOTE: This type of button must always be the first button in the first row.

field login_url: dict[str, str | bool] | None = None

Optional. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.

field pay: bool | None = None

Optional. Specify True, to send a Pay button. NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.

field switch_inline_query: str | None = None

Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot’s username and the specified inline query in the input field. May be empty, in which case just the bot’s username will be inserted.

field switch_inline_query_chosen_chat: dict[str, str | bool] | None = None

Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot’s username and the specified inline query in the input field.

field switch_inline_query_current_chat: str | None = None

Optional. If set, pressing the button will insert the bot’s username and the specified inline query in the current chat’s input field. May be empty, in which case only the bot’s username will be inserted. This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options.

field text: str [Required]

Label text on the button

field url: str | None = None

Optional. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings.

field web_app: dict[str, AnyHttpUrl] | None = None

Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot.

pydantic model tg_api.tg_types.InlineKeyboardMarkup[source]

Bases: BaseModel, ValidableMixin

This model represents an inline keyboard that appears right next to the message it belongs to.

See here: https://core.telegram.org/bots/api#inlinekeyboardmarkup

field inline_keyboard: list[list[InlineKeyboardButton]] [Required]

Array of button rows, each represented by an Array of InlineKeyboardButton objects.

pydantic model tg_api.tg_types.InlineQuery[source]

Bases: BaseModel, ValidableMixin

This object represents an incoming inline query.

When the user sends an empty query, your bot could return some default or trending results. See here: https://core.telegram.org/bots/api#inlinequery

field chat_type: str | None = None

Optional. Type of the chat from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat.

field from_: User [Required] (alias 'from')

Sender

field id: str [Required]

Unique identifier for this query

field location: Location | None = None

Optional. Sender location, only for bots that request user location.

field offset: str [Required]

Offset of the results to be returned, can be controlled by the bot.

field query: str [Required]

Text of the query (up to 256 characters).

pydantic model tg_api.tg_types.InputMediaBytesDocument[source]

Bases: BaseModel, ValidableMixin

This model represents a document with file.

See here: https://core.telegram.org/bots/api#inputmediadocument

field caption: str = None

Optional. Caption of the document to be sent, 0-1024 characters after entities parsing.

Constraints:
  • maxLength = 1024

field caption_entities: list[MessageEntity] | None = None

Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode.

field disable_content_type_detection: bool | None = None

Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always True, if the document is sent as part of an album.

field media: str [Required]

File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.

field media_content: bytes [Required]

File to send in bytes.

field parse_mode: str | None = None

Optional. Mode for parsing entities in the document caption. See formatting options for more details.

field thumbnail: str | None = None

Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

field thumbnail_content: bytes | None = None

Thumbnail of the sent file in bytes.

field type: str = 'document'

Type of the result, must be document.

pydantic model tg_api.tg_types.InputMediaBytesPhoto[source]

Bases: BaseModel, ValidableMixin

This model represents a photo with file.

See here: https://core.telegram.org/bots/api#inputmediaphoto

field caption: str = None

Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing.

Constraints:
  • maxLength = 1024

field caption_entities: list[MessageEntity] | None = None

Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode.

field has_spoiler: bool | None = None

Optional. Pass True if the photo needs to be covered with a spoiler animation.

field media: str [Required]

File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.

field media_content: bytes [Required]

File to send in bytes.

field parse_mode: str | None = None

Optional. Mode for parsing entities in the photo caption. See formatting options for more details.

field type: str = 'photo'

Type of the result, must be photo.

pydantic model tg_api.tg_types.InputMediaUrlDocument[source]

Bases: BaseModel, ValidableMixin

This model represents a document with url or file id.

See here: https://core.telegram.org/bots/api#inputmediadocument

field caption: str = None

Optional. Caption of the document to be sent, 0-1024 characters after entities parsing.

Constraints:
  • maxLength = 1024

field caption_entities: list[MessageEntity] | None = None

Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode.

field disable_content_type_detection: bool | None = None

Optional. Disables automatic server-side content type detectionfor filesuploaded using multipart/form-data. Always True, if the document is sent as part of an album.

field media: str [Required]

File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.

field parse_mode: str | None = None

Optional. Mode for parsing entities in the document caption. See formatting options for more details.

field thumbnail: str | None = None

Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.

field thumbnail_content: bytes | None = None

Thumbnail of the sent file in bytes.

field type: str = 'document'

Type of the result, must be document

pydantic model tg_api.tg_types.InputMediaUrlPhoto[source]

Bases: BaseModel, ValidableMixin

This model represents a photo with url or file id.

See here: https://core.telegram.org/bots/api#inputmediaphoto

field caption: str = None

Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing.

Constraints:
  • maxLength = 1024

field caption_entities: list[MessageEntity] | None = None

Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode.

field has_spoiler: bool | None = None

Optional. Pass True if the photo needs to be covered with a spoiler animation.

field media: str [Required]

File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.

field parse_mode: str | None = None

Optional. Mode for parsing entities in the photo caption. See formatting options for more details.

field type: str = 'photo'

Type of the result, must be photo.

pydantic model tg_api.tg_types.Invoice[source]

Bases: BaseModel, ValidableMixin

This model contains basic information about an invoice.

See here: https://core.telegram.org/bots/api#invoice

field currency: str [Required]

Three-letter ISO 4217 currency code.

field description: str [Required]

Product description

field start_parameter: str [Required]

Unique bot deep-linking parameter that can be used to generate this invoice.

field title: str [Required]

Product name.

field total_amount: int [Required]

Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

pydantic model tg_api.tg_types.KeyboardButton[source]

Bases: BaseModel, ValidableMixin

This model represents one button of the reply keyboard.

For simple text buttons, String can be used instead of this object to specify the button text. The optional fields web_app, request_user, request_chat, request_contact, request_location, and request_poll are mutually exclusive.

See here: https://core.telegram.org/bots/api#keyboardbutton

field request_chat: dict[str, int | bool | dict[str, bool]] | None = None

Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. Available in private chats only.

field request_contact: bool | None = None

Optional. If True, the user’s phone number will be sent as a contact when the button is pressed. Available in private chats only.

field request_location: bool | None = None

Optional. If True, the user’s current location will be sent when the button is pressed. Available in private chats only.

field request_poll: dict[str, str] | None = None

Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only.

field request_user: dict[str, int | bool] | None = None

Optional. If specified, pressing the button will open a list of suitable users. Tapping on any user will send their identifier to the bot in a “user_shared” service message. Available in private chats only.

field text: str [Required]

Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed.

field web_app: dict[str, AnyHttpUrl] | None = None

Optional. If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private chats only.

pydantic model tg_api.tg_types.Location[source]

Bases: BaseModel, ValidableMixin

This object represents a point on the map.

See here: https://core.telegram.org/bots/api#location

field heading: int | None = None

Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only.

field horizontal_accuracy: float | None = None

Optional. The radius of uncertainty for the location, measured in meters; 0-1500.

field latitude: float [Required]

Latitude as defined by sender.

field live_period: int | None = None

Optional. Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only.

field longitude: float [Required]

Longitude as defined by sender.

field proximity_alert_radius: int | None = None

Optional. The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only.

pydantic model tg_api.tg_types.Message[source]

Bases: BaseModel, ValidableMixin

This model represents a message.

See here: https://core.telegram.org/bots/api#message

field animation: dict[str, Any] | None = None

Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set.

field audio: dict[str, Any] | None = None

Optional. Message is an audio file, information about the file.

field author_signature: str | None = None

Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator.

field caption: str | None = None

Optional. Caption for the animation, audio, document, photo, video or voice.

field caption_entities: list[MessageEntity] | None = None

Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption.

field channel_chat_created: bool | None = None

Optional. Service message: the channel has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.

field chat: Chat [Required]

Conversation the message belongs to.

field chat_shared: dict[str, Any] | None = None

Optional. Service message: a chat was shared with the bot.

field connected_website: str | None = None

Optional. The domain name of the website on which the user has logged in.

field contact: dict[str, Any] | None = None

Optional. Message is a shared contact, information about the contact.

field date: int [Required]

Date the message was sent in Unix time.

field delete_chat_photo: bool | None = None

Optional. Service message: the chat photo was deleted.

field dice: dict[str, Any] | None = None

Optional. Message is a dice with random value.

field document: dict[str, Any] | None = None

Optional. Message is a general file, information about the file.

field edit_date: int | None = None

Optional. Date the message was last edited in Unix time.

field entities: list[MessageEntity] | None = None

Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.

field forum_topic_closed: dict[str, Any] | None = None

Optional. Service message: forum topic closed.

field forum_topic_created: dict[str, Any] | None = None

Optional. Service message: forum topic created.

field forum_topic_edited: dict[str, Any] | None = None

Optional. Service message: forum topic edited.

field forum_topic_reopened: dict[str, Any] | None = None

Optional. Service message: forum topic reopened.

field forward_date: int | None = None

Optional. For forwarded messages, date the original message was sent in Unix time.

field forward_from: User | None = None

Optional. For forwarded messages, sender of the original message.

field forward_from_chat: Chat | None = None

Optional. For messages forwarded from channels or from anonymous administrators, information about the original sender chat.

field forward_from_message_id: int | None = None

Optional. For messages forwarded from channels, identifier of the original message in the channel.

field forward_sender_name: str | None = None

Optional. Sender’s name for messages forwarded from users who disallow adding a link to their account in forwarded messages.

field forward_signature: str | None = None

Optional. For forwarded messages that were originally sent in channels or by an anonymous chat administrator, signature of the message sender if present.

field from_: User | None = None (alias 'from')

Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.

field game: dict[str, Any] | None = None

Optional. Message is a game, information about the game.

field general_forum_topic_hidden: dict[str, Any] | None = None

Optional. Service message: the ‘General’ forum topic hidden.

field general_forum_topic_unhidden: dict[str, Any] | None = None

Optional. Service message: the ‘General’ forum topic unhidden.

field group_chat_created: bool | None = None

Optional. Service message: the group has been created.

field has_media_spoiler: bool | None = None

Optional. True, if the message media is covered by a spoiler animation.

field has_protected_content: bool | None = None

Optional. True, if the message can’t be forwarded.

field invoice: Invoice | None = None

Optional. Message is an invoice for a payment, information about the invoice.

field is_automatic_forward: bool | None = None

Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group.

field is_topic_message: dict[str, Any] | None = None

Optional. True, if the message is sent to a forum topic.

field left_chat_member: User | None = None

Optional. A member was removed from the group, information about them (this member may be the bot itself).

field location: dict[str, Any] | None = None

Optional. Message is a shared location, information about the location.

field media_group_id: str | None = None

Optional. The unique identifier of a media message group this message belongs to.

field message_auto_delete_timer_changed: list[dict[str, Any]] | None = None

Optional. Service message: auto-delete timer settings changed in the chat.

field message_id: int [Required]

Unique message identifier inside this chat.

field message_thread_id: int | None = None

Optional. Unique identifier of a message thread to which the message belongs; for supergroups only.

field migrate_from_chat_id: int | None = None

Optional. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

field migrate_to_chat_id: int | None = None

Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

field new_chat_members: list[User] | None = None

Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members).

field new_chat_photo: list[dict[str, Any]] | None = None

Optional. A chat photo was change to this value.

field new_chat_title: str | None = None

Optional. A chat title was changed to this value.

field passport_data: dict[str, Any] | None = None

Optional. Telegram Passport data.

field photo: list[dict[str, Any]] | None = None

Optional. Message is a photo, available sizes of the photo.

field pinned_message: Message | None = None

Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.

field poll: dict[str, Any] | None = None

Optional. Message is a native poll, information about the poll.

field proximity_alert_triggered: dict[str, Any] | None = None

Optional. Service message. A user in the chat triggered another user’s proximity alert while sharing Live Location.

field reply_markup: InlineKeyboardMarkup | None = None

Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.

field reply_to_message: Message | None = None

Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.

field sender_chat: Chat | None = None

Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts,the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.

field sticker: dict[str, Any] | None = None

Optional. Message is a sticker, information about the sticker.

field successful_payment: SuccessfulPayment | None = None

Optional. Message is a service message about a successful payment, information about the payment.

field supergroup_chat_created: bool | None = None

Optional. Service message: the supergroup has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.

field text: str | None = None

Optional. For text messages, the actual UTF-8 text of the message.

field user_shared: dict[str, Any] | None = None

Optional. Service message: a user was shared with the bot.

field venue: dict[str, Any] | None = None

Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set.

field via_bot: User | None = None

Optional. Bot through which the message was sent.

field video: dict[str, Any] | None = None

Optional. Message is a video, information about the video.

field video_chat_ended: dict[str, Any] | None = None

Optional. Service message: video chat ended.

field video_chat_participants_invited: dict[str, Any] | None = None

Optional. Service message: new participants invited to a video chat.

field video_chat_scheduled: dict[str, Any] | None = None

Optional. Service message: video chat scheduled.

field video_chat_started: dict[str, Any] | None = None

Optional. Service message: video chat started.

field video_note: dict[str, Any] | None = None

Optional. Message is a video note, information about the video message.

field voice: dict[str, Any] | None = None

Optional. Message is a voice message, information about the file.

field web_app_data: dict[str, Any] | None = None

Optional. Service message: data sent by a Web App.

field write_access_allowed: dict[str, Any] | None = None

Optional. Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess.

pydantic model tg_api.tg_types.MessageEntity[source]

Bases: BaseModel, ValidableMixin

This model represents one special entity in a text message.

For example, hashtags, usernames, URLs, etc.

See here: https://core.telegram.org/bots/api#messageentity

field custom_emoji_id: str | None = None

Optional. For “custom_emoji” only, unique identifier of the custom emoji.

field language: str | None = None

Optional. For “pre” only, the programming language of the entity text.

field length: int [Required]

Length of the entity in UTF-16 code units.

field offset: int [Required]

Offset in UTF-16 code units to the start of the entity.

field type: str [Required]

Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers).

field url: str | None = None

Optional. For “text_link” only, URL that will be opened after user taps on the text.

field user: User | None = None

Optional. For “text_mention” only, the mentioned user.

pydantic model tg_api.tg_types.MessageReplyMarkup[source]

Bases: BaseModel, ValidableMixin

field message_reply_markup: Message | bool [Required]
pydantic model tg_api.tg_types.OrderInfo[source]

Bases: BaseModel, ValidableMixin

This object represents information about an order.

See here: https://core.telegram.org/bots/api#orderinfo

field email: str | None = None

Optional. User email.

field name: str | None = None

Optional. User name.

field phone_number: str | None = None

Optional. User’s phone number.

field shipping_address: ShippingAddress | None = None

Optional. User shipping address.

class tg_api.tg_types.ParseMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

HTML = 'HTML'
Markdown = 'Markdown'
MarkdownV2 = 'MarkdownV2'
pydantic model tg_api.tg_types.Poll[source]

Bases: BaseModel, ValidableMixin

This object contains information about a poll.

See here: https://core.telegram.org/bots/api#poll

field allows_multiple_answers: bool [Required]

True, if the poll allows multiple answers.

field close_date: int | None = None

Optional. Point in time (Unix timestamp) when the poll will be automatically closed.

field correct_option_id: int | None = None

Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.

field explanation: str | None = None

Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters.

field explanation_entities: list[MessageEntity] | None = None

Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation.

field id: str [Required]

Unique poll identifier.

field is_anonymous: bool [Required]

True, if the poll is anonymous.

field is_closed: bool [Required]

True, if the poll is closed.

field open_period: int | None = None

Optional. Amount of time in seconds the poll will be active after creation.

field options: list[PollOption] [Required]

List of poll options.

field question: str [Required]

Poll question, 1-300 characters.

field total_voter_count: int [Required]

Total number of users that voted in the poll.

field type: str [Required]

Poll type, currently can be “regular” or “quiz”.

pydantic model tg_api.tg_types.PollAnswer[source]

Bases: BaseModel, ValidableMixin

This object represents an answer of a user in a non-anonymous poll.

See here: https://core.telegram.org/bots/api#pollanswer

field option_ids: list[int] [Required]

0-based identifiers of chosen answer options. May be empty if the vote was retracted.

field poll_id: str [Required]

Unique poll identifier.

field user: User [Required]

Optional. The user that changed the answer to the poll, if the voter isn’t anonymous.

pydantic model tg_api.tg_types.PollOption[source]

Bases: BaseModel, ValidableMixin

This object contains information about one answer option in a poll.

See here: https://core.telegram.org/bots/api#polloption

field text: str [Required]

Option text, 1-100 characters.

field voter_count: int [Required]

Number of users that voted for this option.

pydantic model tg_api.tg_types.PreCheckoutQuery[source]

Bases: BaseModel, ValidableMixin

This object contains information about an incoming pre-checkout query.

See here: https://core.telegram.org/bots/api#precheckoutquery

field currency: str [Required]

Three-letter ISO 4217 currency code.

field from_: User [Required] (alias 'from')

User who sent the query.

field id: str [Required]

Unique query identifier.

field invoice_payload: str [Required]

Bot specified invoice payload.

field order_info: OrderInfo | None = None

Optional. Order information provided by the user.

field shipping_option_id: str | None = None

Optional. Identifier of the shipping option chosen by the user.

field total_amount: int [Required]

Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

pydantic model tg_api.tg_types.ReplyKeyboardMarkup[source]

Bases: BaseModel, ValidableMixin

This model represents a custom keyboard with reply options.

See here: https://core.telegram.org/bots/api#replykeyboardmarkup

field input_field_placeholder: str | None = None

Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters.

field is_persistent: bool | None = None

Optional. Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon.

field keyboard: list[list[KeyboardButton]] [Required]

Array of button rows, each represented by an Array of KeyboardButton objects

field one_time_keyboard: bool | None = None

Optional. Requests clients to hide the keyboard as soon as it’s been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat - the user can press a special button in the input field to see the custom keyboard again. Defaults to false.

field resize_keyboard: bool | None = None

Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app’s standard keyboard.

field selective: bool | None = None

Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply (has reply_to_message_id), sender of the original message. Example: A user requests to change the bot’s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.

pydantic model tg_api.tg_types.ReplyKeyboardRemove[source]

Bases: BaseModel, ValidableMixin

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 here: https://core.telegram.org/bots/api#replykeyboardremove

field remove_keyboard: bool [Required]

Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup).

field selective: bool | None = None

Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply (has reply_to_message_id), sender of the original message. Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven’t voted yet.

pydantic model tg_api.tg_types.ResponseParameters[source]

Bases: BaseModel, ValidableMixin

Describes why a request was unsuccessful.

See here: https://core.telegram.org/bots/api#responseparameters

field migrate_to_chat_id: int | None = None

Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

field retry_after: int | None = None

Optional. In case of exceeding flood control, the number of seconds left to wait before the request can be repeated

pydantic model tg_api.tg_types.ShippingAddress[source]

Bases: BaseModel, ValidableMixin

This object represents a shipping address.

See here: https://core.telegram.org/bots/api#shippingaddress

field city: str [Required]

City.

field country_code: str [Required]

Two-letter ISO 3166-1 alpha-2 country code.

field post_code: str [Required]

Address post code.

field state: str [Required]

State, if applicable.

field street_line1: str [Required]

First line for the address.

field street_line2: str [Required]

Second line for the address.

pydantic model tg_api.tg_types.ShippingQuery[source]

Bases: BaseModel, ValidableMixin

This object contains information about an incoming shipping query.

See here: https://core.telegram.org/bots/api#shippingquery

field from_: User [Required] (alias 'from')

User who sent the query.

field id: str [Required]

Unique query identifier.

field invoice_payload: str [Required]

Bot specified invoice payload.

field shipping_address: ShippingAddress [Required]

User specified shipping address.

pydantic model tg_api.tg_types.SuccessfulPayment[source]

Bases: BaseModel, ValidableMixin

This object contains basic information about a successful payment.

See here: https://core.telegram.org/bots/api#successfulpayment

field currency: str [Required]

Three-letter ISO 4217 currency code.

field invoice_payload: str [Required]

Bot specified invoice payload.

field order_info: OrderInfo | None = None

Optional. Order information provided by the user.

field provider_payment_charge_id: str | None = None

Provider payment identifier.

field shipping_option_id: str | None = None

Optional. Identifier of the shipping option chosen by the user.

field telegram_payment_charge_id: str | None = None

Telegram payment identifier.

field total_amount: int [Required]

Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

pydantic model tg_api.tg_types.Update[source]

Bases: BaseModel, ValidableMixin

This object represents an incoming update.

See here: https://core.telegram.org/bots/api#update

field callback_query: CallbackQuery | None = None

Optional. New incoming callback query.

field channel_post: Message | None = None

Optional. New incoming channel post of any kind - text, photo, sticker, etc.

field chat_join_request: ChatJoinRequest | None = None

Optional. A request to join the chat has been sent. The bot must have the can_invite_users administrator right in the chat to receive these updates.

field chat_member: ChatMemberUpdated | None = None

Optional. A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify chat_member in the list of allowed_updates to receive these updates.

field chosen_inline_result: ChosenInlineResult | None = None

Optional. The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.

field edited_channel_post: Message | None = None

Optional. New version of a channel post that is known to the bot and was edited.

field edited_message: Message | None = None

Optional. New version of a message that is known to the bot and was edited.

field inline_query: InlineQuery | None = None

Optional. New incoming inline query.

field message: Message | None = None

Optional. New incoming message of any kind - text, photo, sticker, etc.

field my_chat_member: ChatMemberUpdated | None = None

Optional. The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

field poll: Poll | None = None

Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot.

field poll_answer: PollAnswer | None = None

Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

field pre_checkout_query: PreCheckoutQuery | None = None

Optional. New incoming pre-checkout query. Contains full information about checkout.

field shipping_query: ShippingQuery | None = None

Optional. New incoming shipping query. Only for invoices with flexible price.

field update_id: int [Required]

The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

pydantic model tg_api.tg_types.User[source]

Bases: BaseModel, ValidableMixin

This model represents a Telegram user or bot.

See here: https://core.telegram.org/bots/api#user

field added_to_attachment_menu: bool | None = None

Optional. True, if this user added the bot to the attachment menu.

field can_join_groups: bool | None = None

Optional. True, if the bot can be invited to groups. Returned only in getMe.

field can_read_all_group_messages: bool | None = None

Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.

field first_name: str [Required]

User’s or bot’s first name.

field id: int [Required]

Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.

field is_bot: bool [Required]

True, if this user is a bot.

field is_premium: bool | None = None

Optional. True, if this user is a Telegram Premium user.

field language_code: str | None = None

Optional. IETF language tag of the user’s language.

field last_name: str | None = None

Optional. User’s or bot’s last name.

field supports_inline_queries: bool | None = None

Optional. True, if the bot supports inline queries. Returned only in getMe.

field username: str | None = None

Optional. User’s or bot’s username.

class tg_api.tg_types.ValidableMixin[source]

Bases: object

This mixin sets validation for all fields.

class Config[source]

Bases: object

validate_all = True
pydantic model tg_api.tg_types.WebhookInfo[source]

Bases: BaseModel, ValidableMixin

Describes the current status of a webhook.

https://core.telegram.org/bots/api#webhookinfo

field allowed_updates: list[str] | None = None

Optional. A list of update types the bot is subscribed to. Defaults to all update types except chat_member

field has_custom_certificate: bool [Required]

True, if a custom certificate was provided for webhook certificate checks.

field ip_address: str | None = None

Optional. Currently used webhook IP address

field last_error_date: int | None = None

Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook

field last_error_message: str | None = None

Optional. Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook

field last_synchronization_error_date: int | None = None

Optional. Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters

field max_connections: int | None = None

Optional. The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery

field pending_update_count: int [Required]

Number of updates awaiting delivery

field url: str [Required]

Webhook URL, may be empty if webhook is not set up