Librería pyTelegramBotAPI
Librería pyTelegramBotAPI
Release 4.25.0
coder2020official
1 TeleBot 1
 1.1 Chats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
 1.2 Some features: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
 1.3 Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Index 327
 i
ii
 CHAPTER
ONE
TELEBOT
1.1 Chats
English chat: Private chat
Russian chat: @pytelegrambotapi_talks_ru
News: @pyTelegramBotAPI
Pypi: Pypi
Source: Github repository
1.3 Content
1.3.1 Installation Guide
Using PIP
Using pipenv
 1
pyTelegramBotAPI, Release 4.25.0
By cloning repository
#!/usr/bin/python
import telebot
API_TOKEN = '<api_token>'
bot = telebot.TeleBot(API_TOKEN)
""")
# Handle all other messages with content_type 'text' (content_types defaults to ['text'])
@bot.message_handler(func=lambda message: True)
def echo_message(message):
 bot.reply_to(message, message.text)
bot.infinity_polling()
2 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
Asynchronous TeleBot
#!/usr/bin/python
bot = AsyncTeleBot('TOKEN')
# Handle all other messages with content_type 'text' (content_types defaults to ['text'])
@bot.message_handler(func=lambda message: True)
async def echo_message(message):
 await bot.reply_to(message, message.text)
asyncio.run(bot.polling())
1.3. Content 3
pyTelegramBotAPI, Release 4.25.0
 Return type
 AffiliateInfo
class telebot.types.Animation(file_id, file_unique_id, width=None, height=None, duration=None,
 thumbnail=None, file_name=None, mime_type=None, file_size=None,
 **kwargs)
 Bases: JsonDeserializable
 This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
 Telegram Documentation: https://core.telegram.org/bots/api#animation
 Parameters
 • file_id (str) – Identifier for this file, which can be used to download or reuse the file
 • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same
 over time and for different bots. Can’t be used to download or reuse the file.
 • width (int) – Video width as defined by sender
 • height (int) – Video height as defined by sender
 • duration (int) – Duration of the video in seconds as defined by sender
 • thumbnail (telebot.types.PhotoSize) – Optional. Animation thumbnail as defined by
 sender
 • file_name (str) – Optional. Original animation filename as defined by sender
 • mime_type (str) – Optional. MIME type of the file as defined by sender
 • file_size (int) – Optional. File size in bytes. It can be bigger than 2^31 and some pro-
 gramming 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 value.
 Returns
 Instance of the class
 Return type
 telebot.types.Animation
 property thumb: PhotoSize | None
4 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
class telebot.types.BackgroundFill
 Bases: ABC, JsonDeserializable
 This object describes the way a background is filled based on the selected colors. Currently, it can be one
 of
 BackgroundFillSolid BackgroundFillGradient BackgroundFillFreeformGradient
 Telegram documentation: https://core.telegram.org/bots/api#backgroundfill
 Returns
 Instance of the class
 Return type
 BackgroundFillSolid or BackgroundFillGradient or
 BackgroundFillFreeformGradient
class telebot.types.BackgroundFillFreeformGradient(type, colors, **kwargs)
 Bases: BackgroundFill
 The background is a freeform gradient that rotates after every message in the chat.
 Telegram documentation: https://core.telegram.org/bots/api#backgroundfillfreeformgradient
 Parameters
 • type (str) – Type of the background fill, always “freeform_gradient”
 • colors (list of int) – A list of the 3 or 4 base colors that are used to generate the freeform
 gradient in the RGB24 format
 Returns
 Instance of the class
 Return type
 BackgroundFillFreeformGradient
class telebot.types.BackgroundFillGradient(type, top_color, bottom_color, rotation_angle, **kwargs)
 Bases: BackgroundFill
 The background is a gradient fill.
 Telegram documentation: https://core.telegram.org/bots/api#backgroundfillgradient
 Parameters
1.3. Content 5
pyTelegramBotAPI, Release 4.25.0
6 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Return type
 BackgroundTypeChatTheme
class telebot.types.BackgroundTypeFill(type, fill, dark_theme_dimming, **kwargs)
 Bases: BackgroundFill
 The background is automatically filled based on the selected colors.
 Telegram documentation: https://core.telegram.org/bots/api#backgroundtypefill
 Parameters
 • type (str) – Type of the background, always “fill”
 • fill (BackgroundFill) – The background fill
 • dark_theme_dimming (int) – Dimming of the background in dark themes, as a percentage;
 0-100
 Returns
 Instance of the class
 Return type
 BackgroundTypeFill
class telebot.types.BackgroundTypePattern(type, document, fill, intensity, is_inverted=None,
 is_moving=None, **kwargs)
 Bases: BackgroundFill
 The background is a wallpaper in the JPEG format.
 Telegram documentation: https://core.telegram.org/bots/api#backgroundtypepattern
 Parameters
 • type (str) – Type of the background, always “pattern”
 • document (Document) – Document with the pattern
 • fill (BackgroundFill) – The background fill that is combined with the pattern
 • intensity (int) – Intensity of the pattern when it is shown above the filled background;
 0-100
 • is_inverted (bool) – Optional. True, if the background fill must be applied only to the
 pattern itself. All other pixels are black in this case. For dark themes only
 • is_moving (bool) – Optional. True, if the background moves slightly when the device is
 tilted
 Returns
 Instance of the class
 Return type
 BackgroundTypePattern
class telebot.types.BackgroundTypeWallpaper(type, document, dark_theme_dimming, is_blurred=None,
 is_moving=None, **kwargs)
 Bases: BackgroundFill
 The background is a wallpaper in the JPEG format.
 Telegram documentation: https://core.telegram.org/bots/api#backgroundtypewallpaper
 Parameters
1.3. Content 7
pyTelegramBotAPI, Release 4.25.0
8 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • BotCommandScopeDefault
 • BotCommandScopeAllPrivateChats
 • BotCommandScopeAllGroupChats
 • BotCommandScopeAllChatAdministrators
 • BotCommandScopeChat
 • BotCommandScopeChatAdministrators
 • BotCommandScopeChatMember
 Determining list of commands The following algorithm is used to determine the list of commands for a particular
 user viewing the bot menu. The first list of commands which is set is returned:
 Commands in the chat with the bot:
 • BotCommandScopeChat + language_code
 • BotCommandScopeChat
 • BotCommandScopeAllPrivateChats + language_code
 • BotCommandScopeAllPrivateChats
 • BotCommandScopeDefault + language_code
 • BotCommandScopeDefault
 Commands in group and supergroup chats:
 • BotCommandScopeChatMember + language_code
 • BotCommandScopeChatMember
 • BotCommandScopeChatAdministrators + language_code (administrators only)
 • BotCommandScopeChatAdministrators (administrators only)
 • BotCommandScopeChat + language_code
 • BotCommandScopeChat
 • BotCommandScopeAllChatAdministrators + language_code (administrators only)
 • BotCommandScopeAllChatAdministrators (administrators only)
 • BotCommandScopeAllGroupChats + language_code
 • BotCommandScopeAllGroupChats
 • BotCommandScopeDefault + language_code
 • BotCommandScopeDefault
 Returns
 Instance of the class
 Return type
 telebot.types.BotCommandScope
class telebot.types.BotCommandScopeAllChatAdministrators
 Bases: BotCommandScope
 Represents the scope of bot commands, covering all group and supergroup chat administrators.
 Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallchatadministrators
1.3. Content 9
pyTelegramBotAPI, Release 4.25.0
 Parameters
 type (str) – Scope type, must be all_chat_administrators
 Returns
 Instance of the class
 Return type
 telebot.types.BotCommandScopeAllChatAdministrators
class telebot.types.BotCommandScopeAllGroupChats
 Bases: BotCommandScope
 Represents the scope of bot commands, covering all group and supergroup chats.
 Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallgroupchats
 Parameters
 type (str) – Scope type, must be all_group_chats
 Returns
 Instance of the class
 Return type
 telebot.types.BotCommandScopeAllGroupChats
class telebot.types.BotCommandScopeAllPrivateChats
 Bases: BotCommandScope
 Represents the scope of bot commands, covering all private chats.
 Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallprivatechats
 Parameters
 type (str) – Scope type, must be all_private_chats
 Returns
 Instance of the class
 Return type
 telebot.types.BotCommandScopeAllPrivateChats
class telebot.types.BotCommandScopeChat(chat_id: int | str | None = None)
 Bases: BotCommandScope
 Represents the scope of bot commands, covering a specific chat.
 Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopechat
 Parameters
 • type (str) – Scope type, must be chat
 • chat_id (int or str) – Unique identifier for the target chat or username of the target su-
 pergroup (in the format @supergroupusername)
 Returns
 Instance of the class
 Return type
 telebot.types.BotCommandScopeChat
10 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 11
pyTelegramBotAPI, Release 4.25.0
 Parameters
 description (str) – Bot description
 Returns
 Instance of the class
 Return type
 telebot.types.BotDescription
class telebot.types.BotName(name: str, **kwargs)
 Bases: JsonDeserializable
 This object represents a bot name.
 Telegram Documentation: https://core.telegram.org/bots/api#botname
 Parameters
 name (str) – The bot name
 Returns
 Instance of the class
 Return type
 BotName
class telebot.types.BotShortDescription(short_description: str, **kwargs)
 Bases: JsonDeserializable
 This object represents a bot short description.
 Telegram documentation: https://core.telegram.org/bots/api#botshortdescription
 Parameters
 short_description (str) – Bot short description
 Returns
 Instance of the class
 Return type
 telebot.types.BotShortDescription
class telebot.types.BusinessConnection(id, user, user_chat_id, date, can_reply, is_enabled, **kwargs)
 Bases: JsonDeserializable
 This object describes the connection of the bot with a business account.
 Telegram documentation: https://core.telegram.org/bots/api#businessconnection
 Parameters
 • id (str) – Unique identifier of the business connection
 • user (User) – Business account user that created the business connection
 • user_chat_id (int) – Identifier of a private chat with the user who created the business
 connection
 • date (int) – Date the connection was established in Unix time
 • can_reply (bool) – True, if the bot can act on behalf of the business account in chats that
 were active in the last 24 hours
 • is_enabled (bool) – True, if the connection is active
 Returns
 Instance of the class
12 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Return type
 BusinessConnection
class telebot.types.BusinessIntro(title=None, message=None, sticker=None, **kwargs)
 Bases: JsonDeserializable
 This object represents a business intro.
 Telegram documentation: https://core.telegram.org/bots/api#businessintro
 Parameters
 • title (str) – Optional. Title text of the business intro
 • message (str) – Optional. Message text of the business intro
 • sticker (Sticker) – Optional. Sticker of the business intro
 Returns
 Instance of the class
 Return type
 BusinessIntro
class telebot.types.BusinessLocation(address, location=None, **kwargs)
 Bases: JsonDeserializable
 This object represents a business location.
 Telegram documentation: https://core.telegram.org/bots/api#businesslocation
 Parameters
 • address (str) – Address of the business
 • location (Location) – Optional. Location of the business
 Returns
 Instance of the class
 Return type
 BusinessLocation
class telebot.types.BusinessMessagesDeleted(business_connection_id, chat, message_ids, **kwargs)
 Bases: JsonDeserializable
 This object is received when messages are deleted from a connected business account.
 Telegram documentation: https://core.telegram.org/bots/api#businessmessagesdeleted
 Parameters
 • business_connection_id (str) – Unique identifier of the business connection
 • chat (Chat) – Information about a chat in the business account. The bot may not have access
 to the chat or the corresponding user.
 • message_ids (list of int) – A JSON-serialized list of identifiers of deleted messages in
 the chat of the business account
 Returns
 Instance of the class
 Return type
 BusinessMessagesDeleted
1.3. Content 13
pyTelegramBotAPI, Release 4.25.0
14 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • chat_instance (str) – Global identifier, uniquely corresponding to the chat to which the
 message with the callback button was sent. Useful for high scores in games.
 • data (str) – Optional. Data associated with the callback button. Be aware that the message
 originated the query can contain no callback buttons with this data.
 • game_short_name (str) – Optional. Short name of a Game to be returned, serves as the
 unique identifier for the game
 Returns
 Instance of the class
 Return type
 telebot.types.CallbackQuery
class telebot.types.Chat(id, type, title=None, username=None, first_name=None, last_name=None,
 photo=None, bio=None, has_private_forwards=None, description=None,
 invite_link=None, pinned_message=None, permissions=None,
 slow_mode_delay=None, message_auto_delete_time=None,
 has_protected_content=None, sticker_set_name=None, can_set_sticker_set=None,
 linked_chat_id=None, location=None, join_to_send_messages=None,
 join_by_request=None, has_restricted_voice_and_video_messages=None,
 is_forum=None, max_reaction_count=None, active_usernames=None,
 emoji_status_custom_emoji_id=None, has_hidden_members=None,
 has_aggressive_anti_spam_enabled=None, emoji_status_expiration_date=None,
 available_reactions=None, accent_color_id=None,
 background_custom_emoji_id=None, profile_accent_color_id=None,
 profile_background_custom_emoji_id=None, has_visible_history=None,
 unrestrict_boost_count=None, custom_emoji_sticker_set_name=None,
 business_intro=None, business_location=None, business_opening_hours=None,
 personal_chat=None, birthdate=None, can_send_paid_media=None, **kwargs)
 Bases: ChatFullInfo
 In BotAPI 7.3 Chat was reduced and full info moved to ChatFullInfo: “Split out the class ChatFullInfo from the
 class Chat and changed the return type of the method getChat to ChatFullInfo.”
 https://core.telegram.org/bots/api#chatfullinfo
 Currently Chat is left as full copy of ChatFullInfo for compatibility.
class telebot.types.ChatAdministratorRights(is_anonymous: bool, can_manage_chat: bool,
 can_delete_messages: bool, can_manage_video_chats:
 bool, can_restrict_members: bool, can_promote_members:
 bool, can_change_info: bool, can_invite_users: bool,
 can_post_messages: bool | None = None,
 can_edit_messages: bool | None = None,
 can_pin_messages: bool | None = None,
 can_manage_topics: bool | None = None,
 can_post_stories: bool | None = None, can_edit_stories:
 bool | None = None, can_delete_stories: bool | None =
 None, **kwargs)
 Bases: JsonDeserializable, JsonSerializable, Dictionaryable
 Represents the rights of an administrator in a chat.
 Telegram Documentation: https://core.telegram.org/bots/api#chatadministratorrights
 Parameters
 • is_anonymous (bool) – True, if the user’s presence in the chat is hidden
1.3. Content 15
pyTelegramBotAPI, Release 4.25.0
 • can_manage_chat (bool) – True, if the administrator can access the chat event log, chat
 statistics, message statistics in channels, see channel members, see anonymous administra-
 tors in supergroups and ignore slow mode. Implied by any other administrator privilege
 • can_delete_messages (bool) – True, if the administrator can delete messages of other
 users
 • can_manage_video_chats (bool) – True, if the administrator can manage video chats
 • can_restrict_members (bool) – True, if the administrator can restrict, ban or unban chat
 members
 • can_promote_members (bool) – True, if the administrator can add new administrators with
 a subset of their own privileges or demote administrators that he has promoted, directly or
 indirectly (promoted by administrators that were appointed by the user)
 • can_change_info (bool) – True, if the user is allowed to change the chat title, photo and
 other settings
 • can_invite_users (bool) – True, if the user is allowed to invite new users to the chat
 • can_post_messages (bool) – Optional. True, if the administrator can post in the channel;
 channels only
 • can_edit_messages (bool) – Optional. True, if the administrator can edit messages of
 other users and can pin messages; channels only
 • can_pin_messages (bool) – Optional. True, if the user is allowed to pin messages; groups
 and supergroups only
 • can_manage_topics (bool) – Optional. True, if the user is allowed to create, rename,
 close, and reopen forum topics; supergroups only
 • can_post_stories (bool) – Optional. True, if the administrator can post channel stories
 • can_edit_stories (bool) – Optional. True, if the administrator can edit stories
 • can_delete_stories (bool) – Optional. True, if the administrator can delete stories of
 other users
 Returns
 Instance of the class
 Return type
 telebot.types.ChatAdministratorRights
class telebot.types.ChatBackground(type, **kwargs)
 Bases: JsonDeserializable
 This object represents a chat background.
 Telegram documentation: https://core.telegram.org/bots/api#chatbackground
 Parameters
 type (BackgroundType) – Type of the background
 Returns
 Instance of the class
 Return type
 ChatBackground
16 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 17
pyTelegramBotAPI, Release 4.25.0
class telebot.types.ChatBoostSource
 Bases: ABC, JsonDeserializable
 This object describes the source of a chat boost. It can be one of
 ChatBoostSourcePremium ChatBoostSourceGiftCode ChatBoostSourceGiveaway
 Telegram documentation: https://core.telegram.org/bots/api#chatboostsource
 Returns
 Instance of the class
 Return type
 ChatBoostSourcePremium or ChatBoostSourceGiftCode or ChatBoostSourceGiveaway
class telebot.types.ChatBoostSourceGiftCode(source, user, **kwargs)
 Bases: ChatBoostSource
 The boost was obtained by the creation of Telegram Premium gift codes to boost a chat.
 Telegram documentation: https://core.telegram.org/bots/api#chatboostsourcegiftcode
 Parameters
 • source (str) – Source of the boost, always “gift_code”
 • user (User) – User for which the gift code was created
 Returns
 Instance of the class
 Return type
 ChatBoostSourceGiftCode
class telebot.types.ChatBoostSourceGiveaway(source, giveaway_message_id, user=None,
 is_unclaimed=None, prize_star_count=None, **kwargs)
 Bases: ChatBoostSource
 The boost was obtained by the creation of a Telegram Premium giveaway.
 Telegram documentation: https://core.telegram.org/bots/api#chatboostsourcegiveaway
 Parameters
 • source (str) – Source of the boost, always “giveaway”
 • giveaway_message_id (int) – Identifier of a message in the chat with the giveaway; the
 message could have been deleted already. May be 0 if the message isn’t sent yet.
 • user (User) – User that won the prize in the giveaway if any
 • is_unclaimed (bool) – True, if the giveaway was completed, but there was no user to win
 the prize
 • prize_star_count (int) – Optional. The number of Telegram Stars to be split between
 giveaway winners; for Telegram Star giveaways only
 Returns
 Instance of the class
 Return type
 ChatBoostSourceGiveaway
18 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 19
pyTelegramBotAPI, Release 4.25.0
20 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 21
pyTelegramBotAPI, Release 4.25.0
 • can_set_sticker_set (bool) – Optional. bool, if the bot can change the group sticker
 set. Returned only in getChat.
 • custom_emoji_sticker_set_name – Optional. For supergroups, the name of the group’s
 custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the
 group. Returned only in getChat.
 • custom_emoji_sticker_set_name – str
 • linked_chat_id (int) – 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 identi-
 fier 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.
 • location (telebot.types.ChatLocation) – Optional. For supergroups, the location to
 which the supergroup is connected. Returned only in getChat.
 • can_send_paid_media (bool) – Optional. True, if paid media messages can be sent or
 forwarded to the channel chat. The field is available only for channel chats.
 Returns
 Instance of the class
 Return type
 telebot.types.ChatFullInfo
class telebot.types.ChatInviteLink(invite_link: str, creator: User, creates_join_request: bool, is_primary:
 bool, is_revoked: bool, name: str | None = None, expire_date: int |
 None = None, member_limit: int | None = None,
 pending_join_request_count: int | None = None, **kwargs)
 Bases: JsonSerializable, JsonDeserializable, Dictionaryable
 Represents an invite link for a chat.
 Telegram Documentation: https://core.telegram.org/bots/api#chatinvitelink
 Parameters
 • invite_link (str) – The invite link. If the link was created by another chat administrator,
 then the second part of the link will be replaced with “. . . ”.
 • creator (telebot.types.User) – Creator of the link
 • creates_join_request (bool) – True, if users joining the chat via the link need to be
 approved by chat administrators
 • is_primary (bool) – True, if the link is primary
 • is_revoked (bool) – True, if the link is revoked
 • name (str) – Optional. Invite link name
 • expire_date (int) – Optional. Point in time (Unix timestamp) when the link will expire
 or has been expired
 • member_limit (int) – Optional. The maximum number of users that can be members of
 the chat simultaneously after joining the chat via this invite link; 1-99999
 • pending_join_request_count (int) – Optional. Number of pending join requests cre-
 ated using this link
 Returns
 Instance of the class
22 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Return type
 telebot.types.ChatInviteLink
class telebot.types.ChatJoinRequest(chat, from_user, user_chat_id, date, bio=None, invite_link=None,
 **kwargs)
 Bases: JsonDeserializable
 Represents a join request sent to a chat.
 Telegram Documentation: https://core.telegram.org/bots/api#chatjoinrequest
 Parameters
 • chat (telebot.types.Chat) – Chat to which the request was sent
 • from_user (telebot.types.User) – User that sent the join request
 • user_chat_id (int) – Optional. 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 24 hours to send messages until the join request is processed,
 assuming no other administrator contacted the user.
 • date (int) – Date the request was sent in Unix time
 • bio (str) – Optional. Bio of the user.
 • invite_link (telebot.types.ChatInviteLink) – Optional. Chat invite link that was
 used by the user to send the join request
 Returns
 Instance of the class
 Return type
 telebot.types.ChatJoinRequest
class telebot.types.ChatLocation(location: Location, address: str, **kwargs)
 Bases: JsonSerializable, JsonDeserializable, Dictionaryable
 Represents a location to which a chat is connected.
 Telegram Documentation: https://core.telegram.org/bots/api#chatlocation
 Parameters
 • location (telebot.types.Location) – The location to which the supergroup is con-
 nected. Can’t be a live location.
 • address (str) – Location address; 1-64 characters, as defined by the chat owner
 Returns
 Instance of the class
 Return type
 telebot.types.ChatLocation
1.3. Content 23
pyTelegramBotAPI, Release 4.25.0
24 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 25
pyTelegramBotAPI, Release 4.25.0
26 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 27
pyTelegramBotAPI, Release 4.25.0
28 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 29
pyTelegramBotAPI, Release 4.25.0
 Returns
 Dict of differences
 Return type
 Dict[str, List]
class telebot.types.ChatPermissions(can_send_messages=None, can_send_media_messages=None,
 can_send_audios=None, can_send_documents=None,
 can_send_photos=None, can_send_videos=None,
 can_send_video_notes=None, can_send_voice_notes=None,
 can_send_polls=None, can_send_other_messages=None,
 can_add_web_page_previews=None, can_change_info=None,
 can_invite_users=None, can_pin_messages=None,
 can_manage_topics=None, **kwargs)
 Bases: JsonDeserializable, JsonSerializable, Dictionaryable
 Describes actions that a non-administrator user is allowed to take in a chat.
 Telegram Documentation: https://core.telegram.org/bots/api#chatpermissions
 Parameters
 • can_send_messages (bool) – Optional. True, if the user is allowed to send text messages,
 contacts, locations and venues
 • can_send_audios (bool) – Optional. True, if the user is allowed to send audios
 • can_send_documents (bool) – Optional. True, if the user is allowed to send documents
 • can_send_photos (bool) – Optional. True, if the user is allowed to send photos
 • can_send_videos (bool) – Optional. True, if the user is allowed to send videos
 • can_send_video_notes (bool) – Optional. True, if the user is allowed to send video notes
 • can_send_voice_notes (bool) – Optional. True, if the user is allowed to send voice notes
 • can_send_polls (bool) – Optional. True, if the user is allowed to send polls, implies
 can_send_messages
 • can_send_other_messages (bool) – Optional. True, if the user is allowed to send ani-
 mations, games, stickers and use inline bots
 • can_add_web_page_previews (bool) – Optional. True, if the user is allowed to add web
 page previews to their messages
 • can_change_info (bool) – Optional. True, if the user is allowed to change the chat title,
 photo and other settings. Ignored in public supergroups
 • can_invite_users (bool) – Optional. True, if the user is allowed to invite new users to
 the chat
 • can_pin_messages (bool) – Optional. True, if the user is allowed to pin messages. Ignored
 in public supergroups
 • can_manage_topics (bool) – Optional. True, if the user is allowed to create forum topics.
 If omitted defaults to the value of can_pin_messages
 • can_send_media_messages (bool) – deprecated.
 Returns
 Instance of the class
 Return type
 telebot.types.ChatPermissions
30 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 31
pyTelegramBotAPI, Release 4.25.0
32 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Parameters
 text (str) – The text to be copied to the clipboard; 1-256 characters
 Returns
 Instance of the class
 Return type
 CopyTextButton
 to_dict()
1.3. Content 33
pyTelegramBotAPI, Release 4.25.0
 Returns
 Instance of the class
 Return type
 telebot.types.Document
 property thumb: PhotoSize | None
34 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 35
pyTelegramBotAPI, Release 4.25.0
36 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 This object represents a service message about a new forum topic created in the chat.
 Telegram documentation: https://core.telegram.org/bots/api#forumtopiccreated
 Parameters
 • name (str) – Name of the topic
 • icon_color (int) – Color of the topic icon in RGB format
 • icon_custom_emoji_id (str) – Optional. Unique identifier of the custom emoji shown
 as the topic icon
 Returns
 Instance of the class
 Return type
 telebot.types.ForumTopicCreated
class telebot.types.ForumTopicEdited(name: str | None = None, icon_custom_emoji_id: str | None = None,
 **kwargs)
 Bases: JsonDeserializable
 This object represents a service message about an edited forum topic.
 Telegram documentation: https://core.telegram.org/bots/api#forumtopicedited
 Parameters
 • name (str) – Optional, Name of the topic(if updated)
 • icon_custom_emoji_id (str) – Optional. New identifier of the custom emoji shown as
 the topic icon, if it was edited; an empty string if the icon was removed
class telebot.types.ForumTopicReopened
 Bases: JsonDeserializable
 This object represents a service message about a forum topic reopened in the chat. Currently holds no informa-
 tion.
 Telegram documentation: https://core.telegram.org/bots/api#forumtopicreopened
class telebot.types.Game(title, description, photo, text=None, text_entities=None, animation=None,
 **kwargs)
 Bases: JsonDeserializable
 This object represents a game. Use BotFather to create and edit games, their short names will act as unique
 identifiers.
 Telegram Documentation: https://core.telegram.org/bots/api#game
 Parameters
 • title (str) – Title of the game
 • description (str) – Description of the game
 • photo (list of telebot.types.PhotoSize) – Photo that will be displayed in the game
 message in chats.
 • text (str) – Optional. Brief description of the game or high scores included in the game
 message. Can be automatically edited to include current high scores for the game when the
 bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
 • text_entities (list of telebot.types.MessageEntity) – Optional. Special entities
 that appear in text, such as usernames, URLs, bot commands, etc.
1.3. Content 37
pyTelegramBotAPI, Release 4.25.0
38 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • star_count (int) – The number of Telegram Stars that must be paid to send the sticker
 • upgrade_star_count (int) – Optional. The number of Telegram Stars that must be paid
 to upgrade the gift to a unique one
 • total_count (int) – Optional. The total number of the gifts of this type that can be sent;
 for limited gifts only
 • remaining_count (int) – Optional. The number of remaining gifts of this type that can
 be sent; for limited gifts only
 Returns
 Instance of the class
 Return type
 Gift
class telebot.types.Gifts(gifts, **kwargs)
 Bases: JsonDeserializable
 This object represent a list of gifts.
 Telegram documentation: https://core.telegram.org/bots/api#gifts
 Parameters
 gifts (list of Gift) – The list of gifts
 Returns
 Instance of the class
 Return type
 Gifts
class telebot.types.Giveaway(chats: List[Chat], winners_selection_date: int, winner_count: int,
 only_new_members: bool | None = None, has_public_winners: bool | None =
 None, prize_description: str | None = None, country_codes: List[str] | None =
 None, premium_subscription_month_count: int | None = None,
 prize_star_count: int | None = None, **kwargs)
 Bases: JsonDeserializable
 This object represents a message about a scheduled giveaway.
 Telegram documentation: https://core.telegram.org/bots/api#giveaway
 Parameters
 • chats (list of Chat) – The list of chats which the user must join to participate in the
 giveaway
 • winners_selection_date (int) – Point in time (Unix timestamp) when winners of the
 giveaway will be selected
 • winner_count (int) – The number of users which are supposed to be selected as winners
 of the giveaway
 • only_new_members (bool) – Optional. True, if only users who join the chats after the
 giveaway started should be eligible to win
 • has_public_winners (bool) – Optional. True, if the list of giveaway winners will be
 visible to everyone
 • prize_description (str) – Optional. Description of additional giveaway prize
1.3. Content 39
pyTelegramBotAPI, Release 4.25.0
 • country_codes (list of str) – Optional. A list of two-letter ISO 3166-1 alpha-2 country
 codes indicating the countries from which eligible users for the giveaway must come. If
 empty, then all users can participate in the giveaway.
 • prize_star_count (int) – Optional. The number of Telegram Stars to be split between
 giveaway winners; for Telegram Star giveaways only
 • premium_subscription_month_count (int) – Optional. The number of months the
 Telegram Premium subscription won from the giveaway will be active for
 Returns
 Instance of the class
 Return type
 Giveaway
class telebot.types.GiveawayCompleted(winner_count: int, unclaimed_prize_count: int | None = None,
 giveaway_message: Message | None = None, is_star_giveaway:
 bool | None = None, **kwargs)
 Bases: JsonDeserializable
 This object represents a service message about the completion of a giveaway without public winners.
 Telegram documentation: https://core.telegram.org/bots/api#giveawaycompleted
 Parameters
 • winner_count (int) – Number of winners in the giveaway
 • unclaimed_prize_count (int) – Optional. Number of undistributed prizes
 • giveaway_message (Message) – Optional. Message with the giveaway that was completed,
 if it wasn’t deleted
 • is_star_giveaway (bool) – Optional. True, if the giveaway was a Telegram Star giveaway
 Returns
 Instance of the class
 Return type
 GiveawayCompleted
class telebot.types.GiveawayCreated(prize_star_count=None, **kwargs)
 Bases: JsonDeserializable
 This object represents a service message about the creation of a scheduled giveaway.
 Prize_star_count
 Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram
 Star giveaways only
 Returns
 Instance of the class
class telebot.types.GiveawayWinners(chat: Chat, giveaway_message_id: int, winners_selection_date: int,
 winner_count: int, winners: List[User], additional_chat_count: int |
 None = None, premium_subscription_month_count: int | None =
 None, unclaimed_prize_count: int | None = None,
 only_new_members: bool | None = None, was_refunded: bool | None
 = None, prize_description: str | None = None, prize_star_count: int |
 None = None, **kwargs)
 Bases: JsonDeserializable
40 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 This object represents a message about the completion of a giveaway with public winners.
 Telegram documentation: https://core.telegram.org/bots/api#giveawaywinners
 Parameters
 • chat (Chat) – The chat that created the giveaway
 • giveaway_message_id (int) – Identifier of the messsage with the giveaway in the chat
 • winners_selection_date (int) – Point in time (Unix timestamp) when winners of the
 giveaway were selected
 • winner_count (int) – Total number of winners in the giveaway
 • winners (list of User) – List of up to 100 winners of the giveaway
 • additional_chat_count (int) – Optional. The number of other chats the user had to join
 in order to be eligible for the giveaway
 • premium_subscription_month_count (int) – Optional. The number of months the
 Telegram Premium subscription won from the giveaway will be active for
 • unclaimed_prize_count (int) – Optional. Number of undistributed prizes
 • only_new_members (bool) – Optional. True, if only users who had joined the chats after
 the giveaway started were eligible to win
 • was_refunded (bool) – Optional. True, if the giveaway was canceled because the payment
 for it was refunded
 • prize_description (str) – Optional. Description of additional giveaway prize
 • prize_star_count (int) – Optional. The number of Telegram Stars to be split between
 giveaway winners; for Telegram Star giveaways only
 Returns
 Instance of the class
 Return type
 GiveawayWinners
class telebot.types.InaccessibleMessage(chat, message_id, date, **kwargs)
 Bases: JsonDeserializable
 This object describes a message that was deleted or is otherwise inaccessible to the bot.
 Telegram documentation: https://core.telegram.org/bots/api#inaccessiblemessage
 Parameters
 • chat (Chat) – Chat the message belonged to
 • message_id (int) – Unique message identifier inside the chat
 • date (int) – Always 0. The field can be used to differentiate regular and inaccessible mes-
 sages.
 Returns
 Instance of the class
 Return type
 InaccessibleMessage
1.3. Content 41
pyTelegramBotAPI, Release 4.25.0
class telebot.types.InlineKeyboardButton(text: str, url: str | None = None, callback_data: str | None =
 None, web_app: WebAppInfo | None = None,
 switch_inline_query: str | None = None,
 switch_inline_query_current_chat: str | None = None,
 switch_inline_query_chosen_chat:
 SwitchInlineQueryChosenChat | None = None,
 callback_game=None, pay: bool | None = None, login_url:
 LoginUrl | None = None, copy_text: CopyTextButton | None =
 None, **kwargs)
 Bases: Dictionaryable, JsonSerializable, JsonDeserializable
 This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinekeyboardbutton
 Parameters
 • text (str) – Label text on the button
 • url (str) – 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.
 • callback_data (str) – Optional. Data to be sent in a callback query to the bot when button
 is pressed, 1-64 bytes
 • web_app (telebot.types.WebAppInfo) – 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.
 • login_url (telebot.types.LoginUrl) – Optional. An HTTPS URL used to automati-
 cally authorize the user. Can be used as a replacement for the Telegram Login Widget.
 • switch_inline_query (str) – 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.Note: This offers an easy way for users to start using your bot in inline mode
 when they are currently in a private chat with it. Especially useful when combined with
 switch_pm. . . actions - in this case the user will be automatically returned to the chat they
 switched from, skipping the chat selection screen.
 • switch_inline_query_current_chat (str) – 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.
 • switch_inline_query_chosen_chat (telebot.types.
 SwitchInlineQueryChosenChat) – 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
 • callback_game (telebot.types.CallbackGame) – 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.
 • pay (bool) – 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.
42 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
ò Note
 markup = quick_markup({
 'Twitter': {'url': 'https://twitter.com'},
 'Facebook': {'url': 'https://facebook.com'},
 'Back': {'callback_data': 'whatever'}
 }, row_width=2)
 # returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter,
 ˓→ the other to facebook
1.3. Content 43
pyTelegramBotAPI, Release 4.25.0
 row(*args) → InlineKeyboardMarkup
 Adds a list of InlineKeyboardButton to the keyboard. This method does not consider row_width.
 InlineKeyboardMarkup.row(“A”).row(“B”, “C”).to_json() outputs: ‘{keyboard: [[“A”], [“B”, “C”]]}’ See
 https://core.telegram.org/bots/api#inlinekeyboardmarkup
 Parameters
 args (list of telebot.types.InlineKeyboardButton) – Array of InlineKeyboardBut-
 ton to append to the keyboard
 Returns
 self, to allow function chaining.
 Return type
 telebot.types.InlineKeyboardMarkup
class telebot.types.InlineQuery(id, from_user, query, offset, chat_type=None, location=None, **kwargs)
 Bases: JsonDeserializable
 This object represents an incoming inline query. When the user sends an empty query, your bot could return
 some default or trending results.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequery
 Parameters
 • id (str) – Unique identifier for this query
 • from_user (telebot.types.User) – Sender
 • query (str) – Text of the query (up to 256 characters)
 • offset (str) – Offset of the results to be returned, can be controlled by the bot
 • chat_type (str) – 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”, “super-
 group”, 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
 • location (telebot.types.Location) – Optional. Sender location, only for bots that
 request user location
 Returns
 Instance of the class
 Return type
 telebot.types.InlineQuery
44 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 45
pyTelegramBotAPI, Release 4.25.0
class telebot.types.InlineQueryResultAudio(id: str, audio_url: str, title: str, caption: str | None = None,
 caption_entities: List[MessageEntity] | None = None,
 parse_mode: str | None = None, performer: str | None =
 None, audio_duration: int | None = None, reply_markup:
 InlineKeyboardMarkup | None = None,
 input_message_content: InputTextMessageContent |
 InputLocationMessageContent | InputVenueMessageContent
 | InputContactMessageContent |
 InputInvoiceMessageContent | None = None)
 Bases: InlineQueryResultBase
 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.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultaudio
 Parameters
 • type (str) – Type of the result, must be audio
 • id (str) – Unique identifier for this result, 1-64 bytes
 • audio_url (str) – A valid URL for the audio file
 • title (str) – Title
 • caption (str) – Optional. Caption, 0-1024 characters after entities parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the audio caption. See format-
 ting options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • performer (str) – Optional. Performer
 • audio_duration (int) – Optional. Audio duration in seconds
 • reply_markup (telebot.types.InlineKeyboardMarkup) – Optional. Inline keyboard
 attached to the message
 • input_message_content (telebot.types.InputMessageContent) – Optional. Con-
 tent of the message to be sent instead of the audio
 Returns
 Instance of the class
 Return type
 telebot.types.InlineQueryResultAudio
class telebot.types.InlineQueryResultBase(type: str, id: str, title: str | None = None, caption: str | None
 = None, input_message_content: InputTextMessageContent |
 InputLocationMessageContent | InputVenueMessageContent |
 InputContactMessageContent | InputInvoiceMessageContent |
 None = None, reply_markup: InlineKeyboardMarkup | None
 = None, caption_entities: List[MessageEntity] | None =
 None, parse_mode: str | None = None)
 Bases: ABC, Dictionaryable, JsonSerializable
 This object represents one result of an inline query. Telegram clients currently support results of the following
 20 types:
 • InlineQueryResultCachedAudio
46 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • InlineQueryResultCachedDocument
 • InlineQueryResultCachedGif
 • InlineQueryResultCachedMpeg4Gif
 • InlineQueryResultCachedPhoto
 • InlineQueryResultCachedSticker
 • InlineQueryResultCachedVideo
 • InlineQueryResultCachedVoice
 • InlineQueryResultArticle
 • InlineQueryResultAudio
 • InlineQueryResultContact
 • InlineQueryResultGame
 • InlineQueryResultDocument
 • InlineQueryResultGif
 • InlineQueryResultLocation
 • InlineQueryResultMpeg4Gif
 • InlineQueryResultPhoto
 • InlineQueryResultVenue
 • InlineQueryResultVideo
 • InlineQueryResultVoice
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresult
class telebot.types.InlineQueryResultCachedAudio(id: str, audio_file_id: str, caption: str | None =
 None, caption_entities: List[MessageEntity] | None
 = None, parse_mode: str | None = None,
 reply_markup: InlineKeyboardMarkup | None =
 None, input_message_content:
 InputTextMessageContent |
 InputLocationMessageContent |
 InputVenueMessageContent |
 InputContactMessageContent |
 InputInvoiceMessageContent | None = None)
 Bases: InlineQueryResultCachedBase
 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.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedaudio
 Parameters
 • type (str) – Type of the result, must be audio
 • id (str) – Unique identifier for this result, 1-64 bytes
 • audio_file_id (str) – A valid file identifier for the audio file
 • caption (str) – Optional. Caption, 0-1024 characters after entities parsing
1.3. Content 47
pyTelegramBotAPI, Release 4.25.0
 • parse_mode (str) – Optional. Mode for parsing entities in the audio caption. See format-
 ting options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • reply_markup (telebot.types.InlineKeyboardMarkup) – Optional. Inline keyboard
 attached to the message
 • input_message_content (telebot.types.InputMessageContent) – Optional. Con-
 tent of the message to be sent instead of the audio
 Returns
 Instance of the class
 Return type
 telebot.types.InlineQueryResultCachedAudio
class telebot.types.InlineQueryResultCachedBase
 Bases: ABC, JsonSerializable
 Base class of all InlineQueryResultCached* classes.
class telebot.types.InlineQueryResultCachedDocument(id: str, document_file_id: str, title: str,
 description: str | None = None, caption: str |
 None = None, caption_entities:
 List[MessageEntity] | None = None,
 parse_mode: str | None = None, reply_markup:
 InlineKeyboardMarkup | None = None,
 input_message_content:
 InputTextMessageContent |
 InputLocationMessageContent |
 InputVenueMessageContent |
 InputContactMessageContent |
 InputInvoiceMessageContent | None = None)
 Bases: InlineQueryResultCachedBase
 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.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcacheddocument
 Parameters
 • type (str) – Type of the result, must be document
 • id (str) – Unique identifier for this result, 1-64 bytes
 • title (str) – Title for the result
 • document_file_id (str) – A valid file identifier for the file
 • description (str) – Optional. Short description of the result
 • caption (str) – Optional. Caption of the document to be sent, 0-1024 characters after
 entities parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the document caption. See
 formatting options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
48 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 49
pyTelegramBotAPI, Release 4.25.0
 Return type
 telebot.types.InlineQueryResultCachedGif
class telebot.types.InlineQueryResultCachedMpeg4Gif(id: str, mpeg4_file_id: str, title: str | None =
 None, description: str | None = None, caption:
 str | None = None, caption_entities:
 List[MessageEntity] | None = None,
 parse_mode: str | None = None, reply_markup:
 InlineKeyboardMarkup | None = None,
 input_message_content:
 InputTextMessageContent |
 InputLocationMessageContent |
 InputVenueMessageContent |
 InputContactMessageContent |
 InputInvoiceMessageContent | None = None,
 show_caption_above_media: bool | None =
 None)
 Bases: InlineQueryResultCachedBase
 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.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif
 Parameters
 • type (str) – Type of the result, must be mpeg4_gif
 • id (str) – Unique identifier for this result, 1-64 bytes
 • mpeg4_file_id (str) – A valid file identifier for the MPEG4 file
 • title (str) – Optional. Title for the result
 • caption (str) – Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after
 entities parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the caption. See formatting
 options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • reply_markup (telebot.types.InlineKeyboardMarkup) – Optional. Inline keyboard
 attached to the message
 • input_message_content (telebot.types.InputMessageContent) – Optional. Con-
 tent of the message to be sent instead of the video animation
 • show_caption_above_media (bool) – Optional. Pass True, if caption should be shown
 above the media
 Returns
 Instance of the class
 Return type
 telebot.types.InlineQueryResultCachedMpeg4Gif
50 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 51
pyTelegramBotAPI, Release 4.25.0
52 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 53
pyTelegramBotAPI, Release 4.25.0
54 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 55
pyTelegramBotAPI, Release 4.25.0
 Returns
 Instance of the class
 Return type
 telebot.types.InlineQueryResultDocument
 property thumb_height: int
56 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 57
pyTelegramBotAPI, Release 4.25.0
58 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Bases: InlineQueryResultBase
 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.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
 Parameters
 • type (str) – Type of the result, must be mpeg4_gif
 • id (str) – Unique identifier for this result, 1-64 bytes
 • mpeg4_url (str) – A valid URL for the MPEG4 file. File size must not exceed 1MB
 • mpeg4_width (int) – Optional. Video width
 • mpeg4_height (int) – Optional. Video height
 • mpeg4_duration (int) – Optional. Video duration in seconds
 • thumbnail_url (str) – URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail
 for the result
 • thumbnail_mime_type (str) – Optional. MIME type of the thumbnail, must be one of
 “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
 • title (str) – Optional. Title for the result
 • caption (str) – Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after
 entities parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the caption. See formatting
 options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • reply_markup (telebot.types.InlineKeyboardMarkup) – Optional. Inline keyboard
 attached to the message
 • input_message_content (telebot.types.InputMessageContent) – Optional. Con-
 tent of the message to be sent instead of the video animation
 • show_caption_above_media (bool) – Optional. If true, a caption is shown over the photo
 or video
 Returns
 Instance of the class
 Return type
 telebot.types.InlineQueryResultMpeg4Gif
 property thumb_mime_type: str
1.3. Content 59
pyTelegramBotAPI, Release 4.25.0
60 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
class telebot.types.InlineQueryResultVenue(id: str, title: str, latitude: float, longitude: float, address:
 str, foursquare_id: str | None = None, foursquare_type: str |
 None = None, google_place_id: str | None = None,
 google_place_type: str | None = None, reply_markup:
 InlineKeyboardMarkup | None = None,
 input_message_content: InputTextMessageContent |
 InputLocationMessageContent | InputVenueMessageContent
 | InputContactMessageContent |
 InputInvoiceMessageContent | None = None, thumbnail_url:
 str | None = None, thumbnail_width: int | None = None,
 thumbnail_height: int | None = None)
 Bases: InlineQueryResultBase
 Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use in-
 put_message_content to send a message with the specified content instead of the venue.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultvenue
 Parameters
 • type (str) – Type of the result, must be venue
 • id (str) – Unique identifier for this result, 1-64 Bytes
 • latitude (float) – Latitude of the venue location in degrees
 • longitude (float) – Longitude of the venue location in degrees
 • title (str) – Title of the venue
 • address (str) – Address of the venue
 • foursquare_id (str) – Optional. Foursquare identifier of the venue if known
 • foursquare_type (str) – Optional. Foursquare type of the venue, if known. (For example,
 “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
 • google_place_id (str) – Optional. Google Places identifier of the venue
 • google_place_type (str) – Optional. Google Places type of the venue. (See supported
 types.)
 • reply_markup (telebot.types.InlineKeyboardMarkup) – Optional. Inline keyboard
 attached to the message
 • input_message_content (telebot.types.InputMessageContent) – Optional. Con-
 tent of the message to be sent instead of the venue
 • thumbnail_url (str) – Optional. Url of the thumbnail for the result
 • thumbnail_width (int) – Optional. Thumbnail width
 • thumbnail_height (int) – Optional. Thumbnail height
 Returns
 Instance of the class
 Return type
 telebot.types.InlineQueryResultVenue
 property thumb_height: int
1.3. Content 61
pyTelegramBotAPI, Release 4.25.0
62 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Return type
 telebot.types.InlineQueryResultVideo
 property thumb_url: str
class telebot.types.InlineQueryResultVoice(id: str, voice_url: str, title: str, caption: str | None = None,
 caption_entities: List[MessageEntity] | None = None,
 parse_mode: str | None = None, voice_duration: int | None
 = None, reply_markup: InlineKeyboardMarkup | None =
 None, input_message_content: InputTextMessageContent |
 InputLocationMessageContent | InputVenueMessageContent
 | InputContactMessageContent |
 InputInvoiceMessageContent | None = None)
 Bases: InlineQueryResultBase
 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.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultvoice
 Parameters
 • type (str) – Type of the result, must be voice
 • id (str) – Unique identifier for this result, 1-64 bytes
 • voice_url (str) – A valid URL for the voice recording
 • title (str) – Recording title
 • caption (str) – Optional. Caption, 0-1024 characters after entities parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the voice message caption. See
 formatting options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • voice_duration (int) – Optional. Recording duration in seconds
 • reply_markup (telebot.types.InlineKeyboardMarkup) – Optional. Inline keyboard
 attached to the message
 • input_message_content (telebot.types.InputMessageContent) – Optional. Con-
 tent of the message to be sent instead of the voice recording
 Returns
 Instance of the class
 Return type
 telebot.types.InlineQueryResultVoice
class telebot.types.InlineQueryResultsButton(text: str, web_app: WebAppInfo | None = None,
 start_parameter: str | None = None)
 Bases: JsonSerializable, Dictionaryable
 This object represents a button to be shown above inline query results. You must use exactly one of the optional
 fields.
 Telegram documentation: https://core.telegram.org/bots/api#inlinequeryresultsbutton
 Parameters
1.3. Content 63
pyTelegramBotAPI, Release 4.25.0
64 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 65
pyTelegramBotAPI, Release 4.25.0
66 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Represents the content of a location message to be sent as the result of an inline query.
 Telegram Documentation: https://core.telegram.org/bots/api#inputlocationmessagecontent
 Parameters
 • latitude (float) – Latitude of the location in degrees
 • longitude (float) – Longitude of the location in degrees
 • horizontal_accuracy (float number) – Optional. The radius of uncertainty for the lo-
 cation, measured in meters; 0-1500
 • live_period (int) – Optional. Period in seconds during which the location can be up-
 dated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited
 indefinitely.
 • heading (int) – Optional. For live locations, a direction in which the user is moving, in
 degrees. Must be between 1 and 360 if specified.
 • proximity_alert_radius (int) – Optional. For live locations, a maximum distance for
 proximity alerts about approaching another chat member, in meters. Must be between 1 and
 100000 if specified.
 Returns
 Instance of the class
 Return type
 telebot.types.InputLocationMessageContent
class telebot.types.InputMedia(type, media, caption=None, parse_mode=None, caption_entities=None)
 Bases: Dictionaryable, JsonSerializable
 This object represents the content of a media message to be sent. It should be one of
 • InputMediaAnimation
 • InputMediaDocument
 • InputMediaAudio
 • InputMediaPhoto
 • InputMediaVideo
class telebot.types.InputMediaAnimation(media: str | InputFile, thumbnail: str | InputFile | None = None,
 caption: str | None = None, parse_mode: str | None = None,
 caption_entities: List[MessageEntity] | None = None, width: int
 | None = None, height: int | None = None, duration: int | None =
 None, has_spoiler: bool | None = None,
 show_caption_above_media: bool | None = None)
 Bases: InputMedia
 Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.
 Telegram Documentation: https://core.telegram.org/bots/api#inputmediaanimation
 Parameters
 • media (str) – 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. More information on Sending Files »
1.3. Content 67
pyTelegramBotAPI, Release 4.25.0
 • thumbnail (InputFile or str) – 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>. More
 information on Sending Files »
 • caption (str) – Optional. Caption of the animation to be sent, 0-1024 characters after
 entities parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the animation caption. See
 formatting options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • width (int) – Optional. Animation width
 • height (int) – Optional. Animation height
 • duration (int) – Optional. Animation duration in seconds
 • has_spoiler (bool) – Optional. True, if the uploaded animation is a spoiler
 • show_caption_above_media (bool) – Optional. True, if the caption should be shown
 above the animation
 Returns
 Instance of the class
 Return type
 telebot.types.InputMediaAnimation
 property thumb: str | Any | None
68 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • caption (str) – Optional. Caption of the audio to be sent, 0-1024 characters after entities
 parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the audio caption. See format-
 ting options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • duration (int) – Optional. Duration of the audio in seconds
 • performer (str) – Optional. Performer of the audio
 • title (str) – Optional. Title of the audio
 Returns
 Instance of the class
 Return type
 telebot.types.InputMediaAudio
 property thumb: str | Any | None
1.3. Content 69
pyTelegramBotAPI, Release 4.25.0
 Return type
 telebot.types.InputMediaDocument
 property thumb: str | Any | None
class telebot.types.InputMediaPhoto(media: str | InputFile, caption: str | None = None, parse_mode: str |
 None = None, caption_entities: List[MessageEntity] | None = None,
 has_spoiler: bool | None = None, show_caption_above_media: bool |
 None = None)
 Bases: InputMedia
 Represents a photo to be sent.
 Telegram Documentation: https://core.telegram.org/bots/api#inputmediaphoto
 Parameters
 • media (str) – 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. More information on Sending Files »
 • caption (str) – Optional. Caption of the photo to be sent, 0-1024 characters after entities
 parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the photo caption. See format-
 ting options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • has_spoiler (bool) – Optional. True, if the uploaded photo is a spoiler
 • show_caption_above_media (bool) – Optional. True, if the caption should be shown
 above the photo
 Returns
 Instance of the class
 Return type
 telebot.types.InputMediaPhoto
class telebot.types.InputMediaVideo(media: str | InputFile, thumbnail: str | InputFile | None = None,
 caption: str | None = None, parse_mode: str | None = None,
 caption_entities: List[MessageEntity] | None = None, width: int |
 None = None, height: int | None = None, duration: int | None = None,
 supports_streaming: bool | None = None, has_spoiler: bool | None =
 None, show_caption_above_media: bool | None = None)
 Bases: InputMedia
 Represents a video to be sent.
 Telegram Documentation: https://core.telegram.org/bots/api#inputmediavideo
 Parameters
 • media (str) – 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. More information on Sending Files »
70 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • thumbnail (InputFile or str) – 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>. More
 information on Sending Files »
 • caption (str) – Optional. Caption of the video to be sent, 0-1024 characters after entities
 parsing
 • parse_mode (str) – Optional. Mode for parsing entities in the video caption. See format-
 ting options for more details.
 • caption_entities (list of telebot.types.MessageEntity) – Optional. List of spe-
 cial entities that appear in the caption, which can be specified instead of parse_mode
 • width (int) – Optional. Video width
 • height (int) – Optional. Video height
 • duration (int) – Optional. Video duration in seconds
 • supports_streaming (bool) – Optional. Pass True, if the uploaded video is suitable for
 streaming
 • has_spoiler (bool) – Optional. True, if the uploaded video is a spoiler
 • show_caption_above_media (bool) – Optional. True, if the caption should be shown
 above the video
 Returns
 Instance of the class
 Return type
 telebot.types.InputMediaVideo
 property thumb: str | Any | None
1.3. Content 71
pyTelegramBotAPI, Release 4.25.0
72 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
class telebot.types.InputSticker(sticker: str | InputFile, emoji_list: List[str], format: str | None = None,
 mask_position: MaskPosition | None = None, keywords: List[str] | None
 = None)
 Bases: Dictionaryable, JsonSerializable
 This object describes a sticker to be added to a sticker set.
 Parameters
 • sticker (str or telebot.types.InputFile) – The added sticker. Pass a file_id as a
 String to send a file that already exists on the Telegram servers, pass an HTTP URL as a
 String for Telegram to get a file from the Internet, or upload a new one using multipart/form-
 data. Animated and video stickers can’t be uploaded via HTTP URL.
 • emoji_list (list of str) – One or more(up to 20) emoji(s) corresponding to the sticker
 • mask_position (telebot.types.MaskPosition) – Optional. Position where the mask
 should be placed on faces. For “mask” stickers only.
 • keywords (list of str) – Optional. List of 0-20 search keywords for the sticker with total
 length of up to 64 characters. For “regular” and “custom_emoji” stickers only.
 • format (str) – Format of the added sticker, must be one of “static” for a .WEBP or .PNG
 image, “animated” for a .TGS animation, “video” for a WEBM video
 Returns
 Instance of the class
 Return type
 telebot.types.InputSticker
 convert_input_sticker() → Tuple[str, dict | None]
1.3. Content 73
pyTelegramBotAPI, Release 4.25.0
74 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 75
pyTelegramBotAPI, Release 4.25.0
76 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • chat_is_forum (bool) – Optional. Pass True to request a forum supergroup, pass False to
 request a non-forum chat. If not specified, no additional restrictions are applied.
 • chat_has_username (bool) – Optional. Pass True to request a supergroup or a channel
 with a username, pass False to request a chat without a username. If not specified, no addi-
 tional restrictions are applied.
 • chat_is_created (bool) – Optional. Pass True to request a chat owned by the user. Oth-
 erwise, no additional restrictions are applied.
 • user_administrator_rights (telebot.types.ChatAdministratorRights) – Op-
 tional. A JSON-serialized object listing the required administrator rights of the user in the
 chat. The rights must be a superset of bot_administrator_rights. If not specified, no addi-
 tional restrictions are applied.
 • bot_administrator_rights (telebot.types.ChatAdministratorRights) – Op-
 tional. A JSON-serialized object listing the required administrator rights of the bot in the
 chat. The rights must be a subset of user_administrator_rights. If not specified, no additional
 restrictions are applied.
 • bot_is_member (bool) – Optional. Pass True to request a chat where the bot is a member.
 Otherwise, no additional restrictions are applied.
 • request_title (bool) – Optional. Request title
 • request_photo (bool) – Optional. Request photo
 • request_username (bool) – Optional. Request username
 Returns
 Instance of the class
 Return type
 telebot.types.KeyboardButtonRequestChat
class telebot.types.KeyboardButtonRequestUser(request_id: int, user_is_bot: bool | None = None,
 user_is_premium: bool | None = None, max_quantity:
 int | None = None)
 Bases: KeyboardButtonRequestUsers
 Deprecated. Use KeyboardButtonRequestUsers instead.
class telebot.types.KeyboardButtonRequestUsers(request_id: int, user_is_bot: bool | None = None,
 user_is_premium: bool | None = None, max_quantity:
 int | None = None, request_name: bool | None = None,
 request_username: bool | None = None, request_photo:
 bool | None = None)
 Bases: Dictionaryable
 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.
 Telegram documentation: https://core.telegram.org/bots/api#keyboardbuttonrequestusers
 Parameters
 • request_id (int) – Signed 32-bit identifier of the request, which will be received back in
 the UsersShared object. Must be unique within the message
 • user_is_bot (bool) – Optional. Pass True to request a bot, pass False to request a regular
 user. If not specified, no additional restrictions are applied.
1.3. Content 77
pyTelegramBotAPI, Release 4.25.0
 • user_is_premium (bool) – Optional. Pass True to request a premium user, pass False to
 request a non-premium user. If not specified, no additional restrictions are applied.
 • max_quantity (int) – Optional. The maximum number of users to be selected; 1-10.
 Defaults to 1.
 • request_name (bool) – Optional. Request name
 • request_username (bool) – Optional. Request username
 • request_photo (bool) – Optional. Request photo
 Returns
 Instance of the class
 Return type
 telebot.types.KeyboardButtonRequestUsers
class telebot.types.LabeledPrice(label, amount)
 Bases: JsonSerializable, Dictionaryable
 This object represents a portion of the price for goods or services.
 Telegram Documentation: https://core.telegram.org/bots/api#labeledprice
 Parameters
 • label (str) – Portion label
 • amount (int) – Price of the product 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 pa-
 rameter in currencies.json, it shows the number of digits past the decimal point for each
 currency (2 for the majority of currencies).
 Returns
 Instance of the class
 Return type
 telebot.types.LabeledPrice
class telebot.types.LinkPreviewOptions(is_disabled: bool | None = None, url: str | None = None,
 prefer_small_media: bool | None = None, prefer_large_media:
 bool | None = None, show_above_text: bool | None = None,
 **kwargs)
 Bases: JsonDeserializable, Dictionaryable, JsonSerializable
 Describes the options used for link preview generation.
 Telegram documentation: https://core.telegram.org/bots/api#linkpreviewoptions
 Parameters
 • is_disabled (bool) – Optional. True, if the link preview is disabled
 • url (str) – Optional. URL to use for the link preview. If empty, then the first URL found
 in the message text will be used
 • prefer_small_media (bool) – Optional. True, if the media in the link preview is supposed
 to be shrunk; ignored if the URL isn’t explicitly specified or media size change isn’t supported
 for the preview
 • prefer_large_media (bool) – Optional. True, if the media in the link preview is sup-
 posed to be enlarged; ignored if the URL isn’t explicitly specified or media size change isn’t
 supported for the preview
78 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • show_above_text (bool) – Optional. True, if the link preview must be shown above the
 message text; otherwise, the link preview will be shown below the message text
 Returns
 Instance of the class
 Return type
 LinkPreviewOptions
class telebot.types.Location(longitude, latitude, horizontal_accuracy=None, live_period=None,
 heading=None, proximity_alert_radius=None, **kwargs)
 Bases: JsonDeserializable, JsonSerializable, Dictionaryable
 This object represents a point on the map.
 Telegram Documentation: https://core.telegram.org/bots/api#location
 Parameters
 • longitude (float) – Longitude as defined by sender
 • latitude (float) – Latitude as defined by sender
 • horizontal_accuracy (float number) – Optional. The radius of uncertainty for the lo-
 cation, measured in meters; 0-1500
 • live_period (int) – Optional. Time relative to the message sending date, during which
 the location can be updated; in seconds. For active live locations only.
 • heading (int) – Optional. The direction in which user is moving, in degrees; 1-360. For
 active live locations only.
 • proximity_alert_radius (int) – Optional. The maximum distance for proximity alerts
 about approaching another chat member, in meters. For sent live locations only.
 Returns
 Instance of the class
 Return type
 telebot.types.Location
class telebot.types.LoginUrl(url: str, forward_text: str | None = None, bot_username: str | None = None,
 request_write_access: bool | None = None, **kwargs)
 Bases: Dictionaryable, JsonSerializable, JsonDeserializable
 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:
 Telegram Documentation: https://core.telegram.org/bots/api#loginurl
 Parameters
 • url (str) – An HTTPS URL to be opened with user authorization data added to the query
 string when the button is pressed. If the user refuses to provide authorization data, the orig-
 inal URL without information about the user will be opened. The data added is the same
 as described in Receiving authorization data. NOTE: You must always check the hash of
 the received data to verify the authentication and the integrity of the data as described in
 Checking authorization.
 • forward_text (str) – Optional. New text of the button in forwarded messages.
1.3. Content 79
pyTelegramBotAPI, Release 4.25.0
 • bot_username (str) – Optional. Username of a bot, which will be used for user autho-
 rization. See Setting up a bot for more details. If not specified, the current bot’s username
 will be assumed. The url’s domain must be the same as the domain linked with the bot. See
 Linking your domain to the bot for more details.
 • request_write_access (bool) – Optional. Pass True to request the permission for your
 bot to send messages to the user.
 Returns
 Instance of the class
 Return type
 telebot.types.LoginUrl
class telebot.types.MaskPosition(point, x_shift, y_shift, scale, **kwargs)
 Bases: Dictionaryable, JsonDeserializable, JsonSerializable
 This object describes the position on faces where a mask should be placed by default.
 Telegram Documentation: https://core.telegram.org/bots/api#maskposition
 Parameters
 • point (str) – The part of the face relative to which the mask should be placed. One of
 “forehead”, “eyes”, “mouth”, or “chin”.
 • x_shift (float number) – Shift by X-axis measured in widths of the mask scaled to the
 face size, from left to right. For example, choosing -1.0 will place mask just to the left of the
 default mask position.
 • y_shift (float number) – Shift by Y-axis measured in heights of the mask scaled to the
 face size, from top to bottom. For example, 1.0 will place the mask just below the default
 mask position.
 • scale (float number) – Mask scaling coefficient. For example, 2.0 means double size.
 Returns
 Instance of the class
 Return type
 telebot.types.MaskPosition
class telebot.types.MenuButton
 Bases: JsonDeserializable, JsonSerializable, Dictionaryable
 This object describes the bot’s menu button in a private chat. It should be one of
 • MenuButtonCommands
 • MenuButtonWebApp
 • MenuButtonDefault
 If a menu button other than MenuButtonDefault is set for a private chat, then it is applied in the chat. Otherwise
 the default menu button is applied. By default, the menu button opens the list of bot commands.
class telebot.types.MenuButtonCommands(type: str = None, **kwargs)
 Bases: MenuButton
 Represents a menu button, which opens the bot’s list of commands.
 Telegram Documentation: https://core.telegram.org/bots/api#menubuttoncommands
 Parameters
 type (str) – Type of the button, must be commands
80 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Returns
 Instance of the class
 Return type
 telebot.types.MenuButtonCommands
class telebot.types.MenuButtonDefault(type: str = None, **kwargs)
 Bases: MenuButton
 Describes that no specific value for the menu button was set.
 Telegram Documentation: https://core.telegram.org/bots/api#menubuttondefault
 Parameters
 type (str) – Type of the button, must be default
 Returns
 Instance of the class
 Return type
 telebot.types.MenuButtonDefault
class telebot.types.MenuButtonWebApp(type: str, text: str, web_app: WebAppInfo, **kwargs)
 Bases: MenuButton
 Represents a menu button, which launches a Web App.
 Telegram Documentation: https://core.telegram.org/bots/api#menubuttonwebapp
 Parameters
 • type (str) – Type of the button, must be web_app
 • text (str) – Text on the button
 • web_app (telebot.types.WebAppInfo) – 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. Alternatively, a t.me
 link to a Web App of the bot can be specified in the object instead of the Web App’s URL,
 in which case the Web App will be opened as if the user pressed the link.
 Returns
 Instance of the class
 Return type
 telebot.types.MenuButtonWebApp
class telebot.types.Message(message_id, from_user, date, chat, content_type, options, json_string)
 Bases: JsonDeserializable
 This object represents a message.
 Telegram Documentation: https://core.telegram.org/bots/api#message
 Parameters
 • message_id (int) – Unique message identifier inside this chat
 • message_thread_id (int) – Optional. Unique identifier of a message thread to which the
 message belongs; for supergroups only
 • from_user (telebot.types.User) – Optional. Sender of the message; empty for mes-
 sages 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.
1.3. Content 81
pyTelegramBotAPI, Release 4.25.0
82 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 • effect_id (str) – Optional. Unique identifier of the message effect added to the message
 • animation (telebot.types.Animation) – Optional. Message is an animation, informa-
 tion about the animation. For backward compatibility, when this field is set, the document
 field will also be set
 • audio (telebot.types.Audio) – Optional. Message is an audio file, information about
 the file
 • document (telebot.types.Document) – Optional. Message is a general file, information
 about the file
 • paid_media (telebot.types.PaidMediaInfo) – Optional. Message contains paid me-
 dia; information about the paid media
 • photo (list of telebot.types.PhotoSize) – Optional. Message is a photo, available
 sizes of the photo
 • sticker (telebot.types.Sticker) – Optional. Message is a sticker, information about
 the sticker
 • story (telebot.types.Story) – Optional. Message is a forwarded story
 • video (telebot.types.Video) – Optional. Message is a video, information about the
 video
 • video_note (telebot.types.VideoNote) – Optional. Message is a video note, informa-
 tion about the video message
 • voice (telebot.types.Voice) – Optional. Message is a voice message, information
 about the file
 • caption (str) – Optional. Caption for the animation, audio, document, photo, video or
 voice
 • caption_entities (list of telebot.types.MessageEntity) – Optional. For mes-
 sages with a caption, special entities like usernames, URLs, bot commands, etc. that appear
 in the caption
 • show_caption_above_media (bool) – Optional. True, if the caption must be shown above
 the message media
 • has_media_spoiler (bool) – Optional. True, if the message media is covered by a spoiler
 animation
 • contact (telebot.types.Contact) – Optional. Message is a shared contact, information
 about the contact
 • dice (telebot.types.Dice) – Optional. Message is a dice with random value
 • game (telebot.types.Game) – Optional. Message is a game, information about the game.
 More about games »
 • poll (telebot.types.Poll) – Optional. Message is a native poll, information about the
 poll
 • venue (telebot.types.Venue) – Optional. Message is a venue, information about the
 venue. For backward compatibility, when this field is set, the location field will also be set
 • location (telebot.types.Location) – Optional. Message is a shared location, infor-
 mation about the location
1.3. Content 83
pyTelegramBotAPI, Release 4.25.0
84 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 85
pyTelegramBotAPI, Release 4.25.0
property forward_date
property forward_from
property forward_from_chat
property forward_from_message_id
property forward_sender_name
property forward_signature
property voice_chat_ended
property voice_chat_participants_invited
property voice_chat_scheduled
property voice_chat_started
86 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 87
pyTelegramBotAPI, Release 4.25.0
88 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 89
pyTelegramBotAPI, Release 4.25.0
 • old_reaction (list of ReactionType) – Previous list of reaction types that were set by
 the user
 • new_reaction (list of ReactionType) – New list of reaction types that have been set by
 the user
 Returns
 Instance of the class
 Return type
 MessageReactionUpdated
class telebot.types.OrderInfo(name=None, phone_number=None, email=None, shipping_address=None,
 **kwargs)
 Bases: JsonDeserializable
 This object represents information about an order.
 Telegram Documentation: https://core.telegram.org/bots/api#orderinfo
 Parameters
 • name (str) – Optional. User name
 • phone_number (str) – Optional. User’s phone number
 • email (str) – Optional. User email
 • shipping_address (telebot.types.ShippingAddress) – Optional. User shipping ad-
 dress
 Returns
 Instance of the class
 Return type
 telebot.types.OrderInfo
class telebot.types.PaidMedia
 Bases: JsonDeserializable
 This object describes paid media. Currently, it can be one of
 PaidMediaPreview PaidMediaPhoto PaidMediaVideo
 Telegram documentation: https://core.telegram.org/bots/api#paidmedia
 Returns
 Instance of the class
 Return type
 PaidMediaPreview or PaidMediaPhoto or PaidMediaVideo
class telebot.types.PaidMediaInfo(star_count, paid_media, **kwargs)
 Bases: JsonDeserializable
 Describes the paid media added to a message.
 Telegram documentation: https://core.telegram.org/bots/api#paidmediainfo
 Parameters
 • star_count (int) – The number of Telegram Stars that must be paid to buy access to the
 media
 • paid_media (list of PaidMedia) – Information about the paid media
90 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Returns
 Instance of the class
 Return type
 PaidMediaInfo
class telebot.types.PaidMediaPhoto(type, photo, **kwargs)
 Bases: PaidMedia
 The paid media is a photo.
 Telegram documentation: https://core.telegram.org/bots/api#paidmediaphoto
 Parameters
 • type (str) – Type of the paid media, always “photo”
 • photo (list of PhotoSize) – The photo
 Returns
 Instance of the class
 Return type
 PaidMediaPhoto
class telebot.types.PaidMediaPreview(type, width=None, height=None, duration=None, **kwargs)
 Bases: PaidMedia
 The paid media isn’t available before the payment.
 Telegram documentation: https://core.telegram.org/bots/api#paidmediapreview
 Parameters
 • type (str) – Type of the paid media, always “preview”
 • width (int) – Optional. Media width as defined by the sender
 • height (int) – Optional. Media height as defined by the sender
 • duration (int) – Optional. Duration of the media in seconds as defined by the sender
 Returns
 Instance of the class
 Return type
 PaidMediaPreview
class telebot.types.PaidMediaPurchased(from_user, paid_media_payload, **kwargs)
 Bases: JsonDeserializable
 This object contains information about a paid media purchase.
 Telegram documentation: https://core.telegram.org/bots/api#paidmediapurchased
 Parameters
 • from_user (User) – User who purchased the media
 • paid_media_payload (str) – Bot-specified paid media payload
 Returns
 Instance of the class
 Return type
 PaidMediaPurchased
1.3. Content 91
pyTelegramBotAPI, Release 4.25.0
92 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 93
pyTelegramBotAPI, Release 4.25.0
94 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 95
pyTelegramBotAPI, Release 4.25.0
 Return type
 ReactionType
class telebot.types.ReactionTypeCustomEmoji(custom_emoji_id: str, **kwargs)
 Bases: ReactionType
 This object represents a custom emoji reaction type.
 Telegram documentation: https://core.telegram.org/bots/api#reactiontypecustomemoji
 Parameters
 • type (str) – Type of the reaction, must be custom_emoji
 • custom_emoji_id (str) – Identifier of the custom emoji
 Returns
 Instance of the class
 Return type
 ReactionTypeCustomEmoji
class telebot.types.ReactionTypeEmoji(emoji: str, **kwargs)
 Bases: ReactionType
 This object represents an emoji reaction type.
 Telegram documentation: https://core.telegram.org/bots/api#reactiontypeemoji
 Parameters
 • type (str) – Type of the reaction, must be emoji
 • emoji (str) – Reaction emoji. List is available on the API doc.
 Returns
 Instance of the class
 Return type
 ReactionTypeEmoji
class telebot.types.ReactionTypePaid(**kwargs)
 Bases: ReactionType
 This object represents a paid reaction type.
 Telegram documentation: https://core.telegram.org/bots/api#reactiontypepaid
 Parameters
 type (str) – Type of the reaction, must be paid
 Returns
 Instance of the class
 Return type
 ReactionTypePaid
class telebot.types.RefundedPayment(currency, total_amount, invoice_payload,
 telegram_payment_charge_id, provider_payment_charge_id=None,
 **kwargs)
 Bases: JsonDeserializable
 This object contains basic information about a refunded payment.
 Telegram documentation: https://core.telegram.org/bots/api#refundedpayment
96 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
 Parameters
 • currency (str) – Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram
 Stars. Currently, always “XTR”
 • total_amount (int) – Total refunded price in the smallest units of the currency (integer,
 not float/double). For example, for a price of US$ 1.45, total_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).
 • invoice_payload (str) – Bot-specified invoice payload
 • telegram_payment_charge_id (str) – Telegram payment identifier
 • provider_payment_charge_id (str) – Optional. Provider payment identifier
 Returns
 Instance of the class
 Return type
 RefundedPayment
class telebot.types.ReplyKeyboardMarkup(resize_keyboard: bool | None = None, one_time_keyboard: bool
 | None = None, selective: bool | None = None, row_width: int =
 3, input_field_placeholder: str | None = None, is_persistent:
 bool | None = None)
 Bases: JsonSerializable
 This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
 markup = ReplyKeyboardMarkup(resize_keyboard=True)
 markup.add(KeyboardButton('Text'))
 # or:
 markup.add('Text')
1.3. Content 97
pyTelegramBotAPI, Release 4.25.0
 • selective (bool) – 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 to a message in the same chat and forum topic, 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.
 • is_persistent – 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.
 Returns
 Instance of the class
 Return type
 telebot.types.ReplyKeyboardMarkup
 add(*args, row_width=None) → ReplyKeyboardMarkup
 This function adds strings to the keyboard, while not exceeding row_width. E.g. ReplyKeyboard-
 Markup#add(“A”, “B”, “C”) yields the json result {keyboard: [[“A”], [“B”], [“C”]]} when row_width is
 set to 1. When row_width is set to 2, the following is the result of this function: {keyboard: [[“A”, “B”],
 [“C”]]} See https://core.telegram.org/bots/api#replykeyboardmarkup
 Parameters
 • args (str or telebot.types.KeyboardButton) – KeyboardButton to append to the
 keyboard
 • row_width (int) – width of row
 Returns
 self, to allow function chaining.
 Return type
 telebot.types.ReplyKeyboardMarkup
 max_row_keys = 12
 row(*args) → ReplyKeyboardMarkup
 Adds a list of KeyboardButton to the keyboard. This function does not consider row_width. ReplyKey-
 boardMarkup#row(“A”)#row(“B”, “C”)#to_json() outputs ‘{keyboard: [[“A”], [“B”, “C”]]}’ See https:
 //core.telegram.org/bots/api#replykeyboardmarkup
 Parameters
 args (str) – strings
 Returns
 self, to allow function chaining.
 Return type
 telebot.types.ReplyKeyboardMarkup
class telebot.types.ReplyKeyboardRemove(selective: bool | None = None)
 Bases: JsonSerializable
 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).
98 Chapter 1. TeleBot
 pyTelegramBotAPI, Release 4.25.0
1.3. Content 99
pyTelegramBotAPI, Release 4.25.0
 Return type
 ReplyParameters
class telebot.types.RevenueWithdrawalState
 Bases: JsonDeserializable
 This object describes the state of a revenue withdrawal operation. Currently, it can be one of
 RevenueWithdrawalStatePending RevenueWithdrawalStateSucceeded RevenueWithdrawalStateFailed
 Telegram documentation: https://core.telegram.org/bots/api#revenuewithdrawalstate
 Parameters
 type (str) – Type of the state, always “pending” or “succeeded” or “failed”
 Returns
 Instance of the class
 Return type
 RevenueWithdrawalStatePending or RevenueWithdrawalStateSucceeded or
 RevenueWithdrawalStateFailed
class telebot.types.RevenueWithdrawalStateFailed(type, **kwargs)
 Bases: RevenueWithdrawalState
 The withdrawal failed and the transaction was refunded.
 Telegram documentation: https://core.telegram.org/bots/api#revenuewithdrawalstatefailed
 Parameters
 type (str) – Type of the state, always “failed”
 Returns
 Instance of the class
 Return type
 RevenueWithdrawalStateFailed
class telebot.types.RevenueWithdrawalStatePending(type, **kwargs)
 Bases: RevenueWithdrawalState
 The withdrawal is in progress.
 Telegram documentation: https://core.telegram.org/bots/api#revenuewithdrawalstatepending
 Parameters
 type (str) – Type of the state, always “pending”
 Returns
 Instance of the class
 Return type
 RevenueWithdrawalStatePending
class telebot.types.RevenueWithdrawalStateSucceeded(type, date, url, **kwargs)
 Bases: RevenueWithdrawalState
 The withdrawal succeeded.
 Telegram documentation: https://core.telegram.org/bots/api#revenuewithdrawalstatesucceeded
 Parameters
 • type (str) – Type of the state, always “succeeded”
 • date (int) – Date the withdrawal was completed in Unix time
 • url (str) – An HTTPS URL that can be used to see transaction details
 Returns
 Instance of the class
 Return type
 RevenueWithdrawalStateSucceeded
class telebot.types.SentWebAppMessage(inline_message_id=None, **kwargs)
 Bases: JsonDeserializable, Dictionaryable
 Describes an inline message sent by a Web App on behalf of a user.
 Telegram Documentation: https://core.telegram.org/bots/api#sentwebappmessage
 Parameters
 inline_message_id (str) – Optional. Identifier of the sent inline message. Available only if
 there is an inline keyboard attached to the message.
 Returns
 Instance of the class
 Return type
 telebot.types.SentWebAppMessage
class telebot.types.SharedUser(user_id, first_name=None, last_name=None, username=None,
 photo=None, **kwargs)
 Bases: JsonDeserializable
 This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUser
 button.
 Telegram documentation: https://core.telegram.org/bots/api#shareduser
 Parameters
 • user_id (int) – Identifier of the shared user. This number may have more than 32 signifi-
 cant bits and some programming languages may have difficulty/silent defects in interpreting
 it. But it has at most 52 significant bits, so 64-bit integers or double-precision float types are
 safe for storing these identifiers. The bot may not have access to the user and could be unable
 to use this identifier, unless the user is already known to the bot by some other means.
 • first_name (str) – Optional. First name of the user, if the name was requested by the bot
 • last_name (str) – Optional. Last name of the user, if the name was requested by the bot
 • username (str) – Optional. Username of the user, if the username was requested by the bot
 • photo (list of PhotoSize) – Optional. Available sizes of the chat photo, if the photo was
 requested by the bot
 Returns
 Instance of the class
 Return type
 SharedUser
class telebot.types.ShippingAddress(country_code, state, city, street_line1, street_line2, post_code,
 **kwargs)
 Bases: JsonDeserializable
 This object represents a shipping address.
 Telegram Documentation: https://core.telegram.org/bots/api#shippingaddress
 Parameters
 • country_code (str) – Two-letter ISO 3166-1 alpha-2 country code
 • state (str) – State, if applicable
 • city (str) – City
 • street_line1 (str) – First line for the address
 • street_line2 (str) – Second line for the address
 • post_code (str) – Address post code
 Returns
 Instance of the class
 Return type
 telebot.types.ShippingAddress
class telebot.types.ShippingOption(id, title)
 Bases: JsonSerializable
 This object represents one shipping option.
 Telegram Documentation: https://core.telegram.org/bots/api#shippingoption
 Parameters
 • id (str) – Shipping option identifier
 • title (str) – Option title
 • prices (list of telebot.types.LabeledPrice) – List of price portions
 Returns
 Instance of the class
 Return type
 telebot.types.ShippingOption
 add_price(*args) → ShippingOption
 Add LabeledPrice to ShippingOption
 Parameters
 args (LabeledPrice) – LabeledPrices
 Returns
 None
class telebot.types.ShippingQuery(id, from_user, invoice_payload, shipping_address, **kwargs)
 Bases: JsonDeserializable
 This object contains information about an incoming shipping query.
 Telegram Documentation: https://core.telegram.org/bots/api#shippingquery
 Parameters
 • id (str) – Unique query identifier
 • from (telebot.types.User) – User who sent the query
 • invoice_payload (str) – Bot specified invoice payload
 • shipping_address (telebot.types.ShippingAddress) – User specified shipping ad-
 dress
 Returns
 Instance of the class
 Return type
 telebot.types.ShippingQuery
class telebot.types.StarTransaction(id, amount, date, source=None, receiver=None,
 nanostar_amount=None, **kwargs)
 Bases: JsonDeserializable
 Describes a Telegram Star transaction.
 Telegram documentation: https://core.telegram.org/bots/api#startransaction
 Parameters
 • id (str) – Unique identifier of the transaction. Coincides with the identifer
 of the original transaction for refund transactions. Coincides with SuccessfulPay-
 ment.telegram_payment_charge_id for successful incoming payments from users.
 • amount (int) – Number of Telegram Stars transferred by the transaction
 • nanostar_amount (int) – Optional. The number of 1/1000000000 shares of Telegram
 Stars transferred by the transaction; from 0 to 999999999
 • date (int) – Date the transaction was created in Unix time
 • source (TransactionPartner) – Optional. Source of an incoming transaction (e.g., a user
 purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming
 transactions
 • receiver (TransactionPartner) – Optional. Receiver of an outgoing transaction (e.g.,
 a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions
 Returns
 Instance of the class
 Return type
 StarTransaction
class telebot.types.StarTransactions(transactions, **kwargs)
 Bases: JsonDeserializable
 Contains a list of Telegram Star transactions.
 Telegram documentation: https://core.telegram.org/bots/api#startransactions
 Parameters
 transactions (list of StarTransaction) – The list of transactions
 Returns
 Instance of the class
 Return type
 StarTransactions
class telebot.types.Sticker(file_id, file_unique_id, type, width, height, is_animated, is_video,
 thumbnail=None, emoji=None, set_name=None, mask_position=None,
 file_size=None, premium_animation=None, custom_emoji_id=None,
 needs_repainting=None, **kwargs)
 Bases: JsonDeserializable
 This object represents a sticker.
 • is_recurring (bool) – Optional. True, if the payment is a recurring payment, false other-
 wise
 • is_first_recurring (bool) – Optional. True, if the payment is the first payment for a
 subscription
 • shipping_option_id (str) – Optional. Identifier of the shipping option chosen by the
 user
 • order_info (telebot.types.OrderInfo) – Optional. Order information provided by
 the user
 • telegram_payment_charge_id (str) – Telegram payment identifier
 • provider_payment_charge_id (str) – Provider payment identifier
 Returns
 Instance of the class
 Return type
 telebot.types.SuccessfulPayment
class telebot.types.SwitchInlineQueryChosenChat(query: str | None = None, allow_user_chats: bool |
 None = None, allow_bot_chats: bool | None = None,
 allow_group_chats: bool | None = None,
 allow_channel_chats: bool | None = None)
 Bases: JsonDeserializable, Dictionaryable, JsonSerializable
 Represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default
 inline query.
 Telegram Documentation: https://core.telegram.org/bots/api#inlinekeyboardbutton
 Parameters
 • query (str) – Optional. The default inline query to be inserted in the input field. If left
 empty, only the bot’s username will be inserted
 • allow_user_chats (bool) – Optional. True, if private chats with users can be chosen
 • allow_bot_chats (bool) – Optional. True, if private chats with bots can be chosen
 • allow_group_chats (bool) – Optional. True, if group and supergroup chats can be chosen
 • allow_channel_chats (bool) – Optional. True, if channel chats can be chosen
 Returns
 Instance of the class
 Return type
 SwitchInlineQueryChosenChat
class telebot.types.TextQuote(text: str, position: int, entities: List[MessageEntity] | None = None,
 is_manual: bool | None = None, **kwargs)
 Bases: JsonDeserializable
 This object contains information about the quoted part of a message that is replied to by the given message.
 Telegram documentation: https://core.telegram.org/bots/api#textquote
 Parameters
 • text (str) – Text of the quoted part of a message that is replied to by the given message
 • entities (list of MessageEntity) – Optional. Special entities that appear in the quote.
 Currently, only bold, italic, underline, strikethrough, spoiler, and custom_emoji entities are
 kept in quotes.
 • position (int) – Approximate quote position in the original message in UTF-16 code units
 as specified by the sender
 • is_manual (bool) – Optional. True, if the quote was chosen manually by the message
 sender. Otherwise, the quote was added automatically by the server.
 Returns
 Instance of the class
 Return type
 TextQuote
 property html_text
 Returns html-rendered text.
class telebot.types.TransactionPartner
 Bases: JsonDeserializable
 This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it
 can be one of
 TransactionPartnerFragment TransactionPartnerUser TransactionPartnerOther
 Telegram documentation: https://core.telegram.org/bots/api#transactionpartner
 Parameters
 type (str) – Type of the transaction partner
 Returns
 Instance of the class
 Return type
 TransactionPartnerFragment or TransactionPartnerUser or
 TransactionPartnerOther
class telebot.types.TransactionPartnerAffiliateProgram(type, commission_per_mille,
 sponsor_user=None, **kwargs)
 Bases: TransactionPartner
 Describes the affiliate program that issued the affiliate commission received via this transaction.
 Telegram documentation: https://core.telegram.org/bots/api#transactionpartneraffiliateprogram
 Parameters
 • type (str) – Type of the transaction partner, always “affiliate_program”
 • sponsor_user (User) – Optional. Information about the bot that sponsored the affiliate
 program
 • commission_per_mille (int) – The number of Telegram Stars received by the bot for
 each 1000 Telegram Stars received by the affiliate program sponsor from referred users
 Returns
 Instance of the class
 Return type
 TransactionPartnerAffiliateProgram
 Returns
 Instance of the class
 Return type
 TransactionPartnerTelegramApi
class telebot.types.TransactionPartnerUser(type, user, affiliate=None, invoice_payload=None,
 paid_media: List[PaidMedia] | None = None,
 subscription_period=None, gift: Gift | None = None,
 **kwargs)
 Bases: TransactionPartner
 Describes a transaction with a user.
 Telegram documentation: https://core.telegram.org/bots/api#transactionpartneruser
 Parameters
 • type (str) – Type of the transaction partner, always “user”
 • user (User) – Information about the user
 • affiliate (AffiliateInfo) – Optional. Information about the affiliate that received a
 commission via this transaction
 • invoice_payload (str) – Optional, Bot-specified invoice payload
 • subscription_period (int) – Optional. The duration of the paid subscription
 • paid_media (list of PaidMedia) – Optional. Information about the paid media bought
 by the user
 • gift (Gift) – Optional. The gift sent to the user by the bot
 Returns
 Instance of the class
 Return type
 TransactionPartnerUser
class telebot.types.Update(update_id, message, edited_message, channel_post, edited_channel_post,
 inline_query, chosen_inline_result, callback_query, shipping_query,
 pre_checkout_query, poll, poll_answer, my_chat_member, chat_member,
 chat_join_request, message_reaction, message_reaction_count,
 removed_chat_boost, chat_boost, business_connection, business_message,
 edited_business_message, deleted_business_messages, purchased_paid_media)
 Bases: JsonDeserializable
 This object represents an incoming update.At most one of the optional parameters can be present in any given
 update.
 Telegram Documentation: https://core.telegram.org/bots/api#update
 Parameters
 • update_id (int) – 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.
 • message (telebot.types.Message) – Optional. New incoming message of any kind -
 text, photo, sticker, etc.
 • has_main_web_app (bool) – Optional. True, if the bot has a main Web App. Returned
 only in getMe.
 Returns
 Instance of the class
 Return type
 telebot.types.User
 property full_name: str
 User’s full name
 Type
 return
class telebot.types.UserChatBoosts(boosts, **kwargs)
 Bases: JsonDeserializable
 This object represents a list of boosts added to a chat by a user.
 Telegram documentation: https://core.telegram.org/bots/api#userchatboosts
 Parameters
 boosts (list of ChatBoost) – The list of boosts added to the chat by the user
 Returns
 Instance of the class
 Return type
 UserChatBoosts
class telebot.types.UserProfilePhotos(total_count, photos=None, **kwargs)
 Bases: JsonDeserializable
 This object represent a user’s profile pictures.
 Telegram Documentation: https://core.telegram.org/bots/api#userprofilephotos
 Parameters
 • total_count (int) – Total number of profile pictures the target user has
 • photos (list of list of telebot.types.PhotoSize) – Requested profile pictures (in
 up to 4 sizes each)
 Returns
 Instance of the class
 Return type
 telebot.types.UserProfilePhotos
class telebot.types.UsersShared(request_id: int, users: List[SharedUser], **kwargs)
 Bases: JsonDeserializable
 This object contains information about the users whose identifiers were shared with the bot using a Keyboard-
 ButtonRequestUsers button.
 Telegram documentation: https://core.telegram.org/bots/api#usersshared
 Parameters
 • request_id (int) – Identifier of the request
 • users (list of types.SharedUser) – Information about users shared with the bot
 Returns
 Instance of the class
 Return type
 UsersShared
 property user_id: None
class telebot.types.VideoChatStarted
 Bases: JsonDeserializable
 This object represents a service message about a video chat started in the chat. Currently holds no information.
class telebot.types.VideoNote(file_id, file_unique_id, length, duration, thumbnail=None, file_size=None,
 **kwargs)
 Bases: JsonDeserializable
 This object represents a video message (available in Telegram apps as of v.4.0).
 Telegram Documentation: https://core.telegram.org/bots/api#videonote
 Parameters
 • file_id (str) – Identifier for this file, which can be used to download or reuse the file
 • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same
 over time and for different bots. Can’t be used to download or reuse the file.
 • length (int) – Video width and height (diameter of the video message) as defined by sender
 • duration (int) – Duration of the video in seconds as defined by sender
 • thumbnail (telebot.types.PhotoSize) – Optional. Video thumbnail
 • file_size (int) – Optional. File size in bytes
 Returns
 Instance of the class
 Return type
 telebot.types.VideoNote
 property thumb: PhotoSize | None
class telebot.ExceptionHandler
 Bases: object
 Class for handling exceptions while Polling
 handle(exception)
ò Note
 Parameters
 • token (str) – Token of a bot, should be obtained from @BotFather
 • parse_mode (str, optional) – Default parse mode, defaults to None
 Parameters
 • custom_filter – Class with check(message) method.
 • custom_filter – Custom filter class with key.
 add_data(user_id: int, chat_id: int | None = None, business_connection_id: str | None = None,
 message_thread_id: int | None = None, bot_id: int | None = None, **kwargs) → None
 Add data to states.
 Parameters
 • user_id (int) – User’s identifier
 • chat_id (int) – Chat’s identifier
 • bot_id (int) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str) – Business identifier
 • message_thread_id (int) – Identifier of the message thread
 • kwargs – Data to add
 Returns
 None
 add_sticker_to_set(user_id: int, name: str, emojis: List[str] | str, png_sticker: str | Any | None = None,
 tgs_sticker: str | Any | None = None, webm_sticker: str | Any | None = None,
 mask_position: MaskPosition | None = None, sticker: InputSticker | None = None) →
 bool
 Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match
 the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and
 video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True
 on success.
 Telegram documentation: https://core.telegram.org/bots/api#addstickertoset
ò Note
 Parameters
 • user_id (int) – User identifier of created sticker set owner
 • name (str) – Sticker set name
 • emojis (str) – One or more emoji corresponding to the sticker
 • png_sticker (str or filelike object) – PNG image with the sticker, must be up to
 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must
 be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram
 servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload
 a new one using multipart/form-data.
 • tgs_sticker (str or filelike object) – TGS animation with the sticker, uploaded
 using multipart/form-data.
 • webm_sticker (str or filelike object) – WebM animation with the sticker, uploaded
 using multipart/form-data.
 • mask_position (telebot.types.MaskPosition) – A JSON-serialized object for po-
 sition where the mask should be placed on faces
 • sticker (telebot.types.InputSticker) – A JSON-serialized object for sticker to be
 added to the sticker set
 Returns
 On success, True is returned.
 Return type
 bool
 answer_callback_query(callback_query_id: int, text: str | None = None, show_alert: bool | None = None,
 url: str | None = None, cache_time: int | None = None) → bool
 Use this method to send answers to callback queries sent from inline keyboards. The answer will be dis-
 played to the user as a notification at the top of the chat screen or as an alert.
 Telegram documentation: https://core.telegram.org/bots/api#answercallbackquery
 Parameters
 • callback_query_id (int) – Unique identifier for the query to be answered
 • text (str) – Text of the notification. If not specified, nothing will be shown to the user,
 0-200 characters
 • show_alert (bool) – If True, an alert will be shown by the client instead of a notification
 at the top of the chat screen. Defaults to false.
 • url (str) – URL that will be opened by the user’s client. If you have created a Game and
 accepted the conditions via @BotFather, specify the URL that opens your game - note that
 this will only work if the query comes from a callback_game button.
 • cache_time – The maximum amount of time in seconds that the result of the callback
 query may be cached client-side. Telegram apps will support caching starting in version
 3.14. Defaults to 0.
 Returns
 On success, True is returned.
 Return type
 bool
 answer_inline_query(inline_query_id: str, results: List[Any], cache_time: int | None = None,
 is_personal: bool | None = None, next_offset: str | None = None, switch_pm_text:
 str | None = None, switch_pm_parameter: str | None = None, button:
 InlineQueryResultsButton | None = None) → bool
 Use this method to send answers to an inline query. On success, True is returned. No more than 50 results
 per query are allowed.
 Telegram documentation: https://core.telegram.org/bots/api#answerinlinequery
 Parameters
 • inline_query_id (str) – Unique identifier for the answered query
 • results (list of types.InlineQueryResult) – Array of results for the inline query
 • cache_time (int) – The maximum amount of time in seconds that the result of the inline
 query may be cached on the server.
 • is_personal (bool) – Pass True, if results may be cached on the server side only for the
 user that sent the query.
 • next_offset (str) – Pass the offset that a client should send in the next query with the
 same text to receive more results.
 • switch_pm_parameter (str) – Deep-linking parameter for the /start message sent to the
 bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are
 allowed. Example: An inline bot that sends YouTube videos can ask the user to connect
 the bot to their YouTube account to adapt search results accordingly. To do this, it displays
 a ‘Connect your YouTube account’ button above the results, or even before showing any.
 The user presses the button, switches to a private chat with the bot and, in doing so, passes
 a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer
 a switch_inline button so that the user can easily return to the chat where they wanted to
 use the bot’s inline capabilities.
 • switch_pm_text (str) – Parameter for the start message sent to the bot when user presses
 the switch button
 • button (types.InlineQueryResultsButton) – A JSON-serialized object describing
 a button to be shown above inline query results
 Returns
 On success, True is returned.
 Return type
 bool
 answer_pre_checkout_query(pre_checkout_query_id: str, ok: bool, error_message: str | None = None)
 → bool
 Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in
 the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout
 queries. On success, True is returned.
ò Note
The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
 Parameters
 • shipping_query_id (str) – Unique identifier for the query to be answered
 • ok (bool) – Specify True if delivery to the specified address is possible and False if there
 are any problems (for example, if delivery to the specified address is not possible)
 • shipping_options (list of ShippingOption) – Required if ok is True. A JSON-
 serialized array of available shipping options.
 • error_message (str) – Required if ok is False. Error message in human readable form
 that explains why it is impossible to complete the order (e.g. “Sorry, delivery to your
 desired address is unavailable’). Telegram will display this message to the user.
 Returns
 On success, True is returned.
 Return type
 bool
 answer_web_app_query(web_app_query_id: str, result: InlineQueryResultBase) → SentWebAppMessage
 Use this method to set the result of an interaction with a Web App and send a corresponding message on
 behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object
 is returned.
 Telegram Documentation: https://core.telegram.org/bots/api#answerwebappquery
 Parameters
 • web_app_query_id (str) – Unique identifier for the query to be answered
 • result (telebot.types.InlineQueryResultBase) – A JSON-serialized object de-
 scribing the message to be sent
 Returns
 On success, a SentWebAppMessage object is returned.
 Return type
 telebot.types.SentWebAppMessage
 approve_chat_join_request(chat_id: str | int, user_id: int | str) → bool
 Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work
 and must have the can_invite_users administrator right. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#approvechatjoinrequest
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • user_id (int or str) – Unique identifier of the target user
 Returns
 True on success.
 Return type
 bool
 ban_chat_member(chat_id: int | str, user_id: int, until_date: int | datetime | None = None, revoke_messages:
 bool | None = None) → bool
 Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels,
 the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first.
 Returns True on success.
 content_types=['document'])
 def command_handle_document(message):
 bot.send_message(message.chat.id, 'Document received, sir!')
 Parameters
 • commands (list of str) – Optional list of strings (commands to handle).
 • regexp (str) – Optional regular expression.
 • func (lambda) – Optional lambda function. The lambda receives the message to test as
 the first parameter. It must return True if the command should handle the message.
 • content_types (list of str) – Supported message content types. Must be a list. De-
 faults to [‘text’].
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 decorated function
 callback_query_handler(func=None, **kwargs)
 Handles new incoming callback query. As a parameter to the decorator function, it passes telebot.
 types.CallbackQuery object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 channel_post_handler(commands=None, regexp=None, func=None, content_types=None, **kwargs)
 Handles new incoming channel post of any kind - text, photo, sticker, etc. As a parameter to the decorator
 function, it passes telebot.types.Message object.
 Parameters
 Returns
 None
 clear_reply_handlers(message: Message) → None
 Clears all callback functions registered by register_for_reply() and register_for_reply_by_message_id().
 Parameters
 message (telebot.types.Message) – The message for which we want to clear reply han-
 dlers
 Returns
 None
 clear_reply_handlers_by_message_id(message_id: int) → None
 Clears all callback functions registered by register_for_reply() and register_for_reply_by_message_id().
 Parameters
 message_id (int) – The message id for which we want to clear reply handlers
 Returns
 None
 clear_step_handler(message: Message) → None
 Clears all callback functions registered by register_next_step_handler().
 Parameters
 message (telebot.types.Message) – The message for which we want to handle new mes-
 sage after that in same chat.
 Returns
 None
 clear_step_handler_by_chat_id(chat_id: int | str) → None
 Clears all callback functions registered by register_next_step_handler().
 Parameters
 chat_id (int or str) – The chat for which we want to clear next step handlers
 Returns
 None
 close() → bool
 Use this method to close the bot instance before moving it from one local server to another. You need to
 delete the webhook before calling this method to ensure that the bot isn’t launched again after server restart.
 The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#close
 Returns
 bool
 close_forum_topic(chat_id: str | int, message_thread_id: int) → bool
 Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the
 chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of
 the topic. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#closeforumtopic
 Aram chat_id
 Unique identifier for the target chat or username of the target channel (in the format @chan-
 nelusername)
 Parameters
 message_thread_id (int) – Identifier of the topic to close
 Returns
 On success, True is returned.
 Return type
 bool
 close_general_forum_topic(chat_id: int | str) → bool
 Use this method to close the ‘General’ topic in a forum supergroup chat. The bot must be an administrator
 in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#closegeneralforumtopic
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target channel
 (in the format @channelusername)
 copy_message(chat_id: int | str, from_chat_id: int | str, message_id: int, caption: str | None = None,
 parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None,
 disable_notification: bool | None = None, protect_content: bool | None = None,
 reply_to_message_id: int | None = None, allow_sending_without_reply: bool | None = None,
 reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove |
 ForceReply | None = None, timeout: int | None = None, message_thread_id: int | None =
 None, reply_parameters: ReplyParameters | None = None, show_caption_above_media: bool
 | None = None, allow_paid_broadcast: bool | None = None) → MessageID
 Use this method to copy messages of any kind. Service messages, paid media messages, giveaway mes-
 sages, giveaway winners messages, and invoice messages can’t be copied. A quiz poll can be copied only
 if the value of the field correct_option_id is known to the bot. The method is analogous to the method for-
 wardMessage, but the copied message doesn’t have a link to the original message. Returns the MessageId
 of the sent message on success.
 Telegram documentation: https://core.telegram.org/bots/api#copymessage
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • from_chat_id (int or str) – Unique identifier for the chat where the original message
 was sent (or channel username in the format @channelusername)
 • message_id (int) – Message identifier in the chat specified in from_chat_id
 • caption (str) – New caption for media, 0-1024 characters after entities parsing. If not
 specified, the original caption is kept
 • parse_mode (str) – Mode for parsing entities in the new caption.
 • caption_entities (Array of telebot.types.MessageEntity) – A JSON-serialized
 list of special entities that appear in the new caption, which can be specified instead of
 parse_mode
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • reply_to_message_id (int) – deprecated.
 Returns
 On success, an array of MessageId of the sent messages is returned.
 Return type
 list of telebot.types.MessageID
 create_chat_invite_link(chat_id: int | str, name: str | None = None, expire_date: int | datetime | None =
 None, member_limit: int | None = None, creates_join_request: bool | None =
 None) → ChatInviteLink
 Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for
 this to work and must have the appropriate administrator rights. The link can be revoked using the method
 revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.
 Telegram documentation: https://core.telegram.org/bots/api#createchatinvitelink
 Parameters
 • chat_id (int or str) – Id: Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • name (str) – Invite link name; 0-32 characters
 • expire_date (int or datetime) – Point in time (Unix timestamp) when the link will
 expire
 • member_limit (int) – Maximum number of users that can be members of the chat simul-
 taneously
 • creates_join_request (bool) – True, if users joining the chat via the link need to be
 approved by chat administrators. If True, member_limit can’t be specified
 Returns
 Returns the new invite link as ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 create_chat_subscription_invite_link(chat_id: int | str, subscription_period: int,
 subscription_price: int, name: str | None = None) →
 ChatInviteLink
 Use this method to create a subscription invite link for a channel chat. The bot must have the
 can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionIn-
 viteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatIn-
 viteLink object.
 Telegram documentation: https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
 Parameters
 • chat_id (int or str) – Unique identifier for the target channel chat or username of the
 target channel (in the format @channelusername)
 • name (str) – Invite link name; 0-32 characters
 • subscription_period (int) – The number of seconds the subscription will be active
 for before the next payment. Currently, it must always be 2592000 (30 days).
 • subscription_price (int) – The amount of Telegram Stars a user must pay initially
 and after each subsequent subscription period to be a member of the chat; 1-2500
 Returns
 Returns the new invite link as a ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 create_forum_topic(chat_id: int, name: str, icon_color: int | None = None, icon_custom_emoji_id: str |
 None = None) → ForumTopic
 Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat
 for this to work and must have the can_manage_topics administrator rights. Returns information about the
 created topic as a ForumTopic object.
 Telegram documentation: https://core.telegram.org/bots/api#createforumtopic
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • name (str) – Name of the topic, 1-128 characters
 • icon_color (int) – Color of the topic icon in RGB format. Currently, must be one of
 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F
 • icon_custom_emoji_id (str) – Custom emoji for the topic icon. Must be an emoji of
 type “tgs” and must be exactly 1 character long
 Returns
 On success, information about the created topic is returned as a ForumTopic object.
 Return type
 telebot.types.ForumTopic
 create_invoice_link(title: str, description: str, payload: str, provider_token: str | None, currency: str,
 prices: List[LabeledPrice], max_tip_amount: int | None = None,
 suggested_tip_amounts: List[int] | None = None, provider_data: str | None = None,
 photo_url: str | None = None, photo_size: int | None = None, photo_width: int |
 None = None, photo_height: int | None = None, need_name: bool | None = None,
 need_phone_number: bool | None = None, need_email: bool | None = None,
 need_shipping_address: bool | None = None, send_phone_number_to_provider:
 bool | None = None, send_email_to_provider: bool | None = None, is_flexible: bool
 | None = None, subscription_period: int | None = None, business_connection_id: str
 | None = None) → str
 Use this method to create a link for an invoice. Returns the created invoice link as String on success.
 Telegram documentation: https://core.telegram.org/bots/api#createinvoicelink
 Parameters
 • business_connection_id (str) – Unique identifier of the business connection on behalf
 of which the link will be created
 • title (str) – Product name, 1-32 characters
 • description (str) – Product description, 1-255 characters
 • payload (str) – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
 the user, use for your internal processes.
 • provider_token (str) – Payments provider token, obtained via @Botfather; Pass None
 to omit the parameter to use “XTR” currency
 • currency (str) – Three-letter ISO 4217 currency code, see https://core.telegram.org/
 bots/payments#supported-currencies
ò Note
Fields *_sticker are deprecated, pass a list of stickers to stickers parameter instead.
 Parameters
 • user_id (int) – User identifier of created sticker set owner
 • name (str) – Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals).
 Can contain only English letters, digits and underscores. Must begin with a letter, can’t con-
 tain consecutive underscores and must end in “_by_<bot_username>”. <bot_username>
 is case insensitive. 1-64 characters.
 • title (str) – Sticker set title, 1-64 characters
 • emojis (str) – One or more emoji corresponding to the sticker
 • png_sticker (str) – PNG image with the sticker, must be up to 512 kilobytes in size,
 dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass
 a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP
 URL as a String for Telegram to get a file from the Internet, or upload a new one using
 multipart/form-data.
 • tgs_sticker (str) – TGS animation with the sticker, uploaded using multipart/form-
 data.
 • webm_sticker (str) – WebM animation with the sticker, uploaded using multipart/form-
 data.
 • contains_masks (bool) – Pass True, if a set of mask stickers should be created. Depre-
 cated since Bot API 6.2, use sticker_type instead.
 • sticker_type (str) – Type of stickers in the set, pass “regular”, “mask”, or “cus-
 tom_emoji”. By default, a regular sticker set is created.
 • mask_position (telebot.types.MaskPosition) – A JSON-serialized object for po-
 sition where the mask should be placed on faces
 • needs_repainting (bool) – Pass True if stickers in the sticker set must be repainted to
 the color of text when used in messages, the accent color if used as emoji status, white on
 chat photos, or another appropriate color based on context; for custom emoji sticker sets
 only
 • stickers (list of telebot.types.InputSticker) – List of stickers to be added to
 the set
 • sticker_format (str) – deprecated
 Returns
 On success, True is returned.
 Return type
 bool
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • user_id (int or str) – Unique identifier of the target user
 Returns
 True on success.
 Return type
 bool
 delete_chat_photo(chat_id: int | str) → bool
 Use this method to delete a chat photo. Photos can’t be changed for private chats. The bot must be an
 administrator in the chat for this to work and must have the appropriate admin rights. Returns True on
 success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are
 Admins’ setting is off in the target group.
 Telegram documentation: https://core.telegram.org/bots/api#deletechatphoto
 Parameters
 chat_id (int or str) – Int or Str: Unique identifier for the target chat or username of the
 target channel (in the format @channelusername)
 Returns
 True on success.
 Return type
 bool
 delete_chat_sticker_set(chat_id: int | str) → bool
 Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat
 for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally
 returned in getChat requests to check if the bot can use this method. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#deletechatstickerset
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target super-
 group (in the format @supergroupusername)
 Returns
 Returns True on success.
 Return type
 bool
 delete_forum_topic(chat_id: str | int, message_thread_id: int) → bool
 Use this method to delete a topic in a forum supergroup chat. The bot must be an administrator in the chat
 for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the
 topic. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#deleteforumtopic
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_thread_id (int) – Identifier of the topic to delete
 Returns
 On success, True is returned.
 Return type
 bool
 delete_message(chat_id: int | str, message_id: int, timeout: int | None = None) → bool
 Use this method to delete a message, including service messages, with the following limitations: - A mes-
 sage can only be deleted if it was sent less than 48 hours ago. - A dice message in a private chat can only be
 deleted if it was sent more than 24 hours ago. - Bots can delete outgoing messages in private chats, groups,
 and supergroups. - Bots can delete incoming messages in private chats. - Bots granted can_post_messages
 permissions can delete outgoing messages in channels. - If the bot is an administrator of a group, it can
 delete any message there. - If the bot has can_delete_messages permission in a supergroup or a channel, it
 can delete any message there. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#deletemessage
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Identifier of the message to delete
 • timeout (int) – Timeout in seconds for the request.
 Returns
 Returns True on success.
 Return type
 bool
 delete_messages(chat_id: int | str, message_ids: List[int])
 Use this method to delete multiple messages simultaneously. If some of the specified messages can’t be
 found, they are skipped. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#deletemessages
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_ids (list of int) – Identifiers of the messages to be deleted
 Returns
 Returns True on success.
 delete_my_commands(scope: BotCommandScope | None = None, language_code: str | None = None) →
 bool
 Use this method to delete the list of the bot’s commands for the given scope and user language. After
 deletion, higher level commands will be shown to affected users. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#deletemycommands
 Parameters
 • scope (telebot.types.BotCommandScope) – The scope of users for which the com-
 mands are relevant. Defaults to BotCommandScopeDefault.
 • language_code (str) – A two-letter ISO 639-1 language code. If empty, commands will
 be applied to all users from the given scope, for whose language there are no dedicated
 commands
 Returns
 True on success.
 Return type
 bool
 delete_state(user_id: int, chat_id: int | None = None, business_connection_id: str | None = None,
 message_thread_id: int | None = None, bot_id: int | None = None) → bool
 Fully deletes the storage record of a user in chat.
. Warning
This does NOT set state to None, but deletes the object from storage.
 Parameters
 • user_id (int) – User’s identifier
 • chat_id (int) – Chat’s identifier
 Returns
 True on success
 Return type
 bool
 Returns
 Returns True on success.
 Return type
 bool
 deleted_business_messages_handler(func=None, **kwargs)
 Handles new incoming deleted messages state.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 disable_save_next_step_handlers()
 Disable saving next step handlers (by default saving disable)
 This function is left to keep backward compatibility whose purpose was to disable file saving capability
 for handlers. For the same purpose, MemoryHandlerBackend is reassigned as a new next_step_backend
 backend instead of FileHandlerBackend.
 disable_save_reply_handlers()
 Disable saving next step handlers (by default saving disable)
 This function is left to keep backward compatibility whose purpose was to disable file saving capability for
 handlers. For the same purpose, MemoryHandlerBackend is reassigned as a new reply_backend backend
 instead of FileHandlerBackend.
 download_file(file_path: str) → bytes
 Downloads file.
 Parameters
 file_path (str) – Path where the file should be downloaded.
 Returns
 bytes
 Return type
 bytes
 edit_chat_invite_link(chat_id: int | str, invite_link: str | None = None, name: str | None = None,
 expire_date: int | datetime | None = None, member_limit: int | None = None,
 creates_join_request: bool | None = None) → ChatInviteLink
 Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in
 the chat for this to work and must have the appropriate admin rights.
 Telegram documentation: https://core.telegram.org/bots/api#editchatinvitelink
 Parameters
 • chat_id (int or str) – Id: Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • name (str) – Invite link name; 0-32 characters
 • invite_link (str) – The invite link to edit
 • expire_date (int or datetime) – Point in time (Unix timestamp) when the link will
 expire
 • member_limit (int) – Maximum number of users that can be members of the chat simul-
 taneously
 • creates_join_request (bool) – True, if users joining the chat via the link need to be
 approved by chat administrators. If True, member_limit can’t be specified
 Returns
 Returns the new invite link as ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 edit_chat_subscription_invite_link(chat_id: int | str, invite_link: str, name: str | None = None) →
 ChatInviteLink
 Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users
 administrator rights. Returns the edited invite link as a ChatInviteLink object.
 Telegram documentation: https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • invite_link (str) – The invite link to edit
 • name (str) – Invite link name; 0-32 characters
 Returns
 Returns the edited invite link as a ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 edit_forum_topic(chat_id: int | str, message_thread_id: int, name: str | None = None,
 icon_custom_emoji_id: str | None = None) → bool
 Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an admin-
 istrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the
 creator of the topic. Returns True on success.
 Telegram Documentation: https://core.telegram.org/bots/api#editforumtopic
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_thread_id (int) – Identifier of the topic to edit
 • name (str) – Optional, New name of the topic, 1-128 characters. If not specififed or empty,
 the current name of the topic will be kept
 • icon_custom_emoji_id (str) – Optional, New unique identifier of the custom emoji
 shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji
 identifiers. Pass an empty string to remove the icon. If not specified, the current icon will
 be kept
 Returns
 On success, True is returned.
 Return type
 bool
 Use this method to edit live location messages. A location can be edited until its live_period expires
 or editing is explicitly
 disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline
 message, the edited Message is returned, otherwise True is returned.
 Telegram documentation: https://core.telegram.org/bots/api#editmessagelivelocation
 Parameters
 • latitude (float) – Latitude of new location
 • longitude (float) – Longitude of new location
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the mes-
 sage to edit
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – A JSON-serialized object for a new inline keyboard.
 • timeout (int) – Timeout in seconds for the request.
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message
 • horizontal_accuracy (float) – The radius of uncertainty for the location, measured
 in meters; 0-1500
 • heading (int) – Direction in which the user is moving, in degrees. Must be between 1
 and 360 if specified.
 • proximity_alert_radius (int) – The maximum distance for proximity alerts about
 approaching another chat member, in meters. Must be between 1 and 100000 if specified.
 • live_period (int) – New period in seconds during which the location can be updated,
 starting from the message send date. If 0x7FFFFFFF is specified, then the location can be
 updated forever. Otherwise, the new value must not exceed the current live_period by more
 than a day, and the live location expiration date must remain within the next 90 days. If not
 specified, then live_period remains unchanged
 • business_connection_id (str) – Identifier of a business connection
 Returns
 On success, if the edited message is not an inline message, the edited Message is returned,
 otherwise True is returned.
 Return type
 telebot.types.Message or bool
 edit_message_media(media: Any, chat_id: int | str | None = None, message_id: int | None = None,
 inline_message_id: str | None = None, reply_markup: InlineKeyboardMarkup | None
 = None, business_connection_id: str | None = None, timeout: int | None = None) →
 Message | bool
 Use this method to edit animation, audio, document, photo, or video messages, or to add media to text
 messages. If a message is part of a message album, then it can be edited only to an audio for audio albums,
 only to a document for document albums and to a photo or a video otherwise. When an inline message
 is edited, a new file can’t be uploaded; use a previously uploaded file via its file_id or specify a URL. On
 success, if the edited message is not an inline message, the edited Message is returned, otherwise True is
 returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard
 can only be edited within 48 hours from the time they were sent.
 Telegram documentation: https://core.telegram.org/bots/api#editmessagemedia
 Parameters
 • media (InputMedia) – A JSON-serialized object for a new media content of the message
 • chat_id (int or str) – Required if inline_message_id is not specified. Unique identifier
 for the target chat or username of the target channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the sent
 message
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message
 • reply_markup (telebot.types.InlineKeyboardMarkup or
 ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply) – A JSON-
 serialized object for an inline keyboard.
 • business_connection_id (str) – Unique identifier of the business connection
 • timeout (int) – Timeout in seconds for the request.
 Returns
 On success, if edited message is sent by the bot, the edited Message is returned, otherwise
 True is returned.
 Return type
 types.Message or bool
 edit_message_reply_markup(chat_id: int | str | None = None, message_id: int | None = None,
 inline_message_id: str | None = None, reply_markup:
 InlineKeyboardMarkup | None = None, business_connection_id: str | None
 = None, timeout: int | None = None) → Message | bool
 Use this method to edit only the reply markup of messages.
 Telegram documentation: https://core.telegram.org/bots/api#editmessagereplymarkup
 Parameters
 • chat_id (int or str) – Required if inline_message_id is not specified. Unique identifier
 for the target chat or username of the target channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the sent
 message
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message
 • reply_markup (InlineKeyboardMarkup or ReplyKeyboardMarkup or
 ReplyKeyboardRemove or ForceReply) – A JSON-serialized object for an inline
 keyboard.
 • business_connection_id (str) – Unique identifier of the business connection
ò Note
 Parameters
 filename (str, optional) – Filename of saving file, defaults to “./.state-save/states.pkl”
 Returns
 exported invite link as String on success.
 Return type
 str
 forward_message(chat_id: int | str, from_chat_id: int | str, message_id: int, disable_notification: bool |
 None = None, protect_content: bool | None = None, timeout: int | None = None,
 message_thread_id: int | None = None) → Message
 Use this method to forward messages of any kind.
 Telegram documentation: https://core.telegram.org/bots/api#forwardmessage
 Parameters
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • from_chat_id (int or str) – Unique identifier for the chat where the original message
 was sent (or channel username in the format @channelusername)
 • message_id (int) – Message identifier in the chat specified in from_chat_id
 • protect_content (bool) – Protects the contents of the forwarded message from forward-
 ing and saving
 • timeout (int) – Timeout in seconds for the request.
 • message_thread_id (int) – Identifier of a message thread, in which the message will be
 sent
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 forward_messages(chat_id: str | int, from_chat_id: str | int, message_ids: List[int], disable_notification:
 bool | None = None, message_thread_id: int | None = None, protect_content: bool |
 None = None) → List[MessageID]
 Use this method to forward multiple messages of any kind. If some of the specified messages can’t be found
 or forwarded, they are skipped. Service messages and messages with protected content can’t be forwarded.
 Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages
 is returned.
 Telegram documentation: https://core.telegram.org/bots/api#forwardmessages
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • from_chat_id (int or str) – Unique identifier for the chat where the original message
 was sent (or channel username in the format @channelusername)
 • message_ids (list) – Message identifiers in the chat specified in from_chat_id
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound
 Returns
 List made of ChatMember objects.
 Return type
 list of telebot.types.ChatMember
 get_chat_member(chat_id: int | str, user_id: int) → ChatMember
 Use this method to get information about a member of a chat. Returns a ChatMember object on success.
 Telegram documentation: https://core.telegram.org/bots/api#getchatmember
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • user_id (int) – Unique identifier of the target user
 Returns
 Returns ChatMember object on success.
 Return type
 telebot.types.ChatMember
 get_chat_member_count(chat_id: int | str) → int
 Use this method to get the number of members in a chat.
 Telegram documentation: https://core.telegram.org/bots/api#getchatmembercount
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target super-
 group or channel (in the format @channelusername)
 Returns
 Number of members in the chat.
 Return type
 int
 get_chat_members_count(**kwargs)
 Parameters
 custom_emoji_ids (list of str) – List of custom emoji identifiers. At most 200 custom
 emoji identifiers can be specified.
 Returns
 Returns an Array of Sticker objects.
 Return type
 list of telebot.types.Sticker
 get_file(file_id: str | None) → File
 Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can
 download files of up to 20MB in size. On success, a File object is returned. 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 get_file again.
 Telegram documentation: https://core.telegram.org/bots/api#getfile
 Parameters
 file_id (str) – File identifier
 Returns
 telebot.types.File
 get_file_url(file_id: str | None) → str
 Get a valid URL for downloading a file.
 Parameters
 file_id (str) – File identifier to get download URL for.
 Returns
 URL for downloading the file.
 Return type
 str
 get_forum_topic_icon_stickers() → List[Sticker]
 Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires
 no parameters. Returns an Array of Sticker objects.
 Telegram documentation: https://core.telegram.org/bots/api#getforumtopiciconstickers
 Returns
 On success, a list of StickerSet objects is returned.
 Return type
 List[telebot.types.StickerSet]
 get_game_high_scores(user_id: int, chat_id: int | str | None = None, message_id: int | None = None,
 inline_message_id: str | None = None) → List[GameHighScore]
 Use this method to get data for high score tables. Will return the score of the specified user and several of
 their neighbors in a game. On success, returns an Array of GameHighScore objects.
 This method will currently return scores for the target user, plus two of their closest neighbors on each side.
 Will also return the top three users if the user and their neighbors are not among them. Please note that this
 behavior is subject to change.
 Telegram documentation: https://core.telegram.org/bots/api#getgamehighscores
 Parameters
 • user_id (int) – User identifier
. Warning
 Even if you are using telebot.types.State, this method will return a string. When comparing(not
 recommended), you should compare this string with telebot.types.State.name
 Parameters
 • user_id (int) – User’s identifier
 • chat_id (int) – Chat’s identifier
 • bot_id (int) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str) – Business identifier
 • message_thread_id (int) – Identifier of the message thread
 Returns
 state of a user
 Return type
 int or str or telebot.types.State
ò Note
 Parameters
 • timeout (int) – Request connection timeout.
 • long_polling_timeout (int) – Timeout in seconds for long polling (see API docs)
 • skip_pending (bool) – skip old updates
 • logger_level (int.) – Custom (different from logger itself) logging level for infin-
 ity_polling logging. Use logger levels from logging as a value. None/NOTSET = no error
 logging
 • allowed_updates (list of str) – A list of the update types you want your bot to re-
 ceive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only
 receive updates of these types. See util.update_types for a complete list of available update
 types. Specify an empty list to receive all update types except chat_member (default). If not
 specified, the previous setting will be used. Please note that this parameter doesn’t affect
 updates created before the call to the get_updates, so unwanted updates may be received
 for a short period of time.
 • restart_on_change (bool) – Restart a file on file(s) change. Defaults to False
 • path_to_watch (str) – Path to watch for changes. Defaults to current directory
 Returns
 inline_handler(func, **kwargs)
 Handles new incoming inline query. As a parameter to the decorator function, it passes telebot.types.
 InlineQuery object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
kick_chat_member(**kwargs)
 Handles New incoming message of any kind - text, photo, sticker, etc. As a parameter to the decorator
 function, it passes telebot.types.Message object. All message handlers are tested in the order they
 were added.
 Example:
 content_types=['document'])
 def command_handle_document(message):
 bot.send_message(message.chat.id, 'Document received, sir!')
 Parameters
 • commands (list of str) – Optional list of strings (commands to handle).
 • regexp (str) – Optional regular expression.
 • func (lambda) – Optional lambda function. The lambda receives the message to test as
 the first parameter. It must return True if the command should handle the message.
 • content_types (list of str) – Supported message content types. Must be a list. De-
 faults to [‘text’].
 • chat_types (list of str) – list of chat types
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 decorated function
 message_reaction_count_handler(func=None, **kwargs)
 Handles new incoming message reaction count. As a parameter to the decorator function, it passes
 telebot.types.MessageReactionCountUpdated object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 message_reaction_handler(func=None, **kwargs)
 Handles new incoming message reaction. As a parameter to the decorator function, it passes telebot.
 types.MessageReactionUpdated object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 middleware_handler(update_types: List[str] | None = None)
 Function-based middleware handler decorator.
 This decorator can be used to decorate functions that must be handled as middlewares before entering any
 other message handlers But, be careful and check type of the update inside the handler if more than one
 update_type is given
 Example:
 Parameters
 update_types (list of str) – Optional list of update types that can be passed into the
 middleware handler.
 Returns
 function
 my_chat_member_handler(func=None, **kwargs)
 Handles update in a status of a bot. For private chats, this update is received only when the bot is
 blocked or unblocked by the user. As a parameter to the decorator function, it passes telebot.types.
 ChatMemberUpdated object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 pin_chat_message(chat_id: int | str, message_id: int, disable_notification: bool | None = False,
 business_connection_id: str | None = None) → bool
 Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to
 work and must have the appropriate admin rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#pinchatmessage
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Identifier of a message to pin
 • disable_notification (bool) – Pass True, if it is not necessary to send a notification
 to all group members about the new pinned message
 • business_connection_id (str) – Unique identifier of the business connection
 Returns
 True on success.
 Return type
 bool
 poll_answer_handler(func=None, **kwargs)
 Handles change of user’s answer in a non-anonymous poll(when user changes the vote). Bots receive new
 votes only in polls that were sent by the bot itself. As a parameter to the decorator function, it passes
 telebot.types.PollAnswer object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 poll_handler(func, **kwargs)
 Handles new state of a poll. Bots receive only updates about stopped polls and polls, which are sent by the
 bot As a parameter to the decorator function, it passes telebot.types.Poll object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 polling(non_stop: bool | None = False, skip_pending: bool | None = False, interval: int | None = 0, timeout:
 int | None = 20, long_polling_timeout: int | None = 20, logger_level: int | None = 40,
 allowed_updates: List[str] | None = None, none_stop: bool | None = None, restart_on_change: bool
 | None = False, path_to_watch: str | None = None)
 This function creates a new Thread that calls an internal __retrieve_updates function. This allows the bot
 to retrieve Updates automatically and notify listeners and message handlers accordingly.
 Warning: Do not call this function more than once!
ò Note
 Parameters
 • interval (int) – Delay between two update retrivals
 • non_stop (bool) – Do not stop polling when an ApiException occurs.
 • timeout (int) – Request connection timeout
 • skip_pending (bool) – skip old updates
 • long_polling_timeout (int) – Timeout in seconds for long polling (see API docs)
 • logger_level (int) – Custom (different from logger itself) logging level for infin-
 ity_polling logging. Use logger levels from logging as a value. None/NOTSET = no error
 logging
 • allowed_updates (list of str) – A list of the update types you want your bot to re-
 ceive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only
 receive updates of these types. See util.update_types for a complete list of available update
 types. Specify an empty list to receive all update types except chat_member (default). If
 not specified, the previous setting will be used.
 Please note that this parameter doesn’t affect updates created before the call to the
 get_updates, so unwanted updates may be received for a short period of time.
 • none_stop (bool) – deprecated.
 • restart_on_change (bool) – Restart a file on file(s) change. Defaults to False
 • path_to_watch (str) – Path to watch for changes. Defaults to None
 Returns
 pre_checkout_query_handler(func, **kwargs)
 New incoming pre-checkout query. Contains full information about checkout. As a parameter to the deco-
 rator function, it passes telebot.types.PreCheckoutQuery object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 process_new_updates(updates: List[Update])
 Processes new updates. Just pass list of subclasses of Update to this method.
 Parameters
 updates (list of telebot.types.Update) – List of telebot.types.Update objects.
 Return None
 • can_edit_stories (bool) – Pass True if the administrator can edit the channel’s stories
 • can_delete_stories (bool) – Pass True if the administrator can delete the channel’s
 stories
 Returns
 True on success.
 Return type
 bool
 purchased_paid_media_handler(func=None, **kwargs)
 Handles new incoming purchased paid media.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 refund_star_payment(user_id: int, telegram_payment_charge_id: str) → bool
 Refunds a successful payment in Telegram Stars. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#refundstarpayment
 Parameters
 • user_id (int) – Identifier of the user whose payment will be refunded
 • telegram_payment_charge_id (str) – Telegram payment identifier
 Returns
 On success, True is returned.
 Return type
 bool
 register_business_connection_handler(callback: Callable, func: Callable | None = None, pass_bot:
 bool | None = False, **kwargs)
 Registers business connection handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_business_message_handler(callback: Callable, commands: List[str] | None = None, regexp:
 str | None = None, func: Callable | None = None, content_types:
 List[str] | None = None, pass_bot: bool | None = False,
 **kwargs)
 Registers business connection handler.
 Parameters
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot – True if you need to pass TeleBot instance to handler(useful for separating
 handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_chat_join_request_handler(callback: Callable, func: Callable | None = None, pass_bot:
 bool | None = False, **kwargs)
 Registers chat join request handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_chat_member_handler(callback: Callable, func: Callable | None = None, pass_bot: bool | None
 = False, **kwargs)
 Registers chat member handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 :return:None
 register_chosen_inline_handler(callback: Callable, func: Callable, pass_bot: bool | None = False,
 **kwargs)
 Registers chosen inline handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 decorated function
 register_edited_message_handler(callback: Callable, content_types: List[str] | None = None,
 commands: List[str] | None = None, regexp: str | None = None,
 func: Callable | None = None, chat_types: List[str] | None = None,
 pass_bot: bool | None = False, **kwargs)
 Registers edited message handler.
 Parameters
 • callback (function) – function to be called
 • content_types (list of str) – Supported message content types. Must be a list. De-
 faults to [‘text’].
 • commands (list of str) – list of commands
 • regexp (str) – Regular expression
 • func (function) – Function executed as a filter
 • chat_types (bool) – True for private chat
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_for_reply(message: Message, callback: Callable, *args, **kwargs) → None
 Registers a callback function to be notified when a reply to message arrives.
 Warning: In case callback as lambda function, saving reply handlers will not work.
 Parameters
 • message (telebot.types.Message) – The message for which we are awaiting a reply.
 • callback (Callable[[telebot.types.Message], None]) – The callback function
 to be called when a reply arrives. Must accept one message parameter, which will contain
 the replied message.
 • args – Optional arguments for the callback function.
 • kwargs – Optional keyword arguments for the callback function.
 Returns
 None
 register_for_reply_by_message_id(message_id: int, callback: Callable, *args, **kwargs) → None
 Registers a callback function to be notified when a reply to message arrives.
 Warning: In case callback as lambda function, saving reply handlers will not work.
 Parameters
 • message_id (int) – The id of the message for which we are awaiting a reply.
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_message_reaction_handler(callback: Callable, func: Callable = None, pass_bot: bool | None
 = False, **kwargs)
 Registers message reaction handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_middleware_handler(callback, update_types=None)
 Adds function-based middleware handler.
 This function will register your decorator function. Function-based middlewares are executed before han-
 dlers. But, be careful and check type of the update inside the handler if more than one update_type is
 given
 Example:
 bot = TeleBot(‘TOKEN’)
 bot.register_middleware_handler(print_channel_post_text, update_types=[‘channel_post’,
 ‘edited_channel_post’])
 Parameters
 • callback (function) – Function that will be used as a middleware handler.
 • update_types (list of str) – Optional list of update types that can be passed into the
 middleware handler.
 Returns
 None
 register_my_chat_member_handler(callback: Callable, func: Callable | None = None, pass_bot: bool |
 None = False, **kwargs)
 Registers my chat member handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_next_step_handler(message: Message, callback: Callable, *args, **kwargs) → None
 Registers a callback function to be notified when new message arrives after message.
 Warning: In case callback as lambda function, saving next step handlers will not work.
 Parameters
 • message (telebot.types.Message) – The message for which we want to handle new
 message in the same chat.
 • callback (Callable[[telebot.types.Message], None]) – The callback function
 which next new message arrives.
 • args – Args to pass in callback func
 • kwargs – Args to pass in callback func
 Returns
 None
 register_next_step_handler_by_chat_id(chat_id: int, callback: Callable, *args, **kwargs) → None
 Registers a callback function to be notified when new message arrives in the given chat.
 Warning: In case callback as lambda function, saving next step handlers will not work.
 Parameters
 • chat_id (int) – The chat (chat ID) for which we want to handle new message.
 • callback (Callable[[telebot.types.Message], None]) – The callback function
 which next new message arrives.
 • args – Args to pass in callback func
 • kwargs – Args to pass in callback func
 Returns
 None
 register_poll_answer_handler(callback: Callable, func: Callable, pass_bot: bool | None = False,
 **kwargs)
 Registers poll answer handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_poll_handler(callback: Callable, func: Callable, pass_bot: bool | None = False, **kwargs)
 Registers poll handler.
 Parameters
 • callback (function) – function to be called
 Use this method to replace an existing sticker in a sticker set with a new one. The method is
 equivalent to calling deleteStickerFromSet, then addStickerToSet,
 then setStickerPositionInSet. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#replaceStickerInSet
 Parameters
 • user_id (int) – User identifier of the sticker set owner
 • name (str) – Sticker set name
 • old_sticker (str) – File identifier of the replaced sticker
 • sticker (telebot.types.InputSticker) – A JSON-serialized object with informa-
 tion about the added sticker. If exactly the same sticker had already been added to the set,
 then the set remains unchanged.
 Returns
 Returns True on success.
 Return type
 bool
 reply_to(message: Message, text: str, **kwargs) → Message
 Convenience function for send_message(message.chat.id, text, re-
 ply_parameters=(message.message_id. . . ), **kwargs)
 Parameters
 • message (types.Message) – Instance of telebot.types.Message
 • text (str) – Text of the message.
 • kwargs – Additional keyword arguments which are passed to telebot.TeleBot.
 send_message()
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 reset_data(user_id: int, chat_id: int | None = None, business_connection_id: str | None = None,
 message_thread_id: int | None = None, bot_id: int | None = None) → bool
 Reset data for a user in chat: sets the ‘data’ field to an empty dictionary.
 Parameters
 • user_id (int) – User’s identifier
 • chat_id (int) – Chat’s identifier
 • bot_id (int) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str) – Business identifier
 • message_thread_id (int) – Identifier of the message thread
 Returns
 True on success
 Return type
 bool
 restrict_chat_member(chat_id: int | str, user_id: int, until_date: int | datetime | None = None,
 can_send_messages: bool | None = None, can_send_media_messages: bool | None
 = None, can_send_polls: bool | None = None, can_send_other_messages: bool |
 None = None, can_add_web_page_previews: bool | None = None,
 can_change_info: bool | None = None, can_invite_users: bool | None = None,
 can_pin_messages: bool | None = None, permissions: ChatPermissions | None =
 None, use_independent_chat_permissions: bool | None = None) → bool
 Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup
 for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift
 restrictions from a user.
 Telegram documentation: https://core.telegram.org/bots/api#restrictchatmember
. Warning
Individual parameters are deprecated and will be removed, use ‘permissions’ instead.
 Parameters
 • chat_id (int or str) – Unique identifier for the target group or username of the target
 supergroup or channel (in the format @channelusername)
 • user_id (int) – Unique identifier of the target user
 • until_date (int or datetime, optional) – Date when restrictions will be lifted for the
 user, unix time. If user is restricted for more than 366 days or less than 30 seconds from
 the current time, they are considered to be restricted forever
 • can_send_messages (bool) – deprecated
 • can_send_media_messages (bool) – deprecated
 • can_send_polls (bool) – deprecated
 • can_send_other_messages (bool) – deprecated
 • can_add_web_page_previews (bool) – deprecated
 • can_change_info (bool) – deprecated
 • can_invite_users (bool) – deprecated
 • can_pin_messages (bool) – deprecated
 • use_independent_chat_permissions (bool, optional) – Pass True if chat per-
 missions are set independently. Otherwise, the can_send_other_messages and
 can_add_web_page_previews permissions will imply the can_send_messages,
 can_send_audios, can_send_documents, can_send_photos, can_send_videos,
 can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls
 permission will imply the can_send_messages permission.
 • permissions (telebot.types.ChatPermissions) – ChatPermissions object defining
 permissions.
 Returns
 True on success
 Return type
 bool
 retrieve_data(user_id: int, chat_id: int | None = None, business_connection_id: str | None = None,
 message_thread_id: int | None = None, bot_id: int | None = None) → Dict[str, Any] | None
 Returns context manager with data for a user in chat.
 Parameters
 • user_id (int) – User identifier
 • chat_id (int, optional) – Chat’s unique identifier, defaults to user_id
 • bot_id (int, optional) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str, optional) – Business identifier
 • message_thread_id (int, optional) – Identifier of the message thread
 Returns
 Context manager with data for a user in chat
 Return type
 Optional[Any]
 revoke_chat_invite_link(chat_id: int | str, invite_link: str) → ChatInviteLink
 Use this method to revoke an invite link created by the bot. Note: If the primary link is revoked, a new link
 is automatically generated The bot must be an administrator in the chat for this to work and must have the
 appropriate admin rights.
 Telegram documentation: https://core.telegram.org/bots/api#revokechatinvitelink
 Parameters
 • chat_id (int or str) – Id: Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • invite_link (str) – The invite link to revoke
 Returns
 Returns the new invite link as ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 run_webhooks(listen: str | None = '127.0.0.1', port: int | None = 443, url_path: str | None = None,
 certificate: str | None = None, certificate_key: str | None = None, webhook_url: str | None =
 None, max_connections: int | None = None, allowed_updates: List | None = None,
 ip_address: str | None = None, drop_pending_updates: bool | None = None, timeout: int |
 None = None, secret_token: str | None = None, secret_token_length: int | None = 20)
 This class sets webhooks and listens to a given url and port.
 Requires fastapi, uvicorn, and latest version of starlette.
 Parameters
 • listen (str, optional) – IP address to listen to, defaults to “127.0.0.1”
 • port (int, optional) – A port which will be used to listen to webhooks., defaults to 443
 • url_path (str, optional) – Path to the webhook. Defaults to /token, defaults to None
 • certificate (str, optional) – Path to the certificate file, defaults to None
 • certificate_key (str, optional) – Path to the certificate key file, defaults to None
 • webhook_url (str, optional) – Webhook URL to be set, defaults to None
 • max_connections (int, optional) – Maximum allowed number of simultaneous HTTPS
 connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values
 to limit the load on your bot’s server, and higher values to increase your bot’s throughput.,
 defaults to None
 • allowed_updates (list, optional) – A JSON-serialized list of the update types you
 want your bot to receive. For example, specify [“message”, “edited_channel_post”, “call-
 back_query”] to only receive updates of these types. See Update for a complete list of
 available update types. Specify an empty list to receive all updates regardless of type (de-
 fault). If not specified, the previous setting will be used. defaults to None
 • ip_address (str, optional) – The fixed IP address which will be used to send webhook
 requests instead of the IP address resolved through DNS, defaults to None
 • drop_pending_updates (bool, optional) – Pass True to drop all pending updates, de-
 faults to None
 • timeout (int, optional) – Request connection timeout, defaults to None
 • secret_token (str, optional) – Secret token to be used to verify the webhook request,
 defaults to None
 • secret_token_length (int, optional) – Length of a secret token, defaults to 20
 Raises
 ImportError – If necessary libraries were not installed.
 send_audio(chat_id: int | str, audio: Any | str, caption: str | None = None, duration: int | None = None,
 performer: str | None = None, title: str | None = None, reply_to_message_id: int | None = None,
 reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove |
 ForceReply | None = None, parse_mode: str | None = None, disable_notification: bool | None =
 None, timeout: int | None = None, thumbnail: str | Any | None = None, caption_entities:
 List[MessageEntity] | None = None, allow_sending_without_reply: bool | None = None,
 protect_content: bool | None = None, message_thread_id: int | None = None, thumb: str | Any |
 None = None, reply_parameters: ReplyParameters | None = None, business_connection_id: str |
 None = None, message_effect_id: str | None = None, allow_paid_broadcast: bool | None =
 None) → Message
 Use this method to send audio files, if you want Telegram clients to display them in the music player. Your
 audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently
 send audio files of up to 50 MB in size, this limit may be changed in the future.
 For sending voice messages, use the send_voice method instead.
 Telegram documentation: https://core.telegram.org/bots/api#sendaudio
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • audio (str or telebot.types.InputFile) – Audio file to send. Pass a file_id as String
 to send an audio file that exists on the Telegram servers (recommended), pass an HTTP
 URL as a String for Telegram to get an audio file from the Internet, or upload a new one
 using multipart/form-data. Audio must be in the .MP3 or .M4A format.
 • caption (str) – Audio caption, 0-1024 characters after entities parsing
 • duration (int) – Duration of the audio in seconds
 • performer (str) – Performer
 • title (str) – Track name
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply)
 • parse_mode (str) – Mode for parsing entities in the audio caption. See formatting options
 for more details.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • timeout (int) – Timeout in seconds for the request.
 • thumbnail (str or telebot.types.InputFile) – 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 “at-
 tach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
 <file_attach_name>
 Return type
 bool
 send_contact(chat_id: int | str, phone_number: str, first_name: str, last_name: str | None = None, vcard:
 str | None = None, disable_notification: bool | None = None, reply_to_message_id: int | None
 = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup |
 ReplyKeyboardRemove | ForceReply | None = None, timeout: int | None = None,
 allow_sending_without_reply: bool | None = None, protect_content: bool | None = None,
 message_thread_id: int | None = None, reply_parameters: ReplyParameters | None = None,
 business_connection_id: str | None = None, message_effect_id: str | None = None,
 allow_paid_broadcast: bool | None = None) → Message
 Use this method to send phone contacts. On success, the sent Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendcontact
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel
 • phone_number (str) – Contact’s phone number
 • first_name (str) – Contact’s first name
 • last_name (str) – Contact’s last name
 • vcard (str) – Additional data about the contact in the form of a vCard, 0-2048 bytes
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • timeout (int) – Timeout in seconds for the request.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – The thread identifier of a message from which the reply will
 be sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection
 • message_effect_id (str) – Unique identifier of the message effect to be added to the
 message; for private chats only
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 send_dice(chat_id: int | str, emoji: str | None = None, disable_notification: bool | None = None,
 reply_to_message_id: int | None = None, reply_markup: InlineKeyboardMarkup |
 ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None = None, timeout: int | None
 = None, allow_sending_without_reply: bool | None = None, protect_content: bool | None = None,
 message_thread_id: int | None = None, reply_parameters: ReplyParameters | None = None,
 business_connection_id: str | None = None, message_effect_id: str | None = None,
 allow_paid_broadcast: bool | None = None) → Message
 Use this method to send an animated emoji that will display a random value. On success, the sent Message
 is returned.
 Telegram documentation: https://core.telegram.org/bots/api#senddice
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • emoji (str) – Emoji on which the dice throw animation is based. Currently, must be one
 of “”, “”, “”, “”, “”, or “”. Dice can have values 1-6 for “”, “” and “”, values 1-5 for “” and
 “”, and values 1-64 for “”. Defaults to “”
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • timeout (int) – Timeout in seconds for the request.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – Identifier of a message thread, in which the message will be
 sent
 • reply_parameters (telebot.types.ReplyParameters) – Additional parameters for
 replies to messages
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 • message_effect_id (str) – Unique identifier of the message effect to be added to the
 message; for private chats only
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 send_document(chat_id: int | str, document: Any | str, reply_to_message_id: int | None = None, caption: str
 | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup |
 ReplyKeyboardRemove | ForceReply | None = None, parse_mode: str | None = None,
 disable_notification: bool | None = None, timeout: int | None = None, thumbnail: str | Any |
 None = None, caption_entities: List[MessageEntity] | None = None,
 allow_sending_without_reply: bool | None = None, visible_file_name: str | None = None,
 disable_content_type_detection: bool | None = None, data: str | Any | None = None,
 protect_content: bool | None = None, message_thread_id: int | None = None, thumb: str |
 Any | None = None, reply_parameters: ReplyParameters | None = None,
 business_connection_id: str | None = None, message_effect_id: str | None = None,
 allow_paid_broadcast: bool | None = None) → Message
 Use this method to send general files.
 Telegram documentation: https://core.telegram.org/bots/api#senddocument
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • document (str or telebot.types.InputFile) – (document) File to send. Pass a file_id
 as String to send a file that exists on the Telegram servers (recommended), pass an HTTP
 URL as a String for Telegram to get a file from the Internet, or upload a new one using
 multipart/form-data
 • caption (str) – Document caption (may also be used when resending documents by
 file_id), 0-1024 characters after entities parsing
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • parse_mode (str) – Mode for parsing entities in the document caption
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • timeout (int) – Timeout in seconds for the request.
 • thumbnail (str or telebot.types.InputFile) – InputFile or String : 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>
 • caption_entities (list of telebot.types.MessageEntity) – A JSON-serialized
 list of special entities that appear in the caption, which can be specified instead of
 parse_mode
 • visible_file_name (str) – allows to define file name that will be visible in the Telegram
 instead of original file name
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – The identifier of a message thread, in which the game mes-
 sage will be sent.
 • reply_parameters (ReplyParameters) – Reply parameters
 • business_connection_id (str) – Unique identifier of the business connection
 • message_effect_id (str) – Unique identifier of the message effect
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 types.Message
 send_gift(user_id: int, gift_id: str, text: str | None = None, text_parse_mode: str | None = None,
 text_entities: List[MessageEntity] | None = None, pay_for_upgrade: bool | None = None) → bool
 Sends a gift to the given user. The gift can’t be converted to Telegram Stars by the user. Returns True on
 success.
 Telegram documentation: https://core.telegram.org/bots/api#sendgift
 Parameters
 • user_id (int) – Unique identifier of the target user that will receive the gift
 • gift_id (str) – Identifier of the gift
 • pay_for_upgrade (bool) – Pass True to pay for the gift upgrade from the bot’s balance,
 thereby making the upgrade free for the receiver
 • text (str) – Text that will be shown along with the gift; 0-255 characters
 • text_parse_mode (str) – Mode for parsing entities in the text. See formatting options for
 more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”,
 and “custom_emoji” are ignored.
 • text_entities (list of types.MessageEntity) – A JSON-serialized list of special
 entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities
 other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji”
 are ignored.
 Returns
 Returns True on success.
 Return type
 bool
 send_invoice(chat_id: int | str, title: str, description: str, invoice_payload: str, provider_token: str | None,
 currency: str, prices: List[LabeledPrice], start_parameter: str | None = None, photo_url: str
 | None = None, photo_size: int | None = None, photo_width: int | None = None, photo_height:
 int | None = None, need_name: bool | None = None, need_phone_number: bool | None =
 None, need_email: bool | None = None, need_shipping_address: bool | None = None,
 send_phone_number_to_provider: bool | None = None, send_email_to_provider: bool | None
 = None, is_flexible: bool | None = None, disable_notification: bool | None = None,
 reply_to_message_id: int | None = None, reply_markup: InlineKeyboardMarkup |
 ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None = None, provider_data:
 str | None = None, timeout: int | None = None, allow_sending_without_reply: bool | None =
 None, max_tip_amount: int | None = None, suggested_tip_amounts: List[int] | None = None,
 protect_content: bool | None = None, message_thread_id: int | None = None,
 reply_parameters: ReplyParameters | None = None, message_effect_id: str | None = None,
 allow_paid_broadcast: bool | None = None) → Message
 Sends invoice.
 Telegram documentation: https://core.telegram.org/bots/api#sendinvoice
 Parameters
 • chat_id (int or str) – Unique identifier for the target private chat
 • title (str) – Product name, 1-32 characters
 • description (str) – Product description, 1-255 characters
 • invoice_payload (str) – Bot-defined invoice payload, 1-128 bytes. This will not be
 displayed to the user, use for your internal processes.
 • provider_token (str) – Payments provider token, obtained via @Botfather; Pass None
 to omit the parameter to use “XTR” currency
 • currency (str) – Three-letter ISO 4217 currency code, see https://core.telegram.org/
 bots/payments#supported-currencies
 • prices (List[types.LabeledPrice]) – Price breakdown, a list of components (e.g. prod-
 uct price, tax, discount, delivery cost, delivery tax, bonus, etc.)
 • start_parameter (str) – Unique deep-linking parameter that can be used to generate
 this invoice when used as a start parameter
 • photo_url (str) – URL of the product photo for the invoice. Can be a photo of the goods
 or a marketing image for a service. People like it better when they see what they are paying
 for.
 • photo_size (int) – Photo size in bytes
 • photo_width (int) – Photo width
 • photo_height (int) – Photo height
 • need_name (bool) – Pass True, if you require the user’s full name to complete the order
 • need_phone_number (bool) – Pass True, if you require the user’s phone number to com-
 plete the order
 • need_email (bool) – Pass True, if you require the user’s email to complete the order
 • need_shipping_address (bool) – Pass True, if you require the user’s shipping address
 to complete the order
 • is_flexible (bool) – Pass True, if the final price depends on the shipping method
 Use this method to send point on the map. On success, the sent Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendlocation
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • latitude (float) – Latitude of the location
 • longitude (float) – Longitude of the location
 • live_period (int) – Period in seconds during which the location will be updated (see
 Live Locations, should be between 60 and 86400, or 0x7FFFFFFF for live locations that
 can be edited indefinitely.
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • timeout (int) – Timeout in seconds for the request.
 • horizontal_accuracy (float) – The radius of uncertainty for the location, measured
 in meters; 0-1500
 • heading (int) – For live locations, a direction in which the user is moving, in degrees.
 Must be between 1 and 360 if specified.
 • proximity_alert_radius (int) – For live locations, a maximum distance for proximity
 alerts about approaching another chat member, in meters. Must be between 1 and 100000
 if specified.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – Identifier of a message thread, in which the message will be
 sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 • message_effect_id (str) – Unique identifier of the message effect to be added to the
 message; for private chats only
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 send_media_group(chat_id: int | str, media: List[InputMediaAudio | InputMediaDocument |
 InputMediaPhoto | InputMediaVideo], disable_notification: bool | None = None,
 protect_content: bool | None = None, reply_to_message_id: int | None = None, timeout:
 int | None = None, allow_sending_without_reply: bool | None = None,
 message_thread_id: int | None = None, reply_parameters: ReplyParameters | None =
 None, business_connection_id: str | None = None, message_effect_id: str | None =
 None, allow_paid_broadcast: bool | None = None) → List[Message]
 Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio
 files can be only grouped in an album with messages of the same type. On success, an array of Messages
 that were sent is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendmediagroup
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • media (list of types.InputMedia) – A JSON-serialized array describing messages to
 be sent, must include 2-10 items
 • disable_notification (bool) – Sends the messages silently. Users will receive a no-
 tification with no sound.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • timeout (int) – Timeout in seconds for the request.
 • message_thread_id (int) – Identifier of a message thread, in which the media group
 will be sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 • message_effect_id (str) – Unique identifier of the message effect to be added to the
 message; for private chats only
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, an array of Messages that were sent is returned.
 Return type
 List[types.Message]
 send_message(chat_id: int | str, text: str, parse_mode: str | None = None, entities: List[MessageEntity] |
 None = None, disable_web_page_preview: bool | None = None, disable_notification: bool |
 None = None, protect_content: bool | None = None, reply_to_message_id: int | None = None,
 allow_sending_without_reply: bool | None = None, reply_markup: InlineKeyboardMarkup |
 ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None = None, timeout: int |
 None = None, message_thread_id: int | None = None, reply_parameters: ReplyParameters |
 None = None, link_preview_options: LinkPreviewOptions | None = None,
 business_connection_id: str | None = None, message_effect_id: str | None = None,
 allow_paid_broadcast: bool | None = None) → Message
 Use this method to send text messages.
 Warning: Do not send more than about 4096 characters each message, otherwise you’ll risk an HTTP 414
 error. If you must send more than 4096 characters, use the split_string or smart_split function in util.py.
 Telegram documentation: https://core.telegram.org/bots/api#sendmessage
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • text (str) – Text of the message to be sent
 • parse_mode (str) – Mode for parsing entities in the message text.
 • entities (Array of telebot.types.MessageEntity) – List of special entities that ap-
 pear in message text, which can be specified instead of parse_mode
 • disable_web_page_preview (bool) – deprecated.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • timeout (int) – Timeout in seconds for the request.
 • message_thread_id (int) – Identifier of a message thread, in which the message will be
 sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • link_preview_options (telebot.types.LinkPreviewOptions) – Link preview op-
 tions.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 • message_effect_id (str) – Unique identifier of the message effect to be added to the
 message; for private chats only
 • explanation (str) – 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 with at most 2 line feeds after entities
 parsing
 • explanation_parse_mode (str) – Mode for parsing entities in the explanation. See
 formatting options for more details.
 • open_period (int) – Amount of time in seconds the poll will be active after creation,
 5-600. Can’t be used together with close_date.
 • close_date (int | datetime) – Point in time (Unix timestamp) when the poll will be
 automatically closed.
 • is_closed (bool) – Pass True, if the poll needs to be immediately closed. This can be
 useful for poll preview.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – deprecated. If the message is a reply, ID of the original
 message
 • allow_sending_without_reply (bool) – deprecated. Pass True, if the message should
 be sent even if the specified replied-to message is not found
 • reply_markup (InlineKeyboardMarkup | ReplyKeyboardMarkup |
 ReplyKeyboardRemove | ForceReply) – Additional interface options. A JSON-
 serialized object for an inline keyboard, custom reply keyboard, instructions to remove
 reply keyboard or to force a reply from the user.
 • timeout (int) – Timeout in seconds for waiting for a response from the user.
 • explanation_entities (list of MessageEntity) – A JSON-serialized list of special
 entities that appear in the explanation, which can be specified instead of parse_mode
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – The identifier of a message thread, in which the poll will be
 sent
 • reply_parameters (ReplyParameters) – reply parameters.
 • business_connection_id (str) – Identifier of the business connection to use for the
 poll
 • question_parse_mode (str) – Mode for parsing entities in the question. See formatting
 options for more details. Currently, only custom emoji entities are allowed
 • question_entities (list of MessageEntity) – A JSON-serialized list of special en-
 tities that appear in the poll question. It can be specified instead of question_parse_mode
 • message_effect_id (str) – Unique identifier of the message effect to apply to the sent
 message
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 types.Message
 send_sticker(chat_id: int | str, sticker: Any | str, reply_to_message_id: int | None = None, reply_markup:
 InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply |
 None = None, disable_notification: bool | None = None, timeout: int | None = None,
 allow_sending_without_reply: bool | None = None, protect_content: bool | None = None,
 data: Any | str = None, message_thread_id: int | None = None, emoji: str | None = None,
 reply_parameters: ReplyParameters | None = None, business_connection_id: str | None =
 None, message_effect_id: str | None = None, allow_paid_broadcast: bool | None = None) →
 Message
 Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent
 Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendsticker
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • sticker (str or telebot.types.InputFile) – Sticker to send. Pass a file_id as String
 to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as
 a String for Telegram to get a .webp file from the Internet, or upload a new one using
 multipart/form-data.
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • disable_notification (bool) – to disable the notification
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • timeout (int) – Timeout in seconds for the request.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • data (str) – function typo miss compatibility: do not use it
 • message_thread_id (int) – The thread to which the message will be sent
 • emoji (str) – Emoji associated with the sticker; only for just uploaded stickers
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 • message_effect_id (str) – Unique identifier of the message effect to be added to the
 message; for private chats only
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 send_venue(chat_id: int | str, latitude: float | None, longitude: float | None, title: str, address: str,
 foursquare_id: str | None = None, foursquare_type: str | None = None, disable_notification:
 bool | None = None, reply_to_message_id: int | None = None, reply_markup:
 InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None
 = None, timeout: int | None = None, allow_sending_without_reply: bool | None = None,
 google_place_id: str | None = None, google_place_type: str | None = None, protect_content:
 bool | None = None, message_thread_id: int | None = None, reply_parameters:
 ReplyParameters | None = None, business_connection_id: str | None = None,
 message_effect_id: str | None = None, allow_paid_broadcast: bool | None = None) → Message
 Use this method to send information about a venue. On success, the sent Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendvenue
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel
 • latitude (float) – Latitude of the venue
 • longitude (float) – Longitude of the venue
 • title (str) – Name of the venue
 • address (str) – Address of the venue
 • foursquare_id (str) – Foursquare identifier of the venue
 • foursquare_type (str) – Foursquare type of the venue, if known. (For example,
 “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • timeout (int) – Timeout in seconds for the request.
 • google_place_id (str) – Google Places identifier of the venue
 • google_place_type (str) – Google Places type of the venue.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – The thread identifier of a message from which the reply will
 be sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection
 • message_effect_id (str) – Unique identifier of the message effect to be added to the
 message; for private chats only
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • timeout (int) – Timeout in seconds for the request.
 • data (str) – function typo miss compatibility: do not use it
 • message_thread_id (int) – Identifier of a message thread, in which the video will be
 sent
 • has_spoiler (bool) – Pass True, if the video should be sent as a spoiler
 • thumb (str or telebot.types.InputFile) – deprecated.
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters
 • business_connection_id (str) – Identifier of a business connection
 • message_effect_id (str) – Identifier of a message effect
 • show_caption_above_media (bool) – Pass True, if the caption must be shown above
 the message media. Supported only for animation, photo and video messages.
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 send_video_note(chat_id: int | str, data: Any | str, duration: int | None = None, length: int | None = None,
 reply_to_message_id: int | None = None, reply_markup: InlineKeyboardMarkup |
 ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None = None,
 disable_notification: bool | None = None, timeout: int | None = None, thumbnail: str |
 Any | None = None, allow_sending_without_reply: bool | None = None, protect_content:
 bool | None = None, message_thread_id: int | None = None, thumb: str | Any | None =
 None, reply_parameters: ReplyParameters | None = None, business_connection_id: str |
 None = None, message_effect_id: str | None = None, allow_paid_broadcast: bool | None
 = None) → Message
 As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this
 method to send video messages. On success, the sent Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendvideonote
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 send_voice(chat_id: int | str, voice: Any | str, caption: str | None = None, duration: int | None = None,
 reply_to_message_id: int | None = None, reply_markup: InlineKeyboardMarkup |
 ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None = None, parse_mode: str |
 None = None, disable_notification: bool | None = None, timeout: int | None = None,
 caption_entities: List[MessageEntity] | None = None, allow_sending_without_reply: bool |
 None = None, protect_content: bool | None = None, message_thread_id: int | None = None,
 reply_parameters: ReplyParameters | None = None, business_connection_id: str | None = None,
 message_effect_id: str | None = None, allow_paid_broadcast: bool | None = None) → Message
 Use this method to send audio files, if you want Telegram clients to display the file as a playable voice
 message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format,
 or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is
 returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the
 future.
 Telegram documentation: https://core.telegram.org/bots/api#sendvoice
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • voice (str or telebot.types.InputFile) – Audio file to send. Pass a file_id as String
 to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a
 String for Telegram to get a file from the Internet, or upload a new one using multipart/form-
 data.
 • caption (str) – Voice message caption, 0-1024 characters after entities parsing
 • duration (int) – Duration of the voice message in seconds
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • parse_mode (str) – Mode for parsing entities in the voice message caption. See format-
 ting options for more details.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – deprecated.
 • allow_sending_without_reply (bool) – deprecated.
 • timeout (int) – Timeout in seconds for the request.
 • caption_entities (list of telebot.types.MessageEntity) – A JSON-serialized
 list of special entities that appear in the caption, which can be specified instead of
 parse_mode
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – Identifier of a message thread, in which the message will be
 sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 Returns
 True on success.
 Return type
 bool
 set_chat_permissions(chat_id: int | str, permissions: ChatPermissions,
 use_independent_chat_permissions: bool | None = None) → bool
 Use this method to set default chat permissions for all members. The bot must be an administrator in the
 group or a supergroup for this to work and must have the can_restrict_members admin rights.
 Telegram documentation: https://core.telegram.org/bots/api#setchatpermissions
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • permissions (telebot.types..ChatPermissions) – New default chat permissions
 • use_independent_chat_permissions (bool) – Pass True if chat permis-
 sions are set independently. Otherwise, the can_send_other_messages and
 can_add_web_page_previews permissions will imply the can_send_messages,
 can_send_audios, can_send_documents, can_send_photos, can_send_videos,
 can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls
 permission will imply the can_send_messages permission.
 Returns
 True on success
 Return type
 bool
 set_chat_photo(chat_id: int | str, photo: Any) → bool
 Use this method to set a new profile photo for the chat. Photos can’t be changed for private chats. The bot
 must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns
 True on success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members
 Are Admins’ setting is off in the target group.
 Telegram documentation: https://core.telegram.org/bots/api#setchatphoto
 Parameters
 • chat_id (int or str) – Int or Str: Unique identifier for the target chat or username of the
 target channel (in the format @channelusername)
 • photo (typing.Union[file_like, str]) – InputFile: New chat photo, uploaded using
 multipart/form-data
 Returns
 True on success.
 Return type
 bool
 set_chat_sticker_set(chat_id: int | str, sticker_set_name: str) → StickerSet
 Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the
 chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set
 optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setchatstickerset
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • sticker_set_name (str) – Name of the sticker set to be set as the group sticker set
 Returns
 StickerSet object
 Return type
 telebot.types.StickerSet
 set_chat_title(chat_id: int | str, title: str) → bool
 Use this method to change the title of a chat. Titles can’t be changed for private chats. The bot must be
 an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on
 success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are
 Admins’ setting is off in the target group.
 Telegram documentation: https://core.telegram.org/bots/api#setchattitle
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • title (str) – New chat title, 1-255 characters
 Returns
 True on success.
 Return type
 bool
 set_custom_emoji_sticker_set_thumbnail(name: str, custom_emoji_id: str | None = None) → bool
 Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success.
 Parameters
 • name (str) – Sticker set name
 • custom_emoji_id (str) – Custom emoji identifier of a sticker from the sticker set; pass
 an empty string to drop the thumbnail and use the first sticker as the thumbnail.
 Returns
 Returns True on success.
 Return type
 bool
 set_game_score(user_id: int | str, score: int, force: bool | None = None, chat_id: int | str | None = None,
 message_id: int | None = None, inline_message_id: str | None = None,
 disable_edit_message: bool | None = None) → Message | bool
 Sets the value of points in the game to a specific user.
 Telegram documentation: https://core.telegram.org/bots/api#setgamescore
 Parameters
 • user_id (int or str) – User identifier
 • score (int) – New score, must be non-negative
 • force (bool) – Pass True, if the high score is allowed to decrease. This can be useful
 when fixing mistakes or banning cheaters
 Returns
 True on success.
 Return type
 bool
 set_my_default_administrator_rights(rights: ChatAdministratorRights = None, for_channels: bool |
 None = None) → bool
 Use this method to change the default administrator rights requested by the bot when it’s added as an
 administrator to groups or channels. These rights will be suggested to users, but they are are free to modify
 the list before adding the bot. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setmydefaultadministratorrights
 Parameters
 • rights (telebot.types.ChatAdministratorRights) – A JSON-serialized object de-
 scribing new default administrator rights. If not specified, the default administrator rights
 will be cleared.
 • for_channels (bool) – Pass True to change the default administrator rights of the bot in
 channels. Otherwise, the default administrator rights of the bot for groups and supergroups
 will be changed.
 Returns
 True on success.
 Return type
 bool
 set_my_description(description: str | None = None, language_code: str | None = None)
 Use this method to change the bot’s description, which is shown in the chat with the bot if the chat is empty.
 Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setmydescription
 Parameters
 • description (str) – New bot description; 0-512 characters. Pass an empty string to
 remove the dedicated description for the given language.
 • language_code (str) – A two-letter ISO 639-1 language code. If empty, the description
 will be applied to all users for whose language there is no dedicated description.
 Returns
 True on success.
 set_my_name(name: str | None = None, language_code: str | None = None)
 Use this method to change the bot’s name. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setmyname
 Parameters
 • name (str) – Optional. New bot name; 0-64 characters. Pass an empty string to remove
 the dedicated name for the given language.
 • language_code (str) – Optional. A two-letter ISO 639-1 language code. If empty, the
 name will be shown to all users for whose language there is no dedicated name.
 Returns
 True on success.
ò Note
 You should set both user id and chat id in order to set state for a user in a chat. Otherwise, if you only
 set user_id, chat_id will equal to user_id, this means that state will be set for the user in his private chat
 with a bot.
 Changed in version 4.23.0: Added additional parameters to support topics, business connections, and mes-
 sage threads.
ã See also
 Parameters
 • user_id (int) – User’s identifier
 • state (int or str or telebot.types.State) – new state. can be string, or telebot.
 types.State
 • chat_id (int) – Chat’s identifier
 • bot_id (int) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str) – Business identifier
 • message_thread_id (int) – Identifier of the message thread
 Returns
 True on success
 Return type
 bool
set_sticker_set_thumb(**kwargs)
 set_sticker_set_thumbnail(name: str, user_id: int, thumbnail: Any | str = None, format: str | None =
 None) → bool
 Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker
 sets only. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setstickersetthumbnail
 Parameters
 • name (str) – Sticker set name
 • user_id (int) – User identifier
 • thumbnail (filelike object) – A .WEBP or .PNG image with the thumbnail, must be
 up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS ani-
 mation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#
 animated-sticker-requirements for animated sticker technical requirements), or a WEBM
 video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#
 video-sticker-requirements for video sticker technical requirements. Pass a file_id as a
 String to send a file that already exists on the Telegram servers, pass an HTTP URL as a
 String for Telegram to get a file from the Internet, or upload a new one using multipart/form-
 data. More information on Sending Files ». Animated and video sticker set thumbnails
 can’t be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first
 sticker is used as the thumbnail.
 • format (str) – Format of the thumbnail, must be one of “static” for a .WEBP or .PNG
 image, “animated” for a .TGS animation, or “video” for a WEBM video
 Returns
 On success, True is returned.
 Return type
 bool
 set_sticker_set_title(name: str, title: str) → bool
 Use this method to set the title of a created sticker set. Returns True on success.
 Parameters
 • name (str) – Sticker set name
 • title (str) – New sticker set title
 Returns
 Returns True on success.
 Return type
 bool
 set_update_listener(listener: Callable)
 Sets a listener function to be called when a new update is received.
 Parameters
 listener (Callable) – Listener function.
 set_user_emoji_status(user_id: int, emoji_status_custom_emoji_id: str | None = None,
 emoji_status_expiration_date: int | None = None) → bool
 Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via
 the Mini App method requestEmojiStatusAccess. Returns True on success.
 Returns
 True on success.
 Return type
 bool if the request was successful.
 setup_middleware(middleware: BaseMiddleware)
 Registers class-based middleware.
 Parameters
 middleware (telebot.handler_backends.BaseMiddleware) – Subclass of telebot.
 handler_backends.BaseMiddleware
 Returns
 None
 shipping_query_handler(func, **kwargs)
 Handles new incoming shipping query. Only for invoices with flexible price. As a parameter to the decorator
 function, it passes telebot.types.ShippingQuery object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 stop_bot()
 Stops bot by stopping polling and closing the worker pool.
 stop_message_live_location(chat_id: int | str | None = None, message_id: int | None = None,
 inline_message_id: str | None = None, reply_markup:
 InlineKeyboardMarkup | None = None, timeout: int | None = None,
 business_connection_id: str | None = None) → Message
 Use this method to stop updating a live location message before live_period expires. On success, if the
 message is not an inline message, the edited Message is returned, otherwise True is returned.
 Telegram documentation: https://core.telegram.org/bots/api#stopmessagelivelocation
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the mes-
 sage with live location to stop
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message with live location to stop
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – A JSON-serialized object for a new inline keyboard.
 • timeout (int) – Timeout in seconds for the request.
 • business_connection_id (str) – Identifier of a business connection
 Returns
 On success, if the message is not an inline message, the edited Message is returned, otherwise
 True is returned.
 Return type
 telebot.types.Message or bool
 stop_poll(chat_id: int | str, message_id: int, reply_markup: InlineKeyboardMarkup | None = None,
 business_connection_id: str | None = None) → Poll
 Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
 Telegram documentation: https://core.telegram.org/bots/api#stoppoll
 Parameters
 • chat_id (int | str) – Unique identifier for the target chat or username of the target channel
 • message_id (int) – Identifier of the original message with the poll
 • reply_markup (InlineKeyboardMarkup) – A JSON-serialized object for a new message
 markup.
 • business_connection_id (str) – Identifier of the business connection to use for the
 poll
 Returns
 On success, the stopped Poll is returned.
 Return type
 types.Poll
 stop_polling()
 Stops polling.
 Does not accept any arguments.
 unban_chat_member(chat_id: int | str, user_id: int, only_if_banned: bool | None = False) → bool
 Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to
 the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator
 for this to work. By default, this method guarantees that after the call the user is not a member of the chat,
 but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If
 you don’t want this, use the parameter only_if_banned.
 Telegram documentation: https://core.telegram.org/bots/api#unbanchatmember
 Parameters
 • chat_id (int or str) – Unique identifier for the target group or username of the target
 supergroup or channel (in the format @username)
 • user_id (int) – Unique identifier of the target user
 • only_if_banned (bool) – Do nothing if the user is not banned
 Returns
 True on success
 Return type
 bool
 unban_chat_sender_chat(chat_id: int | str, sender_chat_id: int | str) → bool
 Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an
 administrator for this to work and must have the appropriate administrator rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unbanchatsenderchat
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • sender_chat_id (int or str) – Unique identifier of the target sender chat.
 Returns
 True on success.
 Return type
 bool
 unhide_general_forum_topic(chat_id: int | str) → bool
 Use this method to unhide the ‘General’ topic in a forum supergroup chat. The bot must be an administrator
 in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unhidegeneralforumtopic
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target channel
 (in the format @channelusername)
 unpin_all_chat_messages(chat_id: int | str) → bool
 Use this method to unpin a all pinned messages in a supergroup chat. The bot must be an administrator in
 the chat for this to work and must have the appropriate admin rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unpinallchatmessages
 Parameters
 chat_id (int or str) – Int or Str: Unique identifier for the target chat or username of the
 target channel (in the format @channelusername)
 Returns
 True on success.
 Return type
 bool
 unpin_all_forum_topic_messages(chat_id: str | int, message_thread_id: int) → bool
 Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator
 in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
 Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unpinallforumtopicmessages
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_thread_id (int) – Identifier of the topic
 Returns
 On success, True is returned.
 Return type
 bool
 unpin_all_general_forum_topic_messages(chat_id: int | str) → bool
 Use this method to clear the list of pinned messages in a General forum topic. The bot must be an adminis-
 trator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
 Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unpinAllGeneralForumTopicMessages
 Parameters
 chat_id (int | str) – Unique identifier for the target chat or username of chat
 Returns
 On success, True is returned.
 Return type
 bool
 unpin_chat_message(chat_id: int | str, message_id: int | None = None, business_connection_id: str | None
 = None) → bool
 Use this method to unpin specific pinned message in a supergroup chat. The bot must be an administrator
 in the chat for this to work and must have the appropriate admin rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unpinchatmessage
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Int: Identifier of a message to unpin
 • business_connection_id (str) – Unique identifier of the business connection
 Returns
 True on success.
 Return type
 bool
 upload_sticker_file(user_id: int, png_sticker: Any | str = None, sticker: InputFile | None = None,
 sticker_format: str | None = None) → File
 Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet
 methods (can be used multiple times). Returns the uploaded File on success.
 Telegram documentation: https://core.telegram.org/bots/api#uploadstickerfile
 Parameters
 • user_id (int) – User identifier of sticker set owner
 • png_sticker (filelike object) – DEPRECATED: PNG image with the sticker, must
 be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or
 height must be exactly 512px.
 • sticker (telebot.types.InputFile) – A file with the sticker in .WEBP, .PNG, .TGS,
 or .WEBM format. See https://core.telegram.org/stickers for technical requirements. More
 information on Sending Files »
 • sticker_format (str) – One of “static”, “animated”, “video”.
 Returns
 On success, the sent file is returned.
 Return type
 telebot.types.File
 property user: User
 The User object representing this bot. Equivalent to bot.get_me() but the result is cached so only one API
 call is needed.
 Returns
 Bot’s info.
 Return type
 telebot.types.User
 verify_chat(chat_id: int | str, custom_description: str | None = None) → bool
 Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#verifychat
 Parameters
 • chat_id (int | str) – Unique identifier for the target chat or username of the target channel
 (in the format @channelusername)
 • custom_description (str) – Custom description for the verification; 0-70 characters.
 Must be empty if the organization isn’t allowed to provide a custom verification description.
 Returns
 Returns True on success.
 Return type
 bool
 verify_user(user_id: int, custom_description: str | None = None) → bool
 Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#verifyuser
 Parameters
 • user_id (int) – Unique identifier of the target user
 • custom_description (str) – Custom description for the verification; 0-70 characters.
 Must be empty if the organization isn’t allowed to provide a custom verification description.
 Returns
 Returns True on success.
 Return type
 bool
custom_filters file
class telebot.custom_filters.AdvancedCustomFilter
 Bases: ABC
 Advanced Custom Filter base class. Create child class with check() method. Accepts two parameters, returns
 bool: True - filter passed, False - filter failed. message: Message class text: Filter value given in handler
 Child classes should have .key property.
 check(message, text)
 Perform a check.
class telebot.custom_filters.ChatFilter
 Bases: AdvancedCustomFilter
 Check whether chat_id corresponds to given chat_id.
class telebot.custom_filters.ForwardFilter
 Bases: SimpleCustomFilter
 Check whether message was forwarded from channel or group.
class telebot.custom_filters.IsAdminFilter(bot)
 Bases: SimpleCustomFilter
 Check whether the user is administrator / owner of the chat.
class telebot.custom_filters.IsDigitFilter
 Bases: SimpleCustomFilter
 Filter to check whether the string is made up of only digits.
class telebot.custom_filters.IsReplyFilter
 Bases: SimpleCustomFilter
 Check whether message is a reply.
class telebot.custom_filters.LanguageFilter
 Bases: AdvancedCustomFilter
 Check users language_code.
class telebot.custom_filters.SimpleCustomFilter
 Bases: ABC
 Simple Custom Filter base class. Create child class with check() method. Accepts only message, returns bool
 value, that is compared with given in handler.
 Child classes should have .key property.
 check(message)
 Perform a check.
 key: str = None
class telebot.custom_filters.StateFilter(bot)
 Bases: AdvancedCustomFilter
 Filter to check state.
class telebot.custom_filters.TextContainsFilter
 Bases: AdvancedCustomFilter
 Filter to check Text message. key: text
class telebot.custom_filters.TextFilter(equals: str | None = None, contains: list | tuple | None = None,
 starts_with: str | list | tuple | None = None, ends_with: str | list |
 tuple | None = None, ignore_case: bool = False)
 Bases: object
 Advanced text filter to check (types.Message, types.CallbackQuery, types.InlineQuery, types.Poll)
 example of usage is in examples/custom_filters/advanced_text_filter.py
 Parameters
 • equals (str) – string, True if object’s text is equal to passed string
 • contains (list[str] or tuple[str]) – list[str] or tuple[str], True if any string element
 of iterable is in text
 • starts_with (str) – string, True if object’s text starts with passed string
 • ends_with (str) – string, True if object’s text starts with passed string
 • ignore_case (bool) – bool (default False), case insensitive
 Raises
 ValueError – if incorrect value for a parameter was supplied
 Returns
 None
class telebot.custom_filters.TextMatchFilter
 Bases: AdvancedCustomFilter
 Filter to check Text message.
class telebot.custom_filters.TextStartsFilter
 Bases: AdvancedCustomFilter
 Filter to check whether message starts with some text.
handler_backends file
class telebot.handler_backends.BaseMiddleware
 Bases: object
 Base class for middleware. Your middlewares should be inherited from this class.
 Set update_sensitive=True if you want to get different updates on different functions. For example, if you want
 to handle pre_process for message update, then you will have to create pre_process_message function, and so
 on. Same applies to post_process.
ò Note
If you want to use middleware, you have to set use_class_middlewares=True in your TeleBot instance.
pre_process(message, data)
class telebot.handler_backends.CancelUpdate
 Bases: object
 Class for canceling updates. Just return instance of this class in middleware to skip update. Update will skip
 handler and execution of post_process in middlewares.
class telebot.handler_backends.ContinueHandling
 Bases: object
 Class for continue updates in handlers. Just return instance of this class in handlers to continue process.
 @bot.message_handler(commands=['start'])
 def start2(message):
 bot.send_message(message.chat.id, 'Hello World2!')
class telebot.handler_backends.SkipHandler
 Bases: object
 Class for skipping handlers. Just return instance of this class in middleware to skip handler. Update will go to
 post_process, but will skip execution of handler.
Extensions
1.3.5 AsyncTeleBot
AsyncTeleBot methods
class telebot.async_telebot.AsyncTeleBot(token: str, parse_mode: str | None = None, offset: int | None =
 None, exception_handler:
 ~telebot.async_telebot.ExceptionHandler | None = None,
 state_storage:
 ~telebot.asyncio_storage.base_storage.StateStorageBase |
 None = <tele-
 bot.asyncio_storage.memory_storage.StateMemoryStorage
 object>, disable_web_page_preview: bool | None = None,
 disable_notification: bool | None = None, protect_content:
 bool | None = None, allow_sending_without_reply: bool | None
 = None, colorful_logs: bool | None = False, validate_token:
 bool | None = True)
 Bases: object
 This is the main asynchronous class for Bot.
 It allows you to add handlers for different kind of updates.
 Usage:
ò Note
 Parameters
 • token (str) – Token of a bot, obtained from @BotFather
 • parse_mode (str, optional) – Default parse mode, defaults to None
 • offset (int, optional) – Offset used in get_updates, defaults to None
 • exception_handler (Optional[ExceptionHandler], optional) – Exception han-
 dler, which will handle the exception occured, defaults to None
 • state_storage (telebot.asyncio_storage.StateMemoryStorage, optional) – Stor-
 age for states, defaults to StateMemoryStorage()
 • disable_web_page_preview (bool, optional) – Default value for dis-
 able_web_page_preview, defaults to None
 • disable_notification (bool, optional) – Default value for disable_notification, defaults
 to None
 • protect_content (bool, optional) – Default value for protect_content, defaults to None
 • allow_sending_without_reply (bool, optional) – Deprecated - Use reply_parameters
 instead. Default value for allow_sending_without_reply, defaults to None
 • colorful_logs (bool, optional) – Outputs colorful logs
 • validate_token (bool, optional) – Validate token, defaults to True;
 Raises
 • ImportError – If coloredlogs module is not installed and colorful_logs is True
 • ValueError – If token is invalid
 Parameters
 custom_filter (telebot.asyncio_filters.SimpleCustomFilter or telebot.
 asyncio_filters.AdvancedCustomFilter) – Class with check(message) method.
 Returns
 None
 async add_data(user_id: int, chat_id: int | None = None, business_connection_id: str | None = None,
 message_thread_id: int | None = None, bot_id: int | None = None, **kwargs) → None
 Add data to states.
 Parameters
 • user_id (int) – User’s identifier
 • chat_id (int) – Chat’s identifier
 • bot_id (int) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str) – Business identifier
 • message_thread_id (int) – Identifier of the message thread
 • kwargs – Data to add
 Returns
 None
 async add_sticker_to_set(user_id: int, name: str, emojis: List[str] | str = None, png_sticker: str | Any |
 None = None, tgs_sticker: str | Any | None = None, webm_sticker: str | Any |
 None = None, mask_position: MaskPosition | None = None, sticker:
 InputSticker | None = None) → bool
 Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match
 the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and
 video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True
 on success.
ò Note
 Return type
 bool
 async answer_callback_query(callback_query_id: int, text: str | None = None, show_alert: bool | None
 = None, url: str | None = None, cache_time: int | None = None) → bool
 Use this method to send answers to callback queries sent from inline keyboards. The answer will be dis-
 played to the user as a notification at the top of the chat screen or as an alert.
 Telegram documentation: https://core.telegram.org/bots/api#answercallbackquery
 Parameters
 • callback_query_id (int) – Unique identifier for the query to be answered
 • text (str) – Text of the notification. If not specified, nothing will be shown to the user,
 0-200 characters
 • show_alert (bool) – If True, an alert will be shown by the client instead of a notification
 at the top of the chat screen. Defaults to false.
 • url (str) – URL that will be opened by the user’s client. If you have created a Game and
 accepted the conditions via @BotFather, specify the URL that opens your game - note that
 this will only work if the query comes from a callback_game button.
 • cache_time – The maximum amount of time in seconds that the result of the callback
 query may be cached client-side. Telegram apps will support caching starting in version
 3.14. Defaults to 0.
 Returns
 On success, True is returned.
 Return type
 bool
 async answer_inline_query(inline_query_id: str, results: List[Any], cache_time: int | None = None,
 is_personal: bool | None = None, next_offset: str | None = None,
 switch_pm_text: str | None = None, switch_pm_parameter: str | None =
 None, button: InlineQueryResultsButton | None = None) → bool
 Use this method to send answers to an inline query. On success, True is returned. No more than 50 results
 per query are allowed.
 Telegram documentation: https://core.telegram.org/bots/api#answerinlinequery
 Parameters
 • inline_query_id (str) – Unique identifier for the answered query
 • results (list of types.InlineQueryResult) – Array of results for the inline query
 • cache_time (int) – The maximum amount of time in seconds that the result of the inline
 query may be cached on the server.
 • is_personal (bool) – Pass True, if results may be cached on the server side only for the
 user that sent the query.
 • next_offset (str) – Pass the offset that a client should send in the next query with the
 same text to receive more results.
 • switch_pm_parameter (str) – Deep-linking parameter for the /start message sent to the
 bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are
 allowed. Example: An inline bot that sends YouTube videos can ask the user to connect
 the bot to their YouTube account to adapt search results accordingly. To do this, it displays
 a ‘Connect your YouTube account’ button above the results, or even before showing any.
 The user presses the button, switches to a private chat with the bot and, in doing so, passes
 a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer
 a switch_inline button so that the user can easily return to the chat where they wanted to
 use the bot’s inline capabilities.
 • switch_pm_text (str) – Parameter for the start message sent to the bot when user presses
 the switch button
 • button (types.InlineQueryResultsButton) – A JSON-serialized object describing
 a button to be shown above inline query results
 Returns
 On success, True is returned.
 Return type
 bool
 async answer_pre_checkout_query(pre_checkout_query_id: str, ok: bool, error_message: str | None =
 None) → bool
 Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in
 the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout
 queries. On success, True is returned.
ò Note
The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
 • ok (bool) – Specify True if delivery to the specified address is possible and False if there
 are any problems (for example, if delivery to the specified address is not possible)
 • shipping_options (list of ShippingOption) – Required if ok is True. A JSON-
 serialized array of available shipping options.
 • error_message (str) – Required if ok is False. Error message in human readable form
 that explains why it is impossible to complete the order (e.g. “Sorry, delivery to your
 desired address is unavailable’). Telegram will display this message to the user.
 Returns
 On success, True is returned.
 Return type
 bool
 async answer_web_app_query(web_app_query_id: str, result: InlineQueryResultBase) →
 SentWebAppMessage
 Use this method to set the result of an interaction with a Web App and send a corresponding message on
 behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object
 is returned.
 Telegram Documentation: https://core.telegram.org/bots/api#answerwebappquery
 Parameters
 • web_app_query_id (str) – Unique identifier for the query to be answered
 • result (telebot.types.InlineQueryResultBase) – A JSON-serialized object de-
 scribing the message to be sent
 Returns
 On success, a SentWebAppMessage object is returned.
 Return type
 telebot.types.SentWebAppMessage
 async approve_chat_join_request(chat_id: str | int, user_id: int | str) → bool
 Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work
 and must have the can_invite_users administrator right. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#approvechatjoinrequest
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • user_id (int or str) – Unique identifier of the target user
 Returns
 True on success.
 Return type
 bool
 async ban_chat_member(chat_id: int | str, user_id: int, until_date: int | datetime | None = None,
 revoke_messages: bool | None = None) → bool
 Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels,
 the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first.
 Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#banchatmember
 Parameters
 • chat_id (int or str) – Unique identifier for the target group or username of the target
 supergroup or channel (in the format @channelusername)
 • user_id (int) – Unique identifier of the target user
 • until_date (int or datetime) – Date when the user will be unbanned, unix time. If
 user is banned for more than 366 days or less than 30 seconds from the current time they
 are considered to be banned forever
 • revoke_messages (bool) – Bool: Pass True to delete all messages from the chat for the
 user that is being removed. If False, the user will be able to see messages in the group that
 were sent before the user was removed. Always True for supergroups and channels.
 Returns
 Returns True on success.
 Return type
 bool
 async ban_chat_sender_chat(chat_id: int | str, sender_chat_id: int | str) → bool
 Use this method to ban a channel chat in a supergroup or a channel. The owner of the chat will not be able
 to send messages and join live streams on behalf of the chat, unless it is unbanned first. The bot must be
 an administrator in the supergroup or channel for this to work and must have the appropriate administrator
 rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#banchatsenderchat
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • sender_chat_id (int or str) – Unique identifier of the target sender chat
 Returns
 True on success.
 Return type
 bool
 business_connection_handler(func=None, **kwargs)
 Handles new incoming business connection state.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 business_message_handler(commands: List[str] | None = None, regexp: str | None = None, func:
 Callable | None = None, content_types: List[str] | None = None, **kwargs)
 Handles New incoming message of any kind(for business accounts, see bot api 7.2 for more) - text, photo,
 sticker, etc. As a parameter to the decorator function, it passes telebot.types.Message object. All
 message handlers are tested in the order they were added.
 Example:
 content_types=['document'])
 def command_handle_document(message):
 bot.send_message(message.chat.id, 'Document received, sir!')
 Parameters
 • commands (list of str) – Optional list of strings (commands to handle).
 • regexp (str) – Optional regular expression.
 • func (lambda) – Optional lambda function. The lambda receives the message to test as
 the first parameter. It must return True if the command should handle the message.
 • content_types (list of str) – Supported message content types. Must be a list. De-
 faults to [‘text’].
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 decorated function
 callback_query_handler(func=None, **kwargs)
 Handles new incoming callback query. As a parameter to the decorator function, it passes telebot.
 types.CallbackQuery object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 channel_post_handler(commands=None, regexp=None, func=None, content_types=None, **kwargs)
 Handles new incoming channel post of any kind - text, photo, sticker, etc. As a parameter to the decorator
 function, it passes telebot.types.Message object.
 Parameters
 Returns
 None
 async close() → bool
 Use this method to close the bot instance before moving it from one local server to another. You need to
 delete the webhook before calling this method to ensure that the bot isn’t launched again after server restart.
 The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#close
 Returns
 bool
 async close_forum_topic(chat_id: str | int, message_thread_id: int) → bool
 Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the
 chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of
 the topic. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#closeforumtopic
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_thread_id (int) – Identifier of the topic to close
 Returns
 On success, True is returned.
 Return type
 bool
 async close_general_forum_topic(chat_id: int | str) → bool
 Use this method to close the ‘General’ topic in a forum supergroup chat. The bot must be an administrator
 in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#closegeneralforumtopic
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target channel
 (in the format @channelusername)
 async close_session()
 Closes existing session of aiohttp. Use this function if you stop polling/webhooks.
 async copy_message(chat_id: int | str, from_chat_id: int | str, message_id: int, caption: str | None = None,
 parse_mode: str | None = None, caption_entities: List[MessageEntity] | None =
 None, disable_notification: bool | None = None, protect_content: bool | None = None,
 reply_to_message_id: int | None = None, allow_sending_without_reply: bool | None
 = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup |
 ReplyKeyboardRemove | ForceReply | None = None, timeout: int | None = None,
 message_thread_id: int | None = None, reply_parameters: ReplyParameters | None =
 None, show_caption_above_media: bool | None = None, allow_paid_broadcast: bool
 | None = None) → MessageID
 Use this method to copy messages of any kind. If some of the specified messages can’t be found or copied,
 they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners mes-
 sages, and invoice messages can’t be copied. A quiz poll can be copied only if the value of the field
 correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the
 copied messages don’t have a link to the original message. Album grouping is kept for copied messages.
 On success, an array of MessageId of the sent messages is returned.
 Telegram documentation: https://core.telegram.org/bots/api#copymessage
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • from_chat_id (int or str) – Unique identifier for the chat where the original message
 was sent (or channel username in the format @channelusername)
 • message_id (int) – Message identifier in the chat specified in from_chat_id
 • caption (str) – New caption for media, 0-1024 characters after entities parsing. If not
 specified, the original caption is kept
 • parse_mode (str) – Mode for parsing entities in the new caption.
 • caption_entities (Array of telebot.types.MessageEntity) – A JSON-serialized
 list of special entities that appear in the new caption, which can be specified instead of
 parse_mode
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • allow_sending_without_reply (bool) – Deprecated - Use reply_parameters instead.
 Pass True, if the message should be sent even if the specified replied-to message is not
 found
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • timeout (int) – Timeout in seconds for the request.
 • message_thread_id (int) – Identifier of a message thread, in which the message will be
 sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • show_caption_above_media (bool) – Pass True, if the caption must be shown above
 the message media. Supported only for animation, photo and video messages.
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the MessageId of the sent message is returned.
 Return type
 telebot.types.MessageID
 Returns
 Returns the new invite link as ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 async create_chat_subscription_invite_link(chat_id: int | str, subscription_period: int,
 subscription_price: int, name: str | None = None) →
 ChatInviteLink
 Use this method to create a subscription invite link for a channel chat. The bot must have the
 can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionIn-
 viteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatIn-
 viteLink object.
 Telegram documentation: https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
 Parameters
 • chat_id (int or str) – Unique identifier for the target channel chat or username of the
 target channel (in the format @channelusername)
 • name (str) – Invite link name; 0-32 characters
 • subscription_period (int) – The number of seconds the subscription will be active
 for before the next payment. Currently, it must always be 2592000 (30 days).
 • subscription_price (int) – The amount of Telegram Stars a user must pay initially
 and after each subsequent subscription period to be a member of the chat; 1-2500
 Returns
 Returns the new invite link as a ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 async create_forum_topic(chat_id: int, name: str, icon_color: int | None = None,
 icon_custom_emoji_id: str | None = None) → ForumTopic
 Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat
 for this to work and must have the can_manage_topics administrator rights. Returns information about the
 created topic as a ForumTopic object.
 Telegram documentation: https://core.telegram.org/bots/api#createforumtopic
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • name (str) – Name of the topic, 1-128 characters
 • icon_color (int) – Color of the topic icon in RGB format. Currently, must be one of
 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F
 • icon_custom_emoji_id (str) – Custom emoji for the topic icon. Must be an emoji of
 type “tgs” and must be exactly 1 character long
 Returns
 On success, information about the created topic is returned as a ForumTopic object.
 Return type
 telebot.types.ForumTopic
 async create_invoice_link(title: str, description: str, payload: str, provider_token: str | None,
 currency: str, prices: List[LabeledPrice], max_tip_amount: int | None =
 None, suggested_tip_amounts: List[int] | None = None, provider_data: str |
 None = None, photo_url: str | None = None, photo_size: int | None = None,
 photo_width: int | None = None, photo_height: int | None = None,
 need_name: bool | None = None, need_phone_number: bool | None = None,
 need_email: bool | None = None, need_shipping_address: bool | None =
 None, send_phone_number_to_provider: bool | None = None,
 send_email_to_provider: bool | None = None, is_flexible: bool | None =
 None, subscription_period: int | None = None, business_connection_id: str |
 None = None) → str
 Use this method to create a link for an invoice. Returns the created invoice link as String on success.
 Telegram documentation: https://core.telegram.org/bots/api#createinvoicelink
 Parameters
 • business_connection_id (str) – Unique identifier of the business connection on behalf
 of which the link will be created
 • title (str) – Product name, 1-32 characters
 • description (str) – Product description, 1-255 characters
 • payload (str) – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
 the user, use for your internal processes.
 • provider_token (str) – Payments provider token, obtained via @Botfather; Pass None
 to omit the parameter to use “XTR” currency
 • currency (str) – Three-letter ISO 4217 currency code, see https://core.telegram.org/
 bots/payments#supported-currencies
 • prices (list of types.LabeledPrice) – Price breakdown, a list of components (e.g.
 product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
 • subscription_period (int) – The number of seconds the subscription will be active
 for before the next payment. The currency must be set to “XTR” (Telegram Stars) if the
 parameter is used. Currently, it must always be 2592000 (30 days) if specified.
 • max_tip_amount (int) – The maximum accepted amount for tips in the smallest units of
 the currency
 • suggested_tip_amounts (list of int) – A JSON-serialized array of suggested
 amounts of tips in the smallest units of the currency. At most 4 suggested tip amounts
 can be specified. The suggested tip amounts must be positive, passed in a strictly increased
 order and must not exceed max_tip_amount.
 • provider_data (str) – A JSON-serialized data about the invoice, which will be shared
 with the payment provider. A detailed description of required fields should be provided by
 the payment provider.
 • photo_url (str) – URL of the product photo for the invoice. Can be a photo of the goods
 or a photo of the invoice. People like it better when they see a photo of what they are paying
 for.
 • photo_size (int) – Photo size in bytes
 • photo_width (int) – Photo width
 • photo_height (int) – Photo height
 • need_name (bool) – Pass True, if you require the user’s full name to complete the order
 • need_phone_number (bool) – Pass True, if you require the user’s phone number to com-
 plete the order
 • need_email (bool) – Pass True, if you require the user’s email to complete the order
 • need_shipping_address (bool) – Pass True, if you require the user’s shipping address
 to complete the order
 • send_phone_number_to_provider (bool) – Pass True, if user’s phone number should
 be sent to provider
 • send_email_to_provider (bool) – Pass True, if user’s email address should be sent to
 provider
 • is_flexible (bool) – Pass True, if the final price depends on the shipping method
 Returns
 Created invoice link as String on success.
 Return type
 str
 async create_new_sticker_set(user_id: int, name: str, title: str, emojis: List[str] | None = None,
 png_sticker: Any | str = None, tgs_sticker: Any | str = None,
 webm_sticker: Any | str = None, contains_masks: bool | None = None,
 sticker_type: str | None = None, mask_position: MaskPosition | None =
 None, needs_repainting: bool | None = None, stickers:
 List[InputSticker] = None, sticker_format: str | None = None) → bool
 Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker
 set. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#createnewstickerset
ò Note
Fields *_sticker are deprecated, pass a list of stickers to stickers parameter instead.
 Parameters
 • user_id (int) – User identifier of created sticker set owner
 • name (str) – Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals).
 Can contain only English letters, digits and underscores. Must begin with a letter, can’t con-
 tain consecutive underscores and must end in “_by_<bot_username>”. <bot_username>
 is case insensitive. 1-64 characters.
 • title (str) – Sticker set title, 1-64 characters
 • emojis (str) – One or more emoji corresponding to the sticker
 • png_sticker (str) – PNG image with the sticker, must be up to 512 kilobytes in size,
 dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass
 a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP
 URL as a String for Telegram to get a file from the Internet, or upload a new one using
 multipart/form-data.
 • tgs_sticker (str) – TGS animation with the sticker, uploaded using multipart/form-
 data.
 • webm_sticker (str) – WebM animation with the sticker, uploaded using multipart/form-
 data.
 • contains_masks (bool) – Pass True, if a set of mask stickers should be created. Depre-
 cated since Bot API 6.2, use sticker_type instead.
 • sticker_type (str) – Type of stickers in the set, pass “regular”, “mask”, or “cus-
 tom_emoji”. By default, a regular sticker set is created.
 • mask_position (telebot.types.MaskPosition) – A JSON-serialized object for po-
 sition where the mask should be placed on faces
 • needs_repainting (bool) – Pass True if stickers in the sticker set must be repainted to
 the color of text when used in messages, the accent color if used as emoji status, white on
 chat photos, or another appropriate color based on context; for custom emoji sticker sets
 only
 • stickers (list of telebot.types.InputSticker) – List of stickers to be added to
 the set
 • sticker_format (str) – deprecated
 Returns
 On success, True is returned.
 Return type
 bool
 • chat_id (int or str) – Id: Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • name (str) – Invite link name; 0-32 characters
 • invite_link (str) – The invite link to edit
 • expire_date (int or datetime) – Point in time (Unix timestamp) when the link will
 expire
 • member_limit (int) – Maximum number of users that can be members of the chat simul-
 taneously
 • creates_join_request (bool) – True, if users joining the chat via the link need to be
 approved by chat administrators. If True, member_limit can’t be specified
 Returns
 Returns the new invite link as ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 async edit_chat_subscription_invite_link(chat_id: int | str, invite_link: str, name: str | None =
 None) → ChatInviteLink
 Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users
 administrator rights. Returns the edited invite link as a ChatInviteLink object.
 Telegram documentation: https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • invite_link (str) – The invite link to edit
 • name (str) – Invite link name; 0-32 characters
 Returns
 Returns the edited invite link as a ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 async edit_forum_topic(chat_id: int | str, message_thread_id: int, name: str | None = None,
 icon_custom_emoji_id: str | None = None) → bool
 Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an admin-
 istrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the
 creator of the topic. Returns True on success.
 Telegram Documentation: https://core.telegram.org/bots/api#editforumtopic
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_thread_id (int) – Identifier of the topic to edit
 • name (str) – Optional, New name of the topic, 1-128 characters. If not specififed or empty,
 the current name of the topic will be kept
 • icon_custom_emoji_id (str) – Optional, New unique identifier of the custom emoji
 shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji
 identifiers. Pass an empty string to remove the icon. If not specified, the current icon will
 be kept
 Returns
 On success, True is returned.
 Return type
 bool
 async edit_general_forum_topic(chat_id: int | str, name: str) → bool
 Use this method to edit the name of the ‘General’ topic in a forum supergroup chat. The bot must be an
 administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns
 True on success.
 Telegram documentation: https://core.telegram.org/bots/api#editgeneralforumtopic
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • name (str) – New topic name, 1-128 characters
 async edit_message_caption(caption: str, chat_id: int | str | None = None, message_id: int | None =
 None, inline_message_id: str | None = None, parse_mode: str | None =
 None, caption_entities: List[MessageEntity] | None = None, reply_markup:
 InlineKeyboardMarkup | None = None, show_caption_above_media: bool |
 None = None, business_connection_id: str | None = None, timeout: int |
 None = None) → Message | bool
 Use this method to edit captions of messages.
 Telegram documentation: https://core.telegram.org/bots/api#editmessagecaption
 Parameters
 • caption (str) – New caption of the message
 • chat_id (int | str) – Required if inline_message_id is not specified. Unique identifier
 for the target chat or username of the target channel
 • message_id (int) – Required if inline_message_id is not specified.
 • inline_message_id (str) – Required if inline_message_id is not specified. Identifier of
 the inline message.
 • parse_mode (str) – New caption of the message, 0-1024 characters after entities parsing
 • caption_entities (list of types.MessageEntity) – A JSON-serialized array of ob-
 jects that describe how the caption should be parsed.
 • reply_markup (InlineKeyboardMarkup) – A JSON-serialized object for an inline key-
 board.
 • show_caption_above_media (bool) – Pass True, if the caption must be shown above
 the message media. Supported only for animation, photo and video messages.
 • business_connection_id (str) – Identifier of the business connection to send the mes-
 sage through
 • timeout (int) – Timeout in seconds for the request.
 Returns
 On success, if edited message is sent by the bot, the edited Message is returned, otherwise
 True is returned.
 Return type
 types.Message | bool
 async edit_message_live_location(latitude: float, longitude: float, chat_id: int | str | None = None,
 message_id: int | None = None, inline_message_id: str | None =
 None, reply_markup: InlineKeyboardMarkup | None = None,
 timeout: int | None = None, horizontal_accuracy: float | None =
 None, heading: int | None = None, proximity_alert_radius: int |
 None = None, live_period: int | None = None,
 business_connection_id: str | None = None) → Message
 Use this method to edit live location messages. A location can be edited until its live_period expires
 or editing is explicitly
 disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline
 message, the edited Message is returned, otherwise True is returned.
 Telegram documentation: https://core.telegram.org/bots/api#editmessagelivelocation
 Parameters
 • latitude (float) – Latitude of new location
 • longitude (float) – Longitude of new location
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the mes-
 sage to edit
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – A JSON-serialized object for a new inline keyboard.
 • timeout (int) – Timeout in seconds for the request.
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message
 • horizontal_accuracy (float) – The radius of uncertainty for the location, measured
 in meters; 0-1500
 • heading (int) – Direction in which the user is moving, in degrees. Must be between 1
 and 360 if specified.
 • proximity_alert_radius (int) – The maximum distance for proximity alerts about
 approaching another chat member, in meters. Must be between 1 and 100000 if specified.
 • live_period (int) – New period in seconds during which the location can be updated,
 starting from the message send date. If 0x7FFFFFFF is specified, then the location can be
 updated forever. Otherwise, the new value must not exceed the current live_period by more
 than a day, and the live location expiration date must remain within the next 90 days. If not
 specified, then live_period remains unchanged
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be edited
 Returns
 On success, if the edited message is not an inline message, the edited Message is returned,
 otherwise True is returned.
 Return type
 telebot.types.Message or bool
 async edit_message_media(media: Any, chat_id: int | str | None = None, message_id: int | None = None,
 inline_message_id: str | None = None, reply_markup: InlineKeyboardMarkup
 | None = None, business_connection_id: str | None = None, timeout: int |
 None = None) → Message | bool
 Use this method to edit animation, audio, document, photo, or video messages, or to add media to text
 messages. If a message is part of a message album, then it can be edited only to an audio for audio albums,
 only to a document for document albums and to a photo or a video otherwise. When an inline message
 is edited, a new file can’t be uploaded; use a previously uploaded file via its file_id or specify a URL. On
 success, if the edited message is not an inline message, the edited Message is returned, otherwise True is
 returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard
 can only be edited within 48 hours from the time they were sent.
 Telegram documentation: https://core.telegram.org/bots/api#editmessagemedia
 Parameters
 • media (InputMedia) – A JSON-serialized object for a new media content of the message
 • chat_id (int or str) – Required if inline_message_id is not specified. Unique identifier
 for the target chat or username of the target channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the sent
 message
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message
 • reply_markup (telebot.types.InlineKeyboardMarkup or
 ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply) – A JSON-
 serialized object for an inline keyboard.
 • business_connection_id (str) – Unique identifier of the business connection
 • timeout (int) – Timeout in seconds for the request.
 Returns
 On success, if edited message is sent by the bot, the edited Message is returned, otherwise
 True is returned.
 Return type
 types.Message or bool
 async edit_message_reply_markup(chat_id: int | str | None = None, message_id: int | None = None,
 inline_message_id: str | None = None, reply_markup:
 InlineKeyboardMarkup | None = None, business_connection_id: str
 | None = None, timeout: int | None = None) → Message | bool
 Use this method to edit only the reply markup of messages.
 Telegram documentation: https://core.telegram.org/bots/api#editmessagereplymarkup
 Parameters
 • chat_id (int or str) – Required if inline_message_id is not specified. Unique identifier
 for the target chat or username of the target channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the sent
 message
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message
ò Note
 Parameters
 filename (str, optional) – Filename of saving file, defaults to “./.state-save/states.pkl”
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • from_chat_id (int or str) – Unique identifier for the chat where the original message
 was sent (or channel username in the format @channelusername)
 • message_id (int) – Message identifier in the chat specified in from_chat_id
 • protect_content (bool) – Protects the contents of the forwarded message from forward-
 ing and saving
 • timeout (int) – Timeout in seconds for the request.
 • message_thread_id (int) – Unique identifier for the target message thread (topic) of the
 forum; for forum supergroups only
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 async forward_messages(chat_id: str | int, from_chat_id: str | int, message_ids: List[int],
 disable_notification: bool | None = None, message_thread_id: int | None =
 None, protect_content: bool | None = None) → List[MessageID]
 Use this method to forward multiple messages of any kind. If some of the specified messages can’t be found
 or forwarded, they are skipped. Service messages and messages with protected content can’t be forwarded.
 Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages
 is returned.
 Telegram documentation: https://core.telegram.org/bots/api#forwardmessages
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • from_chat_id (int or str) – Unique identifier for the chat where the original message
 was sent (or channel username in the format @channelusername)
 • message_ids (list) – Message identifiers in the chat specified in from_chat_id
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound
 • message_thread_id (int) – Identifier of a message thread, in which the messages will
 be sent
 • protect_content (bool) – Protects the contents of the forwarded message from forward-
 ing and saving
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.MessageID
 async get_available_gifts() → Gifts
 Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.
 Telegram documentation: https://core.telegram.org/bots/api#getavailablegifts
 Returns
 On success, a Gifts object is returned.
 Return type
 telebot.types.Gifts
 async get_business_connection(business_connection_id: str) → BusinessConnection
 Use this method to get information about the connection of the bot with a business account. Returns a
 BusinessConnection object on success.
 Telegram documentation: https://core.telegram.org/bots/api#getbusinessconnection
 Parameters
 business_connection_id (str) – Unique identifier of the business connection
 Returns
 Returns a BusinessConnection object on success.
 Return type
 telebot.types.BusinessConnection
 async get_chat(chat_id: int | str) → ChatFullInfo
 Use this method to get up to date information about the chat (current name of the user for one-on-one
 conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
 Telegram documentation: https://core.telegram.org/bots/api#getchat
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target super-
 group or channel (in the format @channelusername)
 Returns
 Chat information
 Return type
 telebot.types.ChatFullInfo
 async get_chat_administrators(chat_id: int | str) → List[ChatMember]
 Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember
 objects that contains information about all chat administrators except other bots.
 Telegram documentation: https://core.telegram.org/bots/api#getchatadministrators
 Parameters
 chat_id – Unique identifier for the target chat or username of the target supergroup or channel
 (in the format @channelusername)
 Returns
 List made of ChatMember objects.
 Return type
 list of telebot.types.ChatMember
 async get_chat_member(chat_id: int | str, user_id: int) → ChatMember
 Use this method to get information about a member of a chat. Returns a ChatMember object on success.
 Telegram documentation: https://core.telegram.org/bots/api#getchatmember
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • user_id (int) – Unique identifier of the target user
 Returns
 Returns ChatMember object on success.
 Return type
 telebot.types.ChatMember
 async get_chat_member_count(chat_id: int | str) → int
 Use this method to get the number of members in a chat.
 Telegram documentation: https://core.telegram.org/bots/api#getchatmembercount
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target super-
 group or channel (in the format @channelusername)
 Returns
 Number of members in the chat.
 Return type
 int
 get_chat_members_count(**kwargs)
 Returns
 telebot.types.BotShortDescription
 async get_star_transactions(offset: int | None = None, limit: int | None = None) → StarTransactions
 Returns the bot’s Telegram Star transactions in chronological order.
 Telegram documentation: https://core.telegram.org/bots/api#getstartransactions
 Parameters
 • offset (int) – Number of transactions to skip in the response
 • limit (int) – The maximum number of transactions to be retrieved. Values between 1-
 100 are accepted. Defaults to 100.
 Returns
 On success, returns a StarTransactions object.
 Return type
 types.StarTransactions
 async get_state(user_id: int, chat_id: int | None = None, business_connection_id: str | None = None,
 message_thread_id: int | None = None, bot_id: int | None = None) → str
 Gets current state of a user. Not recommended to use this method. But it is ok for debugging.
. Warning
 Even if you are using telebot.types.State, this method will return a string. When comparing(not
 recommended), you should compare this string with telebot.types.State.name
 Parameters
 • user_id (int) – User’s identifier
 • chat_id (int) – Chat’s identifier
 • bot_id (int) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str) – Business identifier
 • message_thread_id (int) – Identifier of the message thread
 Returns
 state of a user
 Return type
 str
 async get_updates(offset: int | None = None, limit: int | None = None, timeout: int | None = 20,
 allowed_updates: List | None = None, request_timeout: int | None = None) →
 List[Update]
 Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is
 returned.
 Telegram documentation: https://core.telegram.org/bots/api#getupdates
 Parameters
 • offset (int, optional) – Identifier of the first update to be returned. Must be greater
 by one than the highest among the identifiers of previously received updates. By default,
 updates starting with the earliest unconfirmed update are returned. An update is considered
 confirmed as soon as getUpdates is called with an offset higher than its update_id. The
 negative offset can be specified to retrieve updates starting from -offset update from the
 end of the updates queue. All previous updates will forgotten.
 • limit (int, optional) – Limits the number of updates to be retrieved. Values between
 1-100 are accepted. Defaults to 100.
 • timeout (int, optional) – Request connection timeout
 • allowed_updates (list, optional) – Array of string. List the types of updates you want
 your bot to receive.
 • request_timeout (int, optional) – Timeout in seconds for request.
 Returns
 An Array of Update objects is returned.
 Return type
 list of telebot.types.Update
 async get_user_chat_boosts(chat_id: int | str, user_id: int) → UserChatBoosts
 Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat.
 Returns a UserChatBoosts object.
 Telegram documentation: https://core.telegram.org/bots/api#getuserchatboosts
 Parameters
 • chat_id (int | str) – Unique identifier for the target chat or username of the target channel
 • user_id (int) – Unique identifier of the target user
 Returns
 On success, a UserChatBoosts object is returned.
 Return type
 telebot.types.UserChatBoosts
 async get_user_profile_photos(user_id: int, offset: int | None = None, limit: int | None = None) →
 UserProfilePhotos
 Use this method to get a list of profile pictures for a user. Returns a telebot.types.UserProfilePhotos
 object.
 Telegram documentation: https://core.telegram.org/bots/api#getuserprofilephotos
 Parameters
 • user_id (int) – Unique identifier of the target user
 • offset (int) – Sequential number of the first photo to be returned. By default, all photos
 are returned.
 • limit (int) – Limits the number of photos to be retrieved. Values between 1-100 are
 accepted. Defaults to 100.
 Returns
 UserProfilePhotos
 Return type
 telebot.types.UserProfilePhotos
 async get_webhook_info(timeout: int | None = None) → WebhookInfo
 Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo
 object. If the bot is using getUpdates, will return an object with the url field empty.
 Telegram documentation: https://core.telegram.org/bots/api#getwebhookinfo
 Parameters
 timeout (int, optional) – Request connection timeout
 Returns
 On success, returns a WebhookInfo object.
 Return type
 telebot.types.WebhookInfo
 async hide_general_forum_topic(chat_id: int | str) → bool
 Use this method to hide the ‘General’ topic in a forum supergroup chat. The bot must be an administrator in
 the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#hidegeneralforumtopic
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target channel
 (in the format @channelusername)
 async infinity_polling(timeout: int | None = 20, skip_pending: bool | None = False, request_timeout:
 int | None = None, logger_level: int | None = 40, allowed_updates: List[str] |
 None = None, restart_on_change: bool | None = False, path_to_watch: str |
 None = None, *args, **kwargs)
 Wrap polling with infinite loop and exception handling to avoid bot stops polling.
ò Note
 Parameters
 • timeout (int) – Timeout in seconds for get_updates(Defaults to None)
 • skip_pending (bool) – skip old updates
 • request_timeout (int) – Aiohttp’s request timeout. Defaults to 5 min-
 utes(aiohttp.ClientTimeout).
 • logger_level (int) – Custom logging level for infinity_polling logging. Use logger
 levels from logging as a value. None/NOTSET = no error logging
 • allowed_updates (list of str) – A list of the update types you want your bot to re-
 ceive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only
 receive updates of these types. See util.update_types for a complete list of available update
 types. Specify an empty list to receive all update types except chat_member (default). If
 not specified, the previous setting will be used.
 Please note that this parameter doesn’t affect updates created before the call to the
 get_updates, so unwanted updates may be received for a short period of time.
 • restart_on_change (bool) – Restart a file on file(s) change. Defaults to False
 • path_to_watch (str) – Path to watch for changes. Defaults to current directory
 Returns
 None
 inline_handler(func, **kwargs)
 Handles new incoming inline query. As a parameter to the decorator function, it passes telebot.types.
 InlineQuery object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 async kick_chat_member(chat_id: int | str, user_id: int, until_date: int | datetime | None = None,
 revoke_messages: bool | None = None) → bool
 This function is deprecated. Use ban_chat_member instead
 async leave_chat(chat_id: int | str) → bool
 Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#leavechat
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target super-
 group or channel (in the format @channelusername)
 Returns
 bool
 async log_out() → bool
 Use this method to log out from the cloud Bot API server before launching the bot locally. You MUST log
 out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After
 a successful call, you can immediately log in on a local server, but will not be able to log in back to the
 cloud Bot API server for 10 minutes. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#logout
 Returns
 True on success.
 Return type
 bool
 message_handler(commands=None, regexp=None, func=None, content_types=None, chat_types=None,
 **kwargs)
 Handles new incoming message of any kind - text, photo, sticker, etc. As a parameter to the decorator
 function, it passes telebot.types.Message object. All message handlers are tested in the order they
 were added.
Example:
 content_types=['document'])
 async def command_handle_document(message):
 await bot.send_message(message.chat.id, 'Document received, sir!')
 Parameters
 • commands (list of str) – Optional list of strings (commands to handle).
 • regexp (str) – Optional regular expression.
 • func – Optional lambda function. The lambda receives the message to test as the first
 parameter. It must return True if the command should handle the message.
 • content_types (list of str) – Supported message content types. Must be a list. De-
 faults to [‘text’].
 • chat_types (list of str) – list of chat types
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 decorated function
 message_reaction_count_handler(func=None, **kwargs)
 Handles new incoming message reaction count. As a parameter to the decorator function, it passes
 telebot.types.MessageReactionCountUpdated object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 message_reaction_handler(func=None, **kwargs)
 Handles new incoming message reaction. As a parameter to the decorator function, it passes telebot.
 types.MessageReactionUpdated object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 my_chat_member_handler(func=None, **kwargs)
 Handles update in a status of a bot. For private chats, this update is received only when the bot is
 blocked or unblocked by the user. As a parameter to the decorator function, it passes telebot.types.
 ChatMemberUpdated object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 async pin_chat_message(chat_id: int | str, message_id: int, disable_notification: bool | None = False,
 business_connection_id: str | None = None) → bool
 Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to
 work and must have the appropriate admin rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#pinchatmessage
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Identifier of a message to pin
 • disable_notification (bool) – Pass True, if it is not necessary to send a notification
 to all group members about the new pinned message
 • business_connection_id (str) – Unique identifier of the business connection
 Returns
 True on success.
 Return type
 bool
 poll_answer_handler(func=None, **kwargs)
 Handles change of user’s answer in a non-anonymous poll(when user changes the vote). Bots receive new
 votes only in polls that were sent by the bot itself. As a parameter to the decorator function, it passes
 telebot.types.PollAnswer object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 poll_handler(func, **kwargs)
 Handles new state of a poll. Bots receive only updates about stopped polls and polls, which are sent by the
 bot As a parameter to the decorator function, it passes telebot.types.Poll object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 async polling(non_stop: bool = True, skip_pending=False, interval: int = 0, timeout: int = 20,
 request_timeout: int | None = None, allowed_updates: List[str] | None = None, none_stop:
 bool | None = None, restart_on_change: bool | None = False, path_to_watch: str | None =
 None)
 Runs bot in long-polling mode in a main loop. This allows the bot to retrieve Updates automagically and
 notify listeners and message handlers accordingly.
 Warning: Do not call this function more than once!
 Always gets updates.
ò Note
 Parameters
 • non_stop (bool) – Do not stop polling when an ApiException occurs.
 • skip_pending (bool) – skip old updates
 • interval (int) – Delay between two update retrivals
 • timeout (int) – Request connection timeout
 • request_timeout (int) – Timeout in seconds for get_updates(Defaults to None)
 • allowed_updates (list of str) – A list of the update types you want your bot to re-
 ceive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only
 receive updates of these types. See util.update_types for a complete list of available update
 types. Specify an empty list to receive all update types except chat_member (default). If
 not specified, the previous setting will be used.
 Please note that this parameter doesn’t affect updates created before the call to the
 get_updates, so unwanted updates may be received for a short period of time.
 • none_stop (bool) – Deprecated, use non_stop. Old typo, kept for backward compatibility.
 • restart_on_change (bool) – Restart a file on file(s) change. Defaults to False.
 • path_to_watch (str) – Path to watch for changes. Defaults to current directory
 Returns
 pre_checkout_query_handler(func, **kwargs)
 New incoming pre-checkout query. Contains full information about checkout. As a parameter to the deco-
 rator function, it passes telebot.types.PreCheckoutQuery object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 async process_new_updates(updates: List[Update])
 Process new updates. Just pass list of updates - each update should be instance of Update object.
 Parameters
 updates (list of telebot.types.Update) – list of updates
 Returns
 None
 async promote_chat_member(chat_id: int | str, user_id: int, can_change_info: bool | None = None,
 can_post_messages: bool | None = None, can_edit_messages: bool | None =
 None, can_delete_messages: bool | None = None, can_invite_users: bool |
 None = None, can_restrict_members: bool | None = None,
 can_pin_messages: bool | None = None, can_promote_members: bool |
 None = None, is_anonymous: bool | None = None, can_manage_chat: bool |
 None = None, can_manage_video_chats: bool | None = None,
 can_manage_voice_chats: bool | None = None, can_manage_topics: bool |
 None = None, can_post_stories: bool | None = None, can_edit_stories: bool
 | None = None, can_delete_stories: bool | None = None) → bool
 Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator
 in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters
 to demote a user.
 Telegram documentation: https://core.telegram.org/bots/api#promotechatmember
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel ( in the format @channelusername)
 • user_id (int) – Unique identifier of the target user
 • can_change_info (bool) – Pass True, if the administrator can change chat title, photo
 and other settings
 • can_post_messages (bool) – Pass True, if the administrator can create channel posts,
 channels only
 • can_edit_messages (bool) – Pass True, if the administrator can edit messages of other
 users, channels only
 • can_delete_messages (bool) – Pass True, if the administrator can delete messages of
 other users
 • can_invite_users (bool) – Pass True, if the administrator can invite new users to the
 chat
 • can_restrict_members (bool) – Pass True, if the administrator can restrict, ban or un-
 ban chat members
 • can_pin_messages (bool) – Pass True, if the administrator can pin messages, super-
 groups only
 • can_promote_members (bool) – Pass True, if the administrator can add new adminis-
 trators with a subset of his own privileges or demote administrators that he has promoted,
 directly or indirectly (promoted by administrators that were appointed by him)
 • is_anonymous (bool) – Pass True, if the administrator’s presence in the chat is hidden
 • can_manage_chat (bool) – Pass True, if the administrator can access the chat event log,
 chat statistics, message statistics in channels, see channel members, see anonymous ad-
 ministrators in supergroups and ignore slow mode. Implied by any other administrator
 privilege
 • can_manage_video_chats (bool) – Pass True, if the administrator can manage voice
 chats For now, bots can use this privilege only for passing to other administrators.
 • can_manage_voice_chats (bool) – Deprecated, use can_manage_video_chats.
 • can_manage_topics (bool) – Pass True if the user is allowed to create, rename, close,
 and reopen forum topics, supergroups only
 • can_post_stories (bool) – Pass True if the administrator can create the channel’s stories
 • can_edit_stories (bool) – Pass True if the administrator can edit the channel’s stories
 • can_delete_stories (bool) – Pass True if the administrator can delete the channel’s
 stories
 Returns
 True on success.
 Return type
 bool
 purchased_paid_media_handler(func=None, **kwargs)
 Handles new incoming purchased paid media.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 async refund_star_payment(user_id: int, telegram_payment_charge_id: str) → bool
 Refunds a successful payment in Telegram Stars. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#refundstarpayment
 Parameters
 • user_id (int) – Identifier of the user whose payment will be refunded
 • telegram_payment_charge_id (str) – Telegram payment identifier
 Returns
 On success, True is returned.
 Return type
 bool
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_edited_channel_post_handler(callback: Callable[[Any], Awaitable], content_types: List[str]
 | None = None, commands: List[str] | None = None, regexp:
 str | None = None, func: Callable | None = None, pass_bot:
 bool | None = False, **kwargs)
 Registers edited channel post message handler.
 Parameters
 • callback (Awaitable) – function to be called
 • content_types (list of str) – Supported message content types. Must be a list. De-
 faults to [‘text’].
 • commands (list of str) – list of commands
 • regexp (str) – Regular expression
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 decorated function
 register_edited_message_handler(callback: Callable[[Any], Awaitable], content_types: List[str] |
 None = None, commands: List[str] | None = None, regexp: str |
 None = None, func: Callable | None = None, chat_types: List[str] |
 None = None, pass_bot: bool | None = False, **kwargs)
 Registers edited message handler.
 Parameters
 • callback (Awaitable) – function to be called
 • content_types (list of str) – Supported message content types. Must be a list. De-
 faults to [‘text’].
 • commands (list of str) – list of commands
 • regexp (str) – Regular expression
 • func (function) – Function executed as a filter
 • chat_types (bool) – True for private chat
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_pre_checkout_query_handler(callback: Callable[[Any], Awaitable], func: Callable,
 pass_bot: bool | None = False, **kwargs)
 Registers pre-checkout request handler.
 Parameters
 • callback (Awaitable) – function to be called
 • func – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 decorated function
 register_purchased_paid_media_handler(callback: Callable, func: Callable, pass_bot: bool | None =
 False, **kwargs)
 Registers purchased paid media handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_removed_chat_boost_handler(callback: Callable, func: Callable | None = None, pass_bot:
 bool | None = False, **kwargs)
 Registers removed chat boost handler.
 Parameters
 • callback (function) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot – True if you need to pass TeleBot instance to handler(useful for separating
 handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 register_shipping_query_handler(callback: Callable[[Any], Awaitable], func: Callable, pass_bot:
 bool | None = False, **kwargs)
 Registers shipping query handler.
 Parameters
 • callback (Awaitable) – function to be called
 • func (function) – Function executed as a filter
 • pass_bot (bool) – True if you need to pass TeleBot instance to handler(useful for sepa-
 rating handlers into different files)
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 async remove_chat_verification(chat_id: int | str) → bool
 Removes verification from a chat that is currently verified on behalf of the organization represented by the
 bot. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#removechatverification
 Parameters
 chat_id (int | str) – Unique identifier for the target chat or username of the target channel
 (in the format @channelusername)
 Returns
 Returns True on success.
 Return type
 bool
 async remove_user_verification(user_id: int) → bool
 Removes verification from a user who is currently verified on behalf of the organization represented by the
 bot. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#removeuserverification
 Parameters
 user_id (int) – Unique identifier of the target user
 Returns
 Returns True on success.
 Return type
 bool
 async remove_webhook() → bool
 Alternative for delete_webhook but uses set_webhook
 removed_chat_boost_handler(func=None, **kwargs)
 Handles new incoming chat boost state. it passes telebot.types.ChatBoostRemoved object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 async reopen_forum_topic(chat_id: str | int, message_thread_id: int) → bool
 Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in
 the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator
 of the topic. Returns True on success.
 Use this method to replace an existing sticker in a sticker set with a new one. The method is
 equivalent to calling deleteStickerFromSet, then addStickerToSet,
 then setStickerPositionInSet. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#replaceStickerInSet
 Parameters
 • user_id (int) – User identifier of the sticker set owner
 • name (str) – Sticker set name
 • old_sticker (str) – File identifier of the replaced sticker
 • sticker (telebot.types.InputSticker) – A JSON-serialized object with informa-
 tion about the added sticker. If exactly the same sticker had already been added to the set,
 then the set remains unchanged.
 Returns
 Returns True on success.
 Return type
 bool
 async reply_to(message: Message, text: str, **kwargs) → Message
 Convenience function for send_message(message.chat.id, text, re-
 ply_parameters=(message.message_id. . . ), **kwargs)
 Parameters
 • message (types.Message) – Instance of telebot.types.Message
 • text (str) – Text of the message.
 • kwargs – Additional keyword arguments which are passed to telebot.TeleBot.
 send_message()
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 async reset_data(user_id: int, chat_id: int | None = None, business_connection_id: str | None = None,
 message_thread_id: int | None = None, bot_id: int | None = None) → bool
 Reset data for a user in chat.
 Parameters
 • user_id (int) – User’s identifier
 • chat_id (int) – Chat’s identifier
 • bot_id (int) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str) – Business identifier
 • message_thread_id (int) – Identifier of the message thread
 Returns
 True on success
 Return type
 bool
 async restrict_chat_member(chat_id: int | str, user_id: int, until_date: int | datetime | None = None,
 can_send_messages: bool | None = None, can_send_media_messages:
 bool | None = None, can_send_polls: bool | None = None,
 can_send_other_messages: bool | None = None,
 can_add_web_page_previews: bool | None = None, can_change_info: bool
 | None = None, can_invite_users: bool | None = None, can_pin_messages:
 bool | None = None, permissions: ChatPermissions | None = None,
 use_independent_chat_permissions: bool | None = None) → bool
 Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup
 for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift
 restrictions from a user.
 Telegram documentation: https://core.telegram.org/bots/api#restrictchatmember
. Warning
Individual parameters are deprecated and will be removed, use ‘permissions’ instead
 Parameters
 • chat_id (int or str) – Unique identifier for the target group or username of the target
 supergroup or channel (in the format @channelusername)
 • user_id (int) – Unique identifier of the target user
 • until_date (int or datetime, optional) – Date when restrictions will be lifted for the
 user, unix time. If user is restricted for more than 366 days or less than 30 seconds from
 the current time, they are considered to be restricted forever
 • can_send_messages (bool) – deprecated
 • can_send_media_messages (bool) – deprecated
 retrieve_data(user_id: int, chat_id: int | None = None, business_connection_id: str | None = None,
 message_thread_id: int | None = None, bot_id: int | None = None) → Dict[str, Any] | None
 Returns context manager with data for a user in chat.
 Parameters
 • user_id (int) – User identifier
 • chat_id (int, optional) – Chat’s unique identifier, defaults to user_id
 • bot_id (int, optional) – Bot’s identifier, defaults to current bot id
 • business_connection_id (str, optional) – Business identifier
 • message_thread_id (int, optional) – Identifier of the message thread
 Returns
 Context manager with data for a user in chat
 Return type
 dict
 async revoke_chat_invite_link(chat_id: int | str, invite_link: str) → ChatInviteLink
 Use this method to revoke an invite link created by the bot. Note: If the primary link is revoked, a new link
 is automatically generated The bot must be an administrator in the chat for this to work and must have the
 appropriate admin rights.
 Telegram documentation: https://core.telegram.org/bots/api#revokechatinvitelink
 Parameters
 • chat_id (int or str) – Id: Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • invite_link (str) – The invite link to revoke
 Returns
 Returns the new invite link as ChatInviteLink object.
 Return type
 telebot.types.ChatInviteLink
 async run_webhooks(listen: str | None = '127.0.0.1', port: int | None = 443, url_path: str | None = None,
 certificate: str | None = None, certificate_key: str | None = None, webhook_url: str |
 None = None, max_connections: int | None = None, allowed_updates: List | None =
 None, ip_address: str | None = None, drop_pending_updates: bool | None = None,
 timeout: int | None = None, secret_token: str | None = None, secret_token_length: int
 | None = 20, debug: bool | None = False)
 This class sets webhooks and listens to a given url and port.
 Parameters
 • listen – IP address to listen to. Defaults to 0.0.0.0
 • port – A port which will be used to listen to webhooks.
 • url_path – Path to the webhook. Defaults to /token
 • certificate – Path to the certificate file.
 • certificate_key – Path to the certificate key file.
 • webhook_url – Webhook URL.
 • max_connections – Maximum allowed number of simultaneous HTTPS connections to
 the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load
 on your bot’s server, and higher values to increase your bot’s throughput.
 • allowed_updates – A JSON-serialized list of the update types you want your bot to re-
 ceive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only
 receive updates of these types. See Update for a complete list of available update types.
 Specify an empty list to receive all updates regardless of type (default). If not specified,
 the previous setting will be used.
 • ip_address – The fixed IP address which will be used to send webhook requests instead
 of the IP address resolved through DNS
 • drop_pending_updates – Pass True to drop all pending updates
 • timeout – Integer. Request connection timeout
 • secret_token – Secret token to be used to verify the webhook request.
 • secret_token_length – Length of a secret token, defaults to 20
 • debug – Debug mode, defaults to False
 Returns
 async save_prepared_inline_message(user_id: int, result: InlineQueryResultBase, allow_user_chats:
 bool | None = None, allow_bot_chats: bool | None = None,
 allow_group_chats: bool | None = None, allow_channel_chats:
 bool | None = None) → PreparedInlineMessage
 Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.
 Telegram Documentation: https://core.telegram.org/bots/api#savepreparedinlinemessage
 Parameters
 • user_id (int) – Unique identifier of the target user that can use the prepared message
 • caption (str) – Animation caption (may also be used when resending animation by
 file_id), 0-1024 characters after entities parsing
 • parse_mode (str) – Mode for parsing entities in the animation caption
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • timeout (int) – Timeout in seconds for the request.
 • caption_entities (list of telebot.types.MessageEntity) – List of special enti-
 ties that appear in the caption, which can be specified instead of parse_mode
 • allow_sending_without_reply (bool) – Deprecated - Use reply_parameters instead.
 Pass True, if the message should be sent even if the specified replied-to message is not
 found
 • message_thread_id (int) – Identifier of a message thread, in which the video will be
 sent
 • has_spoiler (bool) – Pass True, if the animation should be sent as a spoiler
 • thumb (str or telebot.types.InputFile) – Deprecated. Use thumbnail instead
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 • message_effect_id (str) – Unique identifier of the message effect
 • show_caption_above_media (bool) – Pass True, if the caption must be shown above
 the message media. Supported only for animation, photo and video messages.
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 async send_audio(chat_id: int | str, audio: Any | str, caption: str | None = None, duration: int | None =
 None, performer: str | None = None, title: str | None = None, reply_to_message_id: int |
 None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup |
 ReplyKeyboardRemove | ForceReply | None = None, parse_mode: str | None = None,
 disable_notification: bool | None = None, timeout: int | None = None, thumbnail: str |
 Any | None = None, caption_entities: List[MessageEntity] | None = None,
 allow_sending_without_reply: bool | None = None, protect_content: bool | None =
 None, message_thread_id: int | None = None, thumb: str | Any | None = None,
 reply_parameters: ReplyParameters | None = None, business_connection_id: str | None
 = None, message_effect_id: str | None = None, allow_paid_broadcast: bool | None =
 None) → Message
 Use this method to send audio files, if you want Telegram clients to display them in the music player. Your
 audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently
 send audio files of up to 50 MB in size, this limit may be changed in the future.
 For sending voice messages, use the send_voice method instead.
 Telegram documentation: https://core.telegram.org/bots/api#sendaudio
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • audio (str or telebot.types.InputFile) – Audio file to send. Pass a file_id as String
 to send an audio file that exists on the Telegram servers (recommended), pass an HTTP
 URL as a String for Telegram to get an audio file from the Internet, or upload a new one
 using multipart/form-data. Audio must be in the .MP3 or .M4A format.
 • caption (str) – Audio caption, 0-1024 characters after entities parsing
 • duration (int) – Duration of the audio in seconds
 • performer (str) – Performer
 • title (str) – Track name
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply)
 • parse_mode (str) – Mode for parsing entities in the audio caption. See formatting options
 for more details.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • timeout (int) – Timeout in seconds for the request.
 • thumbnail (str or telebot.types.InputFile) – 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 “at-
 tach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
 <file_attach_name>
 Returns
 Returns True on success.
 Return type
 bool
 async send_contact(chat_id: int | str, phone_number: str, first_name: str, last_name: str | None = None,
 vcard: str | None = None, disable_notification: bool | None = None,
 reply_to_message_id: int | None = None, reply_markup: InlineKeyboardMarkup |
 ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None = None,
 timeout: int | None = None, allow_sending_without_reply: bool | None = None,
 protect_content: bool | None = None, message_thread_id: int | None = None,
 reply_parameters: ReplyParameters | None = None, business_connection_id: str |
 None = None, message_effect_id: str | None = None, allow_paid_broadcast: bool |
 None = None) → Message
 Use this method to send phone contacts. On success, the sent Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendcontact
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel
 • phone_number (str) – Contact’s phone number
 • first_name (str) – Contact’s first name
 • last_name (str) – Contact’s last name
 • vcard (str) – Additional data about the contact in the form of a vCard, 0-2048 bytes
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • timeout (int) – Timeout in seconds for the request.
 • allow_sending_without_reply (bool) – Deprecated - Use reply_parameters instead.
 Pass True, if the message should be sent even if one of the specified replied-to messages is
 not found.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – The thread to which the message will be sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 • message_effect_id (str) – Unique identifier of the message effect
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • reply_markup (InlineKeyboardMarkup or ReplyKeyboardMarkup or
 ReplyKeyboardRemove or ForceReply) – Additional interface options. A JSON-
 serialized object for an inline keyboard, custom reply keyboard, instructions to remove
 reply keyboard or to force a reply from the user.
 • timeout (int) – Timeout in seconds for waiting for a response from the bot.
 • allow_sending_without_reply (bool) – Deprecated - Use reply_parameters instead.
 Pass True, if the message should be sent even if one of the specified replied-to messages is
 not found.
 • protect_content (bool) – Pass True, if content of the message needs to be protected
 from being viewed by the bot.
 • message_thread_id (int) – Identifier of the thread to which the message will be sent.
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of the business connection.
 • message_effect_id (str) – Identifier of the message effect.
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 types.Message
 async send_gift(user_id: int, gift_id: str, text: str | None = None, text_parse_mode: str | None = None,
 text_entities: List[MessageEntity] | None = None, pay_for_upgrade: bool | None =
 None) → bool
 Sends a gift to the given user. The gift can’t be converted to Telegram Stars by the user. Returns True on
 success.
 Telegram documentation: https://core.telegram.org/bots/api#sendgift
 Parameters
 • user_id (int) – Unique identifier of the target user that will receive the gift
 • gift_id (str) – Identifier of the gift
 • pay_for_upgrade (bool) – Pass True to pay for the gift upgrade from the bot’s balance,
 thereby making the upgrade free for the receiver
 • text (str) – Text that will be shown along with the gift; 0-255 characters
 • text_parse_mode (str) – Mode for parsing entities in the text. See formatting options for
 more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”,
 and “custom_emoji” are ignored.
 • text_entities (list of types.MessageEntity) – A JSON-serialized list of special
 entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities
 • need_phone_number (bool) – Pass True, if you require the user’s phone number to com-
 plete the order
 • need_email (bool) – Pass True, if you require the user’s email to complete the order
 • need_shipping_address (bool) – Pass True, if you require the user’s shipping address
 to complete the order
 • is_flexible (bool) – Pass True, if the final price depends on the shipping method
 • send_phone_number_to_provider (bool) – Pass True, if user’s phone number should
 be sent to provider
 • send_email_to_provider (bool) – Pass True, if user’s email address should be sent to
 provider
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • reply_markup (str) – A JSON-serialized object for an inline keyboard. If empty, one
 ‘Pay total price’ button will be shown. If not empty, the first button must be a Pay button
 • provider_data (str) – A JSON-serialized data about the invoice, which will be shared
 with the payment provider. A detailed description of required fields should be provided by
 the payment provider.
 • timeout (int) – Timeout of a request, defaults to None
 • allow_sending_without_reply (bool) – Deprecated - Use reply_parameters instead.
 Pass True, if the message should be sent even if the specified replied-to message is not
 found
 • max_tip_amount (int) – The maximum accepted amount for tips in the smallest units of
 the currency
 • suggested_tip_amounts (list of int) – A JSON-serialized array of suggested
 amounts of tips in the smallest units of the currency. At most 4 suggested tip amounts
 can be specified. The suggested tip amounts must be positive, passed in a strictly increased
 order and must not exceed max_tip_amount.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – The identifier of a message thread, in which the invoice
 message will be sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • message_effect_id (str) – The identifier of a message effect to be applied to the mes-
 sage
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 types.Message
 async send_location(chat_id: int | str, latitude: float, longitude: float, live_period: int | None = None,
 reply_to_message_id: int | None = None, reply_markup: InlineKeyboardMarkup |
 ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None = None,
 disable_notification: bool | None = None, timeout: int | None = None,
 horizontal_accuracy: float | None = None, heading: int | None = None,
 proximity_alert_radius: int | None = None, allow_sending_without_reply: bool |
 None = None, protect_content: bool | None = None, message_thread_id: int | None
 = None, reply_parameters: ReplyParameters | None = None,
 business_connection_id: str | None = None, message_effect_id: str | None = None,
 allow_paid_broadcast: bool | None = None) → Message
 Use this method to send point on the map. On success, the sent Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendlocation
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • latitude (float) – Latitude of the location
 • longitude (float) – Longitude of the location
 • live_period (int) – Period in seconds during which the location will be updated (see
 Live Locations, should be between 60 and 86400, or 0x7FFFFFFF for live locations that
 can be edited indefinitely.
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • timeout (int) – Timeout in seconds for the request.
 • horizontal_accuracy (float) – The radius of uncertainty for the location, measured
 in meters; 0-1500
 • heading (int) – For live locations, a direction in which the user is moving, in degrees.
 Must be between 1 and 360 if specified.
 • proximity_alert_radius (int) – For live locations, a maximum distance for proximity
 alerts about approaching another chat member, in meters. Must be between 1 and 100000
 if specified.
 • allow_sending_without_reply (bool) – Deprecated - Use reply_parameters instead.
 Pass True, if the message should be sent even if the specified replied-to message is not
 found
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – Identifier of a message thread, in which the message will be
 sent
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • message_thread_id (int) – Unique identifier for the target message thread (topic) of the
 forum; for forum supergroups only
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • link_preview_options (telebot.types.LinkPreviewOptions) – Options for pre-
 viewing links.
 • business_connection_id (str) – Unique identifier for the target business connection
 • message_effect_id (str) – Unique identifier for the message effect
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 async send_paid_media(chat_id: int | str, star_count: int, media: List[InputPaidMedia], caption: str |
 None = None, parse_mode: str | None = None, caption_entities:
 List[MessageEntity] | None = None, show_caption_above_media: bool | None =
 None, disable_notification: bool | None = None, protect_content: bool | None =
 None, reply_parameters: ReplyParameters | None = None, reply_markup:
 InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove |
 ForceReply | None = None, business_connection_id: str | None = None, payload:
 str | None = None, allow_paid_broadcast: bool | None = None) → Message
 Use this method to send paid media to channel chats. On success, the sent Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendpaidmedia
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • star_count (int) – The number of Telegram Stars that must be paid to buy access to the
 media
 • media (list of telebot.types.InputPaidMedia) – A JSON-serialized array describ-
 ing the media to be sent; up to 10 items
 • caption (str) – Media caption, 0-1024 characters after entities parsing
 • parse_mode (str) – Mode for parsing entities in the media caption
 • caption_entities (list of telebot.types.MessageEntity) – List of special enti-
 ties that appear in the caption, which can be specified instead of parse_mode
 • show_caption_above_media (bool) – Pass True, if the caption must be shown above
 the message media
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • reply_parameters (telebot.types.ReplyParameters) – Description of the mes-
 sage to reply to
 Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “at-
 tach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
 <file_attach_name>.
 • caption (str) – Video caption (may also be used when resending videos by file_id), 0-
 1024 characters after entities parsing
 • parse_mode (str) – Mode for parsing entities in the video caption
 • caption_entities (list of telebot.types.MessageEntity) – List of special enti-
 ties that appear in the caption, which can be specified instead of parse_mode
 • supports_streaming (bool) – Pass True, if the uploaded video is suitable for streaming
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • allow_sending_without_reply (bool) – Deprecated - Use reply_parameters instead.
 Pass True, if the message should be sent even if the specified replied-to message is not
 found
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • timeout (int) – Timeout in seconds for the request.
 • data (str) – function typo miss compatibility: do not use it
 • message_thread_id (int) – Identifier of a message thread, in which the video will be
 sent
 • has_spoiler (bool) – Pass True, if the video should be sent as a spoiler
 • thumb (str or telebot.types.InputFile) – Deprecated. Use thumbnail instead
 • reply_parameters (telebot.types.ReplyParameters) – Reply parameters.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be sent
 • message_effect_id (str) – Unique identifier of the message effect
 • show_caption_above_media (bool) – Pass True, if the caption must be shown above
 the message media. Supported only for animation, photo and video messages.
 • allow_paid_broadcast (bool) – Pass True to allow up to 1000 messages per second,
 ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars
 will be withdrawn from the bot’s balance
 Returns
 On success, the sent Message is returned.
 Return type
 telebot.types.Message
 async send_video_note(chat_id: int | str, data: Any | str, duration: int | None = None, length: int | None
 = None, reply_to_message_id: int | None = None, reply_markup:
 InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove |
 ForceReply | None = None, disable_notification: bool | None = None, timeout: int
 | None = None, thumbnail: str | Any | None = None,
 allow_sending_without_reply: bool | None = None, protect_content: bool | None
 = None, message_thread_id: int | None = None, thumb: str | Any | None = None,
 reply_parameters: ReplyParameters | None = None, business_connection_id: str |
 None = None, message_effect_id: str | None = None, allow_paid_broadcast: bool
 | None = None) → Message
 As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this
 method to send video messages. On success, the sent Message is returned.
 Telegram documentation: https://core.telegram.org/bots/api#sendvideonote
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • data (str or telebot.types.InputFile) – Video note to send. Pass a file_id as String
 to send a video note that exists on the Telegram servers (recommended) or upload a new
 video using multipart/form-data. Sending video notes by a URL is currently unsupported
 • duration (int) – Duration of sent video in seconds
 • length (int) – Video width and height, i.e. diameter of the video message
 • reply_to_message_id (int) – Deprecated - Use reply_parameters instead. If the mes-
 sage is a reply, ID of the original message
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – Additional interface options. A JSON-serialized object for an
 inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force
 a reply from the user.
 • disable_notification (bool) – Sends the message silently. Users will receive a noti-
 fication with no sound.
 • timeout (int) – Timeout in seconds for the request.
 • thumbnail (str or telebot.types.InputFile) – 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 “at-
 tach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
 <file_attach_name>.
 • allow_sending_without_reply (bool) – Deprecated - Use reply_parameters instead.
 Pass True, if the message should be sent even if the specified replied-to message is not
 found
 • protect_content (bool) – Protects the contents of the sent message from forwarding
 and saving
 • message_thread_id (int) – Identifier of a message thread, in which the video note will
 be sent
 • thumb (str or telebot.types.InputFile) – Deprecated. Use thumbnail instead
 Returns
 True on success.
 Return type
 bool
 async set_chat_menu_button(chat_id: int | str = None, menu_button: MenuButton = None) → bool
 Use this method to change the bot’s menu button in a private chat, or the default menu button. Returns True
 on success.
 Telegram documentation: https://core.telegram.org/bots/api#setchatmenubutton
 Parameters
 • chat_id (int or str) – Unique identifier for the target private chat. If not specified,
 default bot’s menu button will be changed.
 • menu_button (telebot.types.MenuButton) – A JSON-serialized object for the new
 bot’s menu button. Defaults to MenuButtonDefault
 Returns
 True on success.
 Return type
 bool
 async set_chat_permissions(chat_id: int | str, permissions: ChatPermissions,
 use_independent_chat_permissions: bool | None = None) → bool
 Use this method to set default chat permissions for all members. The bot must be an administrator in the
 group or a supergroup for this to work and must have the can_restrict_members admin rights.
 Telegram documentation: https://core.telegram.org/bots/api#setchatpermissions
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • permissions (telebot.types..ChatPermissions) – New default chat permissions
 • use_independent_chat_permissions (bool) – Pass True if chat permis-
 sions are set independently. Otherwise, the can_send_other_messages and
 can_add_web_page_previews permissions will imply the can_send_messages,
 can_send_audios, can_send_documents, can_send_photos, can_send_videos,
 can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls
 permission will imply the can_send_messages permission.
 Returns
 True on success
 Return type
 bool
 async set_chat_photo(chat_id: int | str, photo: Any) → bool
 Use this method to set a new profile photo for the chat. Photos can’t be changed for private chats. The bot
 must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns
 True on success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members
 Are Admins’ setting is off in the target group.
 Telegram documentation: https://core.telegram.org/bots/api#setchatphoto
 Parameters
 • chat_id (int or str) – Int or Str: Unique identifier for the target chat or username of the
 target channel (in the format @channelusername)
 • photo (typing.Union[file_like, str]) – InputFile: New chat photo, uploaded using
 multipart/form-data
 Returns
 True on success.
 Return type
 bool
 async set_chat_sticker_set(chat_id: int | str, sticker_set_name: str) → StickerSet
 Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the
 chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set
 optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setchatstickerset
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup (in the format @supergroupusername)
 • sticker_set_name (str) – Name of the sticker set to be set as the group sticker set
 Returns
 StickerSet object
 Return type
 telebot.types.StickerSet
 async set_chat_title(chat_id: int | str, title: str) → bool
 Use this method to change the title of a chat. Titles can’t be changed for private chats. The bot must be
 an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on
 success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are
 Admins’ setting is off in the target group.
 Telegram documentation: https://core.telegram.org/bots/api#setchattitle
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • title (str) – New chat title, 1-255 characters
 Returns
 True on success.
 Return type
 bool
 async set_custom_emoji_sticker_set_thumbnail(name: str, custom_emoji_id: str | None = None) →
 bool
 Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success.
 Parameters
 • name (str) – Sticker set name
 • custom_emoji_id (str) – Custom emoji identifier of a sticker from the sticker set; pass
 an empty string to drop the thumbnail and use the first sticker as the thumbnail.
 Returns
 Returns True on success.
 Return type
 bool
 async set_game_score(user_id: int | str, score: int, force: bool | None = None, chat_id: int | str | None =
 None, message_id: int | None = None, inline_message_id: str | None = None,
 disable_edit_message: bool | None = None) → Message | bool
 Sets the value of points in the game to a specific user.
 Telegram documentation: https://core.telegram.org/bots/api#setgamescore
 Parameters
 • user_id (int or str) – User identifier
 • score (int) – New score, must be non-negative
 • force (bool) – Pass True, if the high score is allowed to decrease. This can be useful
 when fixing mistakes or banning cheaters
 • chat_id (int or str) – Required if inline_message_id is not specified. Unique identifier
 for the target chat or username of the target channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the sent
 message
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message
 • disable_edit_message (bool) – Pass True, if the game message should not be automat-
 ically edited to include the current scoreboard
 Returns
 On success, if the message was sent by the bot, returns the edited Message, otherwise returns
 True.
 Return type
 types.Message or bool
 async set_message_reaction(chat_id: int | str, message_id: int, reaction: List[ReactionType] | None =
 None, is_big: bool | None = None) → bool
 Use this method to change the chosen reactions on a message. Service messages can’t be reacted to. Auto-
 matically forwarded messages from a channel to its discussion group have the same available reactions as
 messages in the channel. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setmessagereaction
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 supergroup or channel (in the format @channelusername)
 • message_id (int) – Identifier of the message to set reaction to
 • reaction (list of telebot.types.ReactionType) – New list of reaction types to set
 on the message. Currently, as non-premium users, bots can set up to one reaction per
 message. A custom emoji reaction can be used if it is either already present on the message
 or explicitly allowed by chat administrators.
 • is_big (bool) – Pass True to set the reaction with a big animation
 Returns
 bool
 async set_my_commands(commands: List[BotCommand], scope: BotCommandScope | None = None,
 language_code: str | None = None) → bool
 Use this method to change the list of the bot’s commands.
 Telegram documentation: https://core.telegram.org/bots/api#setmycommands
 Parameters
 • commands (list of telebot.types.BotCommand) – List of BotCommand. At most 100
 commands can be specified.
 • scope (telebot.types.BotCommandScope) – The scope of users for which the com-
 mands are relevant. Defaults to BotCommandScopeDefault.
 • language_code (str) – A two-letter ISO 639-1 language code. If empty, commands will
 be applied to all users from the given scope, for whose language there are no dedicated
 commands
 Returns
 True on success.
 Return type
 bool
 async set_my_default_administrator_rights(rights: ChatAdministratorRights = None, for_channels:
 bool = None) → bool
 Use this method to change the default administrator rights requested by the bot when it’s added as an
 administrator to groups or channels. These rights will be suggested to users, but they are are free to modify
 the list before adding the bot. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setmydefaultadministratorrights
 Parameters
 • rights (telebot.types.ChatAdministratorRights) – A JSON-serialized object de-
 scribing new default administrator rights. If not specified, the default administrator rights
 will be cleared.
 • for_channels (bool) – Pass True to change the default administrator rights of the bot in
 channels. Otherwise, the default administrator rights of the bot for groups and supergroups
 will be changed.
 Returns
 True on success.
 Return type
 bool
 async set_my_description(description: str | None = None, language_code: str | None = None)
 Use this method to change the bot’s description, which is shown in the chat with the bot if the chat is empty.
 Returns True on success.
 Parameters
 • description (str) – New bot description; 0-512 characters. Pass an empty string to
 remove the dedicated description for the given language.
 • language_code (str) – A two-letter ISO 639-1 language code. If empty, the description
 will be applied to all users for whose language there is no dedicated description.
 Returns
 True on success.
 async set_my_name(name: str | None = None, language_code: str | None = None)
 Use this method to change the bot’s name. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setmyname
 Parameters
 • name (str) – Optional. New bot name; 0-64 characters. Pass an empty string to remove
 the dedicated name for the given language.
 • language_code (str) – Optional. A two-letter ISO 639-1 language code. If empty, the
 name will be shown to all users for whose language there is no dedicated name.
 Returns
 True on success.
 async set_my_short_description(short_description: str | None = None, language_code: str | None =
 None)
 Use this method to change the bot’s short description, which is shown on the bot’s profile page and is sent
 together with the link when users share the bot. Returns True on success.
 Parameters
 • short_description (str) – New short description for the bot; 0-120 characters. Pass
 an empty string to remove the dedicated short description for the given language.
 • language_code (str) – A two-letter ISO 639-1 language code. If empty, the short de-
 scription will be applied to all users for whose language there is no dedicated short descrip-
 tion.
 Returns
 True on success.
 async set_state(user_id: int, state: int | str | State, chat_id: int | None = None, business_connection_id:
 str | None = None, message_thread_id: int | None = None, bot_id: int | None = None) →
 bool
 Sets a new state of a user.
ò Note
 You should set both user id and chat id in order to set state for a user in a chat. Otherwise, if you only
 set user_id, chat_id will equal to user_id, this means that state will be set for the user in his private chat
 with a bot.
 Changed in version 4.23.0: Added additional parameters to support topics, business connections, and mes-
 sage threads.
ã See also
 Parameters
 • user_id (int) – User’s identifier
 async set_sticker_set_thumbnail(name: str, user_id: int, thumbnail: Any | str = None, format: str |
 None = None) → bool
 Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker
 sets only. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#setstickersetthumbnail
 Parameters
 • name (str) – Sticker set name
 • user_id (int) – User identifier
 • thumbnail (filelike object) – A .WEBP or .PNG image with the thumbnail, must be
 up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS ani-
 mation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#
 animated-sticker-requirements for animated sticker technical requirements), or a WEBM
 video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#
 video-sticker-requirements for video sticker technical requirements. Pass a file_id as a
 String to send a file that already exists on the Telegram servers, pass an HTTP URL as a
 String for Telegram to get a file from the Internet, or upload a new one using multipart/form-
 data. More information on Sending Files ». Animated and video sticker set thumbnails
 can’t be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first
 sticker is used as the thumbnail.
 Returns
 On success, True is returned.
 Return type
 bool
 async set_sticker_set_title(name: str, title: str) → bool
 Use this method to set the title of a created sticker set. Returns True on success.
 Parameters
 • name (str) – Sticker set name
 • title (str) – New sticker set title
 Returns
 Returns True on success.
 Return type
 bool
 set_update_listener(func: Awaitable)
 Update listener is a function that gets any update.
 Parameters
 func (Awaitable) – function that should get update.
bot.set_update_listener(update_listener)
 Returns
 None
 • certificate (str, optional) – Upload your public key certificate so that the root certifi-
 cate in use can be checked, defaults to None
 • max_connections (int, optional) – The maximum allowed number of simultaneous
 HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use
 lower values to limit the load on your bot’s server, and higher values to increase your bot’s
 throughput, defaults to None
 • allowed_updates (list, optional) – A JSON-serialized list of the update types you
 want your bot to receive. For example, specify [“message”, “edited_channel_post”, “call-
 back_query”] to only receive updates of these types. See Update for a complete list of avail-
 able update types. Specify an empty list to receive all update types except chat_member
 (default). If not specified, the previous setting will be used.
 Please note that this parameter doesn’t affect updates created before the call to the setWeb-
 hook, so unwanted updates may be received for a short period of time. Defaults to None
 • ip_address (str, optional) – The fixed IP address which will be used to send webhook
 requests instead of the IP address resolved through DNS, defaults to None
 • drop_pending_updates (bool, optional) – Pass True to drop all pending updates, de-
 faults to None
 • timeout (int, optional) – Timeout of a request, defaults to None
 • secret_token (str, optional) – A secret token to be sent in a header “X-Telegram-Bot-
 Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z,
 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a
 webhook set by you. Defaults to None
 Returns
 True on success.
 Return type
 bool if the request was successful.
 setup_middleware(middleware: BaseMiddleware)
 Setup middleware.
ò Note
 Parameters
 middleware (telebot.asyncio_handler_backends.BaseMiddleware) – Middleware-
 class.
 Returns
 None
 shipping_query_handler(func, **kwargs)
 Handles new incoming shipping query. Only for invoices with flexible price. As a parameter to the decorator
 function, it passes telebot.types.ShippingQuery object.
 Parameters
 • func (function) – Function executed as a filter
 • kwargs – Optional keyword arguments(custom filters)
 Returns
 None
 async skip_updates()
 Skip existing updates. Only last update will remain on server.
 async stop_message_live_location(chat_id: int | str | None = None, message_id: int | None = None,
 inline_message_id: str | None = None, reply_markup:
 InlineKeyboardMarkup | None = None, timeout: int | None = None,
 business_connection_id: str | None = None) → Message
 Use this method to stop updating a live location message before live_period expires. On success, if the
 message is not an inline message, the edited Message is returned, otherwise True is returned.
 Telegram documentation: https://core.telegram.org/bots/api#stopmessagelivelocation
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Required if inline_message_id is not specified. Identifier of the mes-
 sage with live location to stop
 • inline_message_id (str) – Required if chat_id and message_id are not specified. Iden-
 tifier of the inline message with live location to stop
 • reply_markup (telebot.types.InlineKeyboardMarkup or telebot.types.
 ReplyKeyboardMarkup or telebot.types.ReplyKeyboardRemove or telebot.
 types.ForceReply) – A JSON-serialized object for a new inline keyboard.
 • timeout (int) – Timeout in seconds for the request.
 • business_connection_id (str) – Identifier of a business connection, in which the mes-
 sage will be edited
 Returns
 On success, if the message is not an inline message, the edited Message is returned, otherwise
 True is returned.
 Return type
 telebot.types.Message or bool
 async stop_poll(chat_id: int | str, message_id: int, reply_markup: InlineKeyboardMarkup | None = None,
 business_connection_id: str | None = None) → Poll
 Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
 Telegram documentation: https://core.telegram.org/bots/api#stoppoll
 Parameters
 • chat_id (int | str) – Unique identifier for the target chat or username of the target channel
 • message_id (int) – Identifier of the original message with the poll
 • reply_markup (InlineKeyboardMarkup) – A JSON-serialized object for a new message
 markup.
 • business_connection_id (str) – Identifier of the business connection to send the mes-
 sage through
 Returns
 On success, the stopped Poll is returned.
 Return type
 types.Poll
 async unban_chat_member(chat_id: int | str, user_id: int, only_if_banned: bool | None = False) → bool
 Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to
 the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator
 for this to work. By default, this method guarantees that after the call the user is not a member of the chat,
 but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If
 you don’t want this, use the parameter only_if_banned.
 Telegram documentation: https://core.telegram.org/bots/api#unbanchatmember
 Parameters
 • chat_id (int or str) – Unique identifier for the target group or username of the target
 supergroup or channel (in the format @username)
 • user_id (int) – Unique identifier of the target user
 • only_if_banned (bool) – Do nothing if the user is not banned
 Returns
 True on success
 Return type
 bool
 async unban_chat_sender_chat(chat_id: int | str, sender_chat_id: int | str) → bool
 Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an
 administrator for this to work and must have the appropriate administrator rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unbanchatsenderchat
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • sender_chat_id (int or str) – Unique identifier of the target sender chat.
 Returns
 True on success.
 Return type
 bool
 async unhide_general_forum_topic(chat_id: int | str) → bool
 Use this method to unhide the ‘General’ topic in a forum supergroup chat. The bot must be an administrator
 in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unhidegeneralforumtopic
 Parameters
 chat_id (int or str) – Unique identifier for the target chat or username of the target channel
 (in the format @channelusername)
 async unpin_all_chat_messages(chat_id: int | str) → bool
 Use this method to unpin a all pinned messages in a supergroup chat. The bot must be an administrator in
 the chat for this to work and must have the appropriate admin rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unpinallchatmessages
 Parameters
 chat_id (int or str) – Int or Str: Unique identifier for the target chat or username of the
 target channel (in the format @channelusername)
 Returns
 True on success.
 Return type
 bool
 async unpin_all_forum_topic_messages(chat_id: str | int, message_thread_id: int) → bool
 Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator
 in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
 Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unpinallforumtopicmessages
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_thread_id (int) – Identifier of the topic
 Returns
 On success, True is returned.
 Return type
 bool
 async unpin_all_general_forum_topic_messages(chat_id: int | str) → bool
 Use this method to clear the list of pinned messages in a General forum topic. The bot must be an adminis-
 trator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
 Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unpinAllGeneralForumTopicMessages
 Parameters
 chat_id (int | str) – Unique identifier for the target chat or username of chat
 Returns
 On success, True is returned.
 Return type
 bool
 async unpin_chat_message(chat_id: int | str, message_id: int | None = None, business_connection_id: str
 | None = None) → bool
 Use this method to unpin specific pinned message in a supergroup chat. The bot must be an administrator
 in the chat for this to work and must have the appropriate admin rights. Returns True on success.
 Telegram documentation: https://core.telegram.org/bots/api#unpinchatmessage
 Parameters
 • chat_id (int or str) – Unique identifier for the target chat or username of the target
 channel (in the format @channelusername)
 • message_id (int) – Int: Identifier of a message to unpin
 • business_connection_id (str) – Unique identifier of the business connection
 Returns
 True on success.
 Return type
 bool
 async upload_sticker_file(user_id: int, png_sticker: Any | str = None, sticker: InputFile | None = None,
 sticker_format: str | None = None) → File
 Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet
 methods (can be used multiple times). Returns the uploaded File on success.
 Telegram documentation: https://core.telegram.org/bots/api#uploadstickerfile
 Parameters
 • user_id (int) – User identifier of sticker set owner
 • png_sticker (filelike object) – DEPRECATED: PNG image with the sticker, must
 be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or
 height must be exactly 512px.
 • sticker (telebot.types.InputFile) – A file with the sticker in .WEBP, .PNG, .TGS,
 or .WEBM format. See https://core.telegram.org/stickers for technical requirements. More
 information on Sending Files »
 • sticker_format (str) – One of “static”, “animated”, “video”.
 Returns
 On success, the sent file is returned.
 Return type
 telebot.types.File
 property user
 Returns
 Returns True on success.
 Return type
 bool
class telebot.async_telebot.ExceptionHandler
 Bases: object
 Class for handling exceptions while Polling
 async handle(exception)
Asyncio filters
class telebot.asyncio_filters.AdvancedCustomFilter
 Bases: ABC
 Advanced Custom Filter base class. Create child class with check() method. Accepts two parameters, returns
 bool: True - filter passed, False - filter failed. message: Message class text: Filter value given in handler
 Child classes should have .key property.
class telebot.asyncio_filters.ChatFilter
 Bases: AdvancedCustomFilter
 Check whether chat_id corresponds to given chat_id.
class telebot.asyncio_filters.ForwardFilter
 Bases: SimpleCustomFilter
 Check whether message was forwarded from channel or group.
class telebot.asyncio_filters.IsAdminFilter(bot)
 Bases: SimpleCustomFilter
 Check whether the user is administrator / owner of the chat.
class telebot.asyncio_filters.IsDigitFilter
 Bases: SimpleCustomFilter
 Filter to check whether the string is made up of only digits.
class telebot.asyncio_filters.IsReplyFilter
 Bases: SimpleCustomFilter
 Check whether message is a reply.
class telebot.asyncio_filters.LanguageFilter
 Bases: AdvancedCustomFilter
 Check users language_code.
class telebot.asyncio_filters.SimpleCustomFilter
 Bases: ABC
 Simple Custom Filter base class. Create child class with check() method. Accepts only message, returns bool
 value, that is compared with given in handler.
 Child classes should have .key property.
class telebot.asyncio_filters.StateFilter(bot)
 Bases: AdvancedCustomFilter
 Filter to check state.
class telebot.asyncio_filters.TextContainsFilter
 Bases: AdvancedCustomFilter
 Filter to check Text message. key: text
class telebot.asyncio_filters.TextFilter(equals: str | None = None, contains: list | tuple | None = None,
 starts_with: str | list | tuple | None = None, ends_with: str | list
 | tuple | None = None, ignore_case: bool = False)
 Bases: object
 Advanced text filter to check (types.Message, types.CallbackQuery, types.InlineQuery, types.Poll)
 example of usage is in examples/asynchronous_telebot/custom_filters/advanced_text_filter.py
 Parameters
 • equals (str) – string, True if object’s text is equal to passed string
class telebot.asyncio_filters.TextStartsFilter
 Bases: AdvancedCustomFilter
 Filter to check whether message starts with some text.
class telebot.asyncio_handler_backends.CancelUpdate
 Bases: object
 Class for canceling updates. Just return instance of this class in middleware to skip update. Update will skip
 handler and execution of post_process in middlewares.
class telebot.asyncio_handler_backends.ContinueHandling
 Bases: object
 Class for continue updates in handlers. Just return instance of this class in handlers to continue process.
 @bot.message_handler(commands=['start'])
 async def start2(message):
 await bot.send_message(message.chat.id, 'Hello World2!')
class telebot.asyncio_handler_backends.SkipHandler
 Bases: object
 Class for skipping handlers. Just return instance of this class in middleware to skip handler. Update will go to
 post_process, but will skip execution of handler.
Extensions
1.3.7 Utils
util file
telebot.util.antiflood(function: Callable, *args, number_retries=5, **kwargs)
 Use this function inside loops in order to avoid getting TooManyRequests error. Example:
 Parameters
 • function (:obj:int) – The function to call
 • number_retries – Number of retries to send
 • args (tuple) – The arguments to pass to the function
 • kwargs (dict) – The keyword arguments to pass to the function
 Returns
 None
telebot.util.chunks(lst, n)
 Yield successive n-sized chunks from lst.
telebot.util.content_type_media = ['text', 'animation', 'audio', 'document', 'photo',
'sticker', 'story', 'video', 'video_note', 'voice', 'contact', 'dice', 'game', 'poll',
'venue', 'location', 'invoice', 'successful_payment', 'connected_website',
'passport_data', 'web_app_data']
 Contains all media content types.
telebot.util.content_type_service = ['new_chat_members', 'left_chat_member',
'new_chat_title', 'new_chat_photo', 'delete_chat_photo', 'group_chat_created',
'supergroup_chat_created', 'channel_chat_created', 'message_auto_delete_timer_changed',
'migrate_to_chat_id', 'migrate_from_chat_id', 'pinned_message', 'users_shared',
'chat_shared', 'write_access_allowed', 'proximity_alert_triggered',
'forum_topic_created', 'forum_topic_edited', 'forum_topic_closed',
'forum_topic_reopened', 'general_forum_topic_hidden', 'general_forum_topic_unhidden',
'giveaway_created', 'giveaway', 'giveaway_winners', 'giveaway_completed',
'video_chat_scheduled', 'video_chat_started', 'video_chat_ended',
'video_chat_participants_invited']
 Contains all service content types such as User joined the group.
telebot.util.escape(text: str) → str | None
 Replaces the following chars in text (’&’ with ‘&’, ‘<’ with ‘<’ and ‘>’ with ‘>’).
 Parameters
 text – the text to escape
 Returns
 the escaped text
telebot.util.extract_arguments(text: str) → str
 Returns the argument after the command.
 Parameters
 text (str) – String to extract the arguments from a command
 Returns
 the arguments if text is a command (according to is_command), else None.
 Return type
 str or None
 Parameters
 text (str) – String to extract the command from
 Returns
 the command if text is a command (according to is_command), else None.
 Return type
 str or None
telebot.util.generate_random_token() → str
 Generates a random token consisting of letters and digits, 16 characters long.
 Returns
 a random token
 Return type
 str
telebot.util.is_bytes(var) → bool
 Returns True if the given object is a bytes object.
 Parameters
 var (object) – object to be checked
 Returns
 True if the given object is a bytes object.
 Return type
 bool
telebot.util.is_command(text: str) → bool
 Checks if text is a command. Telegram chat commands start with the ‘/’ character.
 Parameters
 text (str) – Text to check.
 Returns
 True if text is a command, else False.
 Return type
 bool
telebot.util.is_dict(var) → bool
 Returns True if the given object is a dictionary.
 Parameters
 var (object) – object to be checked
 Returns
 True if the given object is a dictionary.
 Return type
 bool
telebot.util.is_pil_image(var) → bool
 Returns True if the given object is a PIL.Image.Image object.
 Parameters
 var (object) – object to be checked
 Returns
 True if the given object is a PIL.Image.Image object.
 Return type
 bool
telebot.util.is_string(var) → bool
 Returns True if the given object is a string.
telebot.util.parse_web_app_data(token: str, raw_init_data: str)
 Parses web app data.
 Parameters
 • token (str) – The bot token
 • raw_init_data (str) – The raw init data
 Returns
 The parsed init data
telebot.util.pil_image_to_file(image, extension='JPEG', quality='web_low')
 markup = quick_markup({
 'Twitter': {'url': 'https://twitter.com'},
 'Facebook': {'url': 'https://facebook.com'},
 'Back': {'callback_data': 'whatever'}
 }, row_width=2)
 # returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter,
 ˓→ the other to facebook
 Parameters
 • values (dict) – a dict containing all buttons to create in this format: {text: kwargs} {str:}
 • row_width (int) – number of telebot.types.InlineKeyboardButton objects on each
 row
 Returns
 InlineKeyboardMarkup
 Return type
 types.InlineKeyboardMarkup
ò Note
 You can use formatting.* for all other formatting options(bold, italic, links, and etc.) This method is kept for
 backward compatibility, and it is recommended to use formatting.* for more options.
 Parameters
 • user (telebot.types.User) – the user (not the user_id)
 • include_id (bool) – include the user_id
 Returns
 HTML user link
 Return type
 str
telebot.util.validate_token(token) → bool
 Custom subs:
 You can customize the substitutes. By default, there is no substitute for the entities: hashtag, bot_command,
 email. You can add or modify substitute an existing entity.
 )
 >> "<strong class="example">Test</strong> parse <i class="example">formatting</i>,
 ˓→<a href="https://example.com">url</a> and <a href="tg://user?id=123456">text_
telebot.formatting.format_text(*args, separator='\n')
 Formats a list of strings into a single string.
 Parameters
 • args (str) – Strings to format.
 • separator (str) – The separator to use between each string.
 Returns
 The formatted string.
 Return type
 str
 Return type
 str
telebot.formatting.hide_link(url: str) → str
 Hide url of an image.
 Parameters
 url (str) – The url of the image.
 Returns
 The hidden url.
 Return type
 str
telebot.formatting.hitalic(content: str, escape: bool | None = True) → str
 Returns an HTML-formatted italic string.
 Parameters
 • content (str) – The string to italicize.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
telebot.formatting.hlink(content: str, url: str, escape: bool | None = True) → str
 Returns an HTML-formatted link string.
 Parameters
 • content (str) – The string to link.
 • url (str) – The URL to link to.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
telebot.formatting.hpre(content: str, escape: bool | None = True, language: str = '') → str
 Returns an HTML-formatted preformatted string.
 Parameters
 • content (str) – The string to preformatted.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 • expandable (bool) – True if you need the quote to be expandable. Defaults to False.
 Returns
 The formatted string.
 Return type
 str
telebot.formatting.mcode(content: str, language: str = '', escape: bool | None = True) → str
 Returns a Markdown-formatted code string.
 Parameters
 • content (str) – The string to code.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
telebot.formatting.mitalic(content: str, escape: bool | None = True) → str
 Returns a Markdown-formatted italic string.
 Parameters
 • content (str) – The string to italicize.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
telebot.formatting.mlink(content: str, url: str, escape: bool | None = True) → str
 Returns a Markdown-formatted link string.
 Parameters
 • content (str) – The string to link.
 • url (str) – The URL to link to.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
telebot.formatting.mspoiler(content: str, escape: bool | None = True) → str
 Returns a Markdown-formatted spoiler string.
 Parameters
 • content (str) – The string to spoiler.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
telebot.formatting.mstrikethrough(content: str, escape: bool | None = True) → str
 Returns a Markdown-formatted strikethrough string.
 Parameters
 • content (str) – The string to strikethrough.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
telebot.formatting.munderline(content: str, escape: bool | None = True) → str
 Returns a Markdown-formatted underline string.
 Parameters
 • content (str) – The string to underline.
 • escape (bool) – True if you need to escape special characters. Defaults to True.
 Returns
 The formatted string.
 Return type
 str
TWO
• genindex
• modindex
• search
 323
pyTelegramBotAPI, Release 4.25.0
t
telebot, 117
telebot.async_telebot, 216
telebot.asyncio_filters, 306
telebot.asyncio_handler_backends, 309
telebot.callback_data, 310
telebot.custom_filters, 211
telebot.formatting, 317
telebot.handler_backends, 215
telebot.types, 3
telebot.util, 311
 325
pyTelegramBotAPI, Release 4.25.0
A answer_web_app_query() (tele-
add() (telebot.types.InlineKeyboardMarkup method), 43 bot.async_telebot.AsyncTeleBot method),
add() (telebot.types.Poll method), 93 221
add() (telebot.types.ReplyKeyboardMarkup method), 98 answer_web_app_query() (telebot.TeleBot method),
add_custom_filter() (tele- 123
 bot.async_telebot.AsyncTeleBot method), antiflood() (in module telebot.util), 311
 217 any_entities (telebot.types.Message property), 86
add_custom_filter() (telebot.TeleBot method), 119 any_text (telebot.types.Message property), 86
add_data() (telebot.async_telebot.AsyncTeleBot apply_html_entities() (in module tele-
 method), 217 bot.formatting), 317
add_data() (telebot.TeleBot method), 119 approve_chat_join_request() (tele-
add_price() (telebot.types.ShippingOption method), bot.async_telebot.AsyncTeleBot method),
 102 221
add_sticker_to_set() (tele- approve_chat_join_request() (telebot.TeleBot
 bot.async_telebot.AsyncTeleBot method), method), 123
 218 AsyncTeleBot (class in telebot.async_telebot), 216
add_sticker_to_set() (telebot.TeleBot method), 120 Audio (class in telebot.types), 4
AdvancedCustomFilter (class in tele-
 bot.asyncio_filters), 306 B
AdvancedCustomFilter (class in tele- BackgroundFill (class in telebot.types), 5
 bot.custom_filters), 211 BackgroundFillFreeformGradient (class in tele-
AffiliateInfo (class in telebot.types), 3 bot.types), 5
Animation (class in telebot.types), 4 BackgroundFillGradient (class in telebot.types), 5
answer_callback_query() (tele- BackgroundFillSolid (class in telebot.types), 6
 bot.async_telebot.AsyncTeleBot method), BackgroundType (class in telebot.types), 6
 219 BackgroundTypeChatTheme (class in telebot.types), 6
answer_callback_query() (telebot.TeleBot method), BackgroundTypeFill (class in telebot.types), 7
 121 BackgroundTypePattern (class in telebot.types), 7
answer_inline_query() (tele- BackgroundTypeWallpaper (class in telebot.types), 7
 bot.async_telebot.AsyncTeleBot method), ban_chat_member() (tele-
 219 bot.async_telebot.AsyncTeleBot method),
answer_inline_query() (telebot.TeleBot method), 121 221
answer_pre_checkout_query() (tele- ban_chat_member() (telebot.TeleBot method), 123
 bot.async_telebot.AsyncTeleBot method), ban_chat_sender_chat() (tele-
 220 bot.async_telebot.AsyncTeleBot method),
answer_pre_checkout_query() (telebot.TeleBot 222
 method), 122 ban_chat_sender_chat() (telebot.TeleBot method),
answer_shipping_query() (tele- 124
 bot.async_telebot.AsyncTeleBot method), BaseMiddleware (class in tele-
 220 bot.asyncio_handler_backends), 309
answer_shipping_query() (telebot.TeleBot method), BaseMiddleware (class in telebot.handler_backends),
 122 215
 327
pyTelegramBotAPI, Release 4.25.0
328 Index
 pyTelegramBotAPI, Release 4.25.0
Index 329
pyTelegramBotAPI, Release 4.25.0
330 Index
 pyTelegramBotAPI, Release 4.25.0
Index 331
pyTelegramBotAPI, Release 4.25.0
332 Index
 pyTelegramBotAPI, Release 4.25.0
Index 333
pyTelegramBotAPI, Release 4.25.0
334 Index
 pyTelegramBotAPI, Release 4.25.0
Index 335
pyTelegramBotAPI, Release 4.25.0
336 Index
 pyTelegramBotAPI, Release 4.25.0
Index 337
pyTelegramBotAPI, Release 4.25.0
338 Index
 pyTelegramBotAPI, Release 4.25.0
set_user_emoji_status() (tele- T
 bot.async_telebot.AsyncTeleBot method), telebot
 300 module, 117
set_user_emoji_status() (telebot.TeleBot method), TeleBot (class in telebot), 118
 205 telebot.async_telebot
set_webhook() (telebot.async_telebot.AsyncTeleBot module, 216
 method), 300 telebot.asyncio_filters
set_webhook() (telebot.TeleBot method), 206 module, 306
setup_middleware() (tele- telebot.asyncio_handler_backends
 bot.async_telebot.AsyncTeleBot method), module, 309
 301 telebot.callback_data
setup_middleware() (telebot.TeleBot method), 207 module, 310
SharedUser (class in telebot.types), 101 telebot.custom_filters
shipping_query_handler() (tele- module, 211
 bot.async_telebot.AsyncTeleBot method), telebot.formatting
 301 module, 317
shipping_query_handler() (telebot.TeleBot method), telebot.handler_backends
 207 module, 215
ShippingAddress (class in telebot.types), 101 telebot.types
ShippingOption (class in telebot.types), 102 module, 3
ShippingQuery (class in telebot.types), 102 telebot.util
SimpleCustomFilter (class in telebot.asyncio_filters), module, 311
 307 TextContainsFilter (class in telebot.asyncio_filters),
SimpleCustomFilter (class in telebot.custom_filters), 308
 213 TextContainsFilter (class in telebot.custom_filters),
skip_updates() (telebot.async_telebot.AsyncTeleBot 213
 method), 302 TextFilter (class in telebot.asyncio_filters), 308
SkipHandler (class in tele- TextFilter (class in telebot.custom_filters), 214
 bot.asyncio_handler_backends), 310 TextMatchFilter (class in telebot.asyncio_filters), 309
SkipHandler (class in telebot.handler_backends), 216 TextMatchFilter (class in telebot.custom_filters), 214
smart_split() (in module telebot.util), 315 TextQuote (class in telebot.types), 106
split_string() (in module telebot.util), 315 TextStartsFilter (class in telebot.asyncio_filters),
StarTransaction (class in telebot.types), 103 309
StarTransactions (class in telebot.types), 103 TextStartsFilter (class in telebot.custom_filters), 214
StateFilter (class in telebot.asyncio_filters), 308 thumb (telebot.types.Animation property), 4
StateFilter (class in telebot.custom_filters), 213 thumb (telebot.types.Audio property), 5
Sticker (class in telebot.types), 103 thumb (telebot.types.Document property), 34
StickerSet (class in telebot.types), 104 thumb (telebot.types.InputMediaAnimation property), 68
stop_bot() (telebot.TeleBot method), 207 thumb (telebot.types.InputMediaAudio property), 69
stop_message_live_location() (tele- thumb (telebot.types.InputMediaDocument property), 70
 bot.async_telebot.AsyncTeleBot method), thumb (telebot.types.InputMediaVideo property), 71
 302 thumb (telebot.types.Sticker property), 104
stop_message_live_location() (telebot.TeleBot thumb (telebot.types.StickerSet property), 105
 method), 207 thumb (telebot.types.Video property), 114
stop_poll() (telebot.async_telebot.AsyncTeleBot thumb (telebot.types.VideoNote property), 115
 method), 302 thumb_height (telebot.types.InlineQueryResultArticle
stop_poll() (telebot.TeleBot method), 208 property), 45
stop_polling() (telebot.TeleBot method), 208 thumb_height (telebot.types.InlineQueryResultContact
Story (class in telebot.types), 105 property), 54
SuccessfulPayment (class in telebot.types), 105 thumb_height (telebot.types.InlineQueryResultDocument
SwitchInlineQueryChosenChat (class in tele- property), 56
 bot.types), 106 thumb_height (telebot.types.InlineQueryResultLocation
 property), 58
Index 339
pyTelegramBotAPI, Release 4.25.0
thumb_height (telebot.types.InlineQueryResultVenue U
 property), 61 unban_chat_member() (tele-
thumb_mime_type (telebot.types.InlineQueryResultGif bot.async_telebot.AsyncTeleBot method),
 property), 57 303
thumb_mime_type (tele- unban_chat_member() (telebot.TeleBot method), 208
 bot.types.InlineQueryResultMpeg4Gif prop- unban_chat_sender_chat() (tele-
 erty), 59 bot.async_telebot.AsyncTeleBot method),
thumb_url (telebot.types.InlineQueryResultArticle prop- 303
 erty), 45 unban_chat_sender_chat() (telebot.TeleBot method),
thumb_url (telebot.types.InlineQueryResultContact 208
 property), 55 unhide_general_forum_topic() (tele-
thumb_url (telebot.types.InlineQueryResultDocument bot.async_telebot.AsyncTeleBot method),
 property), 56 303
thumb_url (telebot.types.InlineQueryResultGif prop- unhide_general_forum_topic() (telebot.TeleBot
 erty), 57 method), 209
thumb_url (telebot.types.InlineQueryResultLocation unpin_all_chat_messages() (tele-
 property), 58 bot.async_telebot.AsyncTeleBot method),
thumb_url (telebot.types.InlineQueryResultMpeg4Gif 303
 property), 59 unpin_all_chat_messages() (telebot.TeleBot
thumb_url (telebot.types.InlineQueryResultPhoto prop- method), 209
 erty), 60 unpin_all_forum_topic_messages() (tele-
thumb_url (telebot.types.InlineQueryResultVenue prop- bot.async_telebot.AsyncTeleBot method),
 erty), 61 304
thumb_url (telebot.types.InlineQueryResultVideo prop- unpin_all_forum_topic_messages() (tele-
 erty), 63 bot.TeleBot method), 209
thumb_width (telebot.types.InlineQueryResultArticle unpin_all_general_forum_topic_messages()
 property), 45 (telebot.async_telebot.AsyncTeleBot method),
thumb_width (telebot.types.InlineQueryResultContact 304
 property), 55 unpin_all_general_forum_topic_messages()
thumb_width (telebot.types.InlineQueryResultDocument (telebot.TeleBot method), 209
 property), 56 unpin_chat_message() (tele-
thumb_width (telebot.types.InlineQueryResultLocation bot.async_telebot.AsyncTeleBot method),
 property), 58 304
thumb_width (telebot.types.InlineQueryResultVenue unpin_chat_message() (telebot.TeleBot method), 210
 property), 61 Update (class in telebot.types), 109
to_dict() (telebot.types.CopyTextButton method), 33 update_sensitive (tele-
to_dict() (telebot.types.InputPaidMedia method), 71 bot.asyncio_handler_backends.BaseMiddleware
to_dict() (telebot.types.InputPaidMediaVideo attribute), 310
 method), 72 update_sensitive (tele-
to_dict() (telebot.types.InputPollOption method), 73 bot.handler_backends.BaseMiddleware at-
to_list_of_dicts() (telebot.types.MessageEntity tribute), 215
 static method), 87 update_types (in module telebot.util), 315
TransactionPartner (class in telebot.types), 107 upload_sticker_file() (tele-
TransactionPartnerAffiliateProgram (class in bot.async_telebot.AsyncTeleBot method),
 telebot.types), 107 305
TransactionPartnerFragment (class in telebot.types), upload_sticker_file() (telebot.TeleBot method), 210
 107 User (class in telebot.types), 111
TransactionPartnerOther (class in telebot.types), 108 user (telebot.async_telebot.AsyncTeleBot property), 305
TransactionPartnerTelegramAds (class in tele- user (telebot.TeleBot property), 210
 bot.types), 108 user_id (telebot.types.UsersShared property), 113
TransactionPartnerTelegramApi (class in tele- user_ids (telebot.types.UsersShared property), 113
 bot.types), 108 user_link() (in module telebot.util), 316
TransactionPartnerUser (class in telebot.types), 109 user_shared (telebot.types.Message property), 86
 UserChatBoosts (class in telebot.types), 112
340 Index
 pyTelegramBotAPI, Release 4.25.0
V
validate_token() (in module telebot.util), 316
validate_web_app_data() (in module telebot.util),
 316
Venue (class in telebot.types), 113
verify_chat() (telebot.async_telebot.AsyncTeleBot
 method), 305
verify_chat() (telebot.TeleBot method), 211
verify_user() (telebot.async_telebot.AsyncTeleBot
 method), 305
verify_user() (telebot.TeleBot method), 211
Video (class in telebot.types), 113
VideoChatEnded (class in telebot.types), 114
VideoChatParticipantsInvited (class in tele-
 bot.types), 114
VideoChatScheduled (class in telebot.types), 114
VideoChatStarted (class in telebot.types), 114
VideoNote (class in telebot.types), 115
Voice (class in telebot.types), 115
voice_chat_ended (telebot.types.Message property), 86
voice_chat_participants_invited (tele-
 bot.types.Message property), 86
voice_chat_scheduled (telebot.types.Message prop-
 erty), 86
voice_chat_started (telebot.types.Message property),
 86
VoiceChatEnded (class in telebot.types), 115
VoiceChatParticipantsInvited (class in tele-
 bot.types), 116
VoiceChatScheduled (class in telebot.types), 116
VoiceChatStarted (class in telebot.types), 116
W
WebAppData (class in telebot.types), 116
WebAppInfo (class in telebot.types), 116
webhook_google_functions() (in module tele-
 bot.util), 316
WebhookInfo (class in telebot.types), 116
WriteAccessAllowed (class in telebot.types), 117
Index 341