Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# InlineKeyboardMarkup

class telegram.InlineKeyboardMarkup(inline_keyboard, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

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

  Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their size of `inline_keyboard` and all the buttons are equal.

  An inline keyboard on a message

  Use In

  - `telegram.Bot.copy_message()`

  - `telegram.Bot.edit_message_caption()`

  - `telegram.Bot.edit_message_live_location()`

  - `telegram.Bot.edit_message_media()`

  - `telegram.Bot.edit_message_reply_markup()`

  - `telegram.Bot.edit_message_text()`

  - `telegram.Bot.send_animation()`

  - `telegram.Bot.send_audio()`

  - `telegram.Bot.send_contact()`

  - `telegram.Bot.send_dice()`

  - `telegram.Bot.send_document()`

  - `telegram.Bot.send_game()`

  - `telegram.Bot.send_invoice()`

  - `telegram.Bot.send_location()`

  - `telegram.Bot.send_message()`

  - `telegram.Bot.send_paid_media()`

  - `telegram.Bot.send_photo()`

  - `telegram.Bot.send_poll()`

  - `telegram.Bot.send_sticker()`

  - `telegram.Bot.send_venue()`

  - `telegram.Bot.send_video_note()`

  - `telegram.Bot.send_video()`

  - `telegram.Bot.send_voice()`

  - `telegram.Bot.stop_message_live_location()`

  - `telegram.Bot.stop_poll()`

  Available In

  - `telegram.InlineQueryResultArticle.reply_markup`

  - `telegram.InlineQueryResultAudio.reply_markup`

  - `telegram.InlineQueryResultCachedAudio.reply_markup`

  - `telegram.InlineQueryResultCachedDocument.reply_markup`

  - `telegram.InlineQueryResultCachedGif.reply_markup`

  - `telegram.InlineQueryResultCachedMpeg4Gif.reply_markup`

  - `telegram.InlineQueryResultCachedPhoto.reply_markup`

  - `telegram.InlineQueryResultCachedSticker.reply_markup`

  - `telegram.InlineQueryResultCachedVideo.reply_markup`

  - `telegram.InlineQueryResultCachedVoice.reply_markup`

  - `telegram.InlineQueryResultContact.reply_markup`

  - `telegram.InlineQueryResultDocument.reply_markup`

  - `telegram.InlineQueryResultGame.reply_markup`

  - `telegram.InlineQueryResultGif.reply_markup`

  - `telegram.InlineQueryResultLocation.reply_markup`

  - `telegram.InlineQueryResultMpeg4Gif.reply_markup`

  - `telegram.InlineQueryResultPhoto.reply_markup`

  - `telegram.InlineQueryResultVenue.reply_markup`

  - `telegram.InlineQueryResultVideo.reply_markup`

  - `telegram.InlineQueryResultVoice.reply_markup`

  - `telegram.Message.reply_markup`

  See also

  Another kind of keyboard would be the `telegram.ReplyKeyboardMarkup`.

  Examples

  - Inline Keyboard 1

  - Inline Keyboard 2

  Parameters:

    inline_keyboard (Sequence[Sequence[`telegram.InlineKeyboardButton`]]) –

    Sequence of button rows, each represented by a sequence of `InlineKeyboardButton` objects.

    Changed in version 20.0: Accepts any `collections.abc.Sequence` as input instead of just a list. The input is converted to a tuple.

  inline_keyboard

    Tuple of button rows, each represented by a tuple of `InlineKeyboardButton` objects.

    Changed in version 20.0: This attribute is now an immutable tuple.

    Type:

      tuple[tuple[`telegram.InlineKeyboardButton`]]

  classmethod de_json(data, bot=None)

    See `telegram.TelegramObject.de_json()`.

  classmethod from_button(button, **kwargs)

    Shortcut for:

        InlineKeyboardMarkup([[button]], **kwargs)

    Return an InlineKeyboardMarkup from a single InlineKeyboardButton

    Parameters:

      button (`telegram.InlineKeyboardButton`) – The button to use in the markup

  classmethod from_column(button_column, **kwargs)

    Shortcut for:

        InlineKeyboardMarkup([[button] for button in button_column], **kwargs)

    Return an InlineKeyboardMarkup from a single column of InlineKeyboardButtons

    Parameters:

      button_column (Sequence[`telegram.InlineKeyboardButton`]) –

      The button to use in the markup

      > Changed in version 20.0: Accepts any `collections.abc.Sequence` as input instead of just a list.

  classmethod from_row(button_row, **kwargs)

    Shortcut for:

        InlineKeyboardMarkup([button_row], **kwargs)

    Return an InlineKeyboardMarkup from a single row of InlineKeyboardButtons

    Parameters:

      button_row (Sequence[`telegram.InlineKeyboardButton`]) –

      The button to use in the markup

      Changed in version 20.0: Accepts any `collections.abc.Sequence` as input instead of just a list.