Inline objects


class InlineQuery(*, id_unique, from_user, location=None, query, offset)

This class represents an incoming inline query

  • id_unique (str) – Unique identifier for this query

  • from_user (User) – Sender from which query came from

  • location (Location) – Optional: Sender location, only for bots that request user location

  • query (str) – Text of the query (up to 512 characters)

  • offset (str) – Offset of the results to be returned, can be controlled by the bot


class ChosenInlineResult(*, query, result_id=None, from_user=None, location=None, inline_message_id=None)

This class represents a result of an inline query that was chosen by the user and sent to their chat partner It is necessary to enable inline feedback via the Botfather to receive this objects in updates

  • query (str) – The query that was used to obtain the result

  • result_id (str) – The unique identifier for the result that was chosen

  • from_user (User) – The user that chose the result

  • location (Location) – Optional: Sender locations, only for bots that require user location

  • inline_message_id (str) – Optional: Identifier of the sent inline message


class InlineKeyboardButton(*, text, url=None, login_url=None, callback_data=None, switch_inline_query=None, switch_inline_query_current_chat=None, callback_game=None, pay=None)

This class represents one button of an inline keyboard. You must use exactly one of the optional fields

  • text – Label text on the button

  • url (str) – Optional: HTTP or tg:// url to be opened when button is pressed

  • login_url (LoginUrl) – Optional: An HTTP URL user to automatically authorize the user

  • callback_data (str) – Optional: Data to be sent in a CallbackQuery to the bot when button is pressed, 1-64 bytes

  • 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. Can be empty, in which case just the bot’s username will be inserted.

  • 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. Can be empty, in which case only the bot’s username will be inserted.

  • callback_game (CallbackGame) – Optional: Description if the game that will be launched when the user presses the button. Note: This button must be always be the first button in the first row

  • pay (bool) – Optional: Specify True, to send a Pay Button


class InlineKeyboardMarkup(*, inline_keyboard)

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


inline_keyboard (list of list of InlineKeyboardButton) – List of button rows, each represented by a list of InlineKeyboardButton objects


class LoginUrl(*, url, forward_text=None, bot_username=None, request_write_access=None)

This class represents a parameter of the inline keyboard button used to automatically authorize a user

  • url (str) – An HTTP 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 original URL without information about the user will be opened

  • forward_text (str) – Optional: New text of the button in forwarded messages

  • bot_username (str) – Optional: Username of a bot, which will be user for user authorization. If not specified, the bot’s username will be assumed. The url’s domain must be the same as the domain linked with the bot

  • request_write_access (bool) – Optional: Pass True to request the permission for your bot to send messages to the user