Available Methods

This page is about wzgram methods. All the methods listed here are bound to a Client instance, except for idle() and compose(), which are special functions that can be found in the main package directly.

from pyrogram import Client

app = Client("my_account")

with app:
    app.send_message("me", "hi")

Listeners

ask

Send a message and wait for the answer to it.

listen

Wait for the next update matching the given criteria.

register_next_step_handler

Run a callback once, on the next update matching the given criteria.

stop_listening

Stop the listeners covered by the given criteria.

wait_for_callback_query

Wait for the next callback query in a chat.

wait_for_message

Wait for the next message in a chat.

Utilities

add_handler

Register an update handler.

export_session_string

Export the current authorized session as a serialized string.

remove_handler

Remove a previously-registered update handler.

restart

Restart the Client.

run

Start the client, idle the main script and finally stop the client.

set_parse_mode

Set the parse mode to be used globally by the client.

start

Start the client.

stop

Stop the Client.

stop_transmission

Stop downloading or uploading a file.

idle

Block the main script execution until a signal is received.

compose

Run multiple clients at once.

Account

add_profile_audio

Adds an audio file to the beginning of the profile audio files of the current user.

get_account_ttl

Get days to live of account.

get_global_privacy_settings

Get account global privacy settings.

get_privacy

Get account privacy rules.

remove_profile_audio

Removes an audio file from the profile audio files of the current user.

set_account_ttl

Set days to live of account.

set_global_privacy_settings

Set account global privacy settings.

set_inactive_session_ttl

Changes the period of inactivity after which sessions will automatically be terminated.

set_privacy

Set account privacy rules.

set_profile_audio_position

Changes position of an audio file in the profile audio files of the current user.

Messages

add_checklist_tasks

Add tasks to a checklist in a message.

add_poll_option

Adds an option to a poll.

add_to_gifs

Add a GIF to the list of saved GIFs.

approve_suggested_post

Use this method to approve a suggested post in a direct messages chat.

compose_text_with_ai

Changes text using an AI model.

copy_media_group

Copy a media group by providing one of the message ids.

copy_message

Copy messages of any kind.

decline_suggested_post

Use this method to decline a suggested post in a direct messages chat.

delete_chat_history

Delete the history of a chat.

delete_direct_messages_chat_topic_history

Delete messages in the topic in a channel direct messages chat administered by the current user.

delete_ephemeral_message

Delete an ephemeral message.

delete_messages

Delete messages, including service messages.

delete_participant_reaction

Remove all reactions of a specific participant from a single message.

delete_participant_reactions

Remove all reactions of a specific participant from every message in a group or channel.

delete_poll_option

Deletes an option from a poll.

delete_scheduled_messages

Delete scheduled messages.

download_media

Download the media from a message.

edit_fact_check

Edit the fact-check on a message (channel admins only).

edit_inline_caption

Edit the caption of inline media messages.

edit_inline_media

Edit inline animation, audio, document, photo or video messages.

edit_inline_reply_markup

Edit only the reply markup of inline messages sent via the bot (for inline bots).

edit_inline_text

Edit the text of inline messages.

edit_message_caption

Edit the caption of media messages.

edit_message_checklist

Use this method to edit a checklist.

edit_message_media

Edit animation, audio, document, photo or video messages.

edit_message_reply_markup

Edit only the reply markup of messages sent by the bot.

edit_message_text

Edit the text of a message.

fix_text_with_ai

Fixes text using an AI model.

forward_media_group

Forward a media group by providing one of the message ids.

forward_messages

Forward messages of any kind.

get_available_effects

Get all available effects.

get_chat_history

Get messages from a chat history.

get_chat_history_count

Get the total count of messages in a chat.

get_custom_emoji_stickers

Get information about custom emoji stickers by their identifiers.

get_direct_messages_chat_topic_history

Return messages in the topic in a channel direct messages chat administered by the current user.

get_discussion_message

Get the first discussion message of a channel post or a discussion thread in a group.

get_discussion_replies

Get the message replies of a discussion thread.

get_discussion_replies_count

Get the total count of replies in a discussion thread.

get_main_web_app

Returns information needed to open the main Web App of a bot.

get_media_group

Get the media group a message belongs to.

get_messages

Get one or more messages from a chat by using message identifiers.

get_poll_results

Get the current results of a poll.

get_poll_stats

Get statistics for a poll sent in a message.

get_scheduled_messages

Get one or more scheduled messages from a chat.

get_stickers

Get all stickers from set by short name.

get_user_personal_chat_messages

Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user.

get_web_app_link_url

Returns an HTTPS URL of a Web App to open.

get_web_app_url

Returns an HTTPS URL of a Web App to open from the side menu, a KeyboardButton button with web app type, or an InlineKeyboardButton button with web app type.

mark_checklist_tasks_as_done

Add tasks of a checklist in a message as done or not done.

open_web_app

Informs pyrogram that a Web App is being opened from the attachment menu, a MenuButton, an url, or an InlineKeyboardButton button.

read_chat_history

Mark a chat's message history as read.

read_mentions

Mark a mention in the chat as read.

read_reactions

Mark a reaction in the chat as read.

retract_vote

Retract your vote in a poll.

search_global

Search messages globally from all of your chats.

search_global_count

Get the count of messages resulting from a global search.

search_messages

Search for text and media messages inside a specific chat.

search_messages_count

Get the count of messages resulting from a search inside a chat.

send_animation

Send animation files (animation or H.264/MPEG-4 AVC video without sound).

send_audio

Send audio files.

send_cached_media

Send any media stored on the Telegram servers using a file_id.

send_chat_action

Tell the other party that something is happening on your side.

send_checklist

Send a checklist (todo list).

send_contact

Send phone contacts.

send_dice

Send a dice with a random value from 1 to 6.

send_document

Send generic files.

send_ephemeral_message

Send an ephemeral message visible only to a specific user and the bot in a group.

send_location

send_media_group

Send a group of photos or videos as an album.

send_message

Send text messages.

send_paid_media

Send a group or one paid photo/video.

send_photo

Send photos.

send_poll

Send a new poll.

send_reaction

Send a reaction to a message.

send_rich_message

Send a rich formatted message.

send_rich_message_draft

Send a rich message draft action, allowing bots to stream partial rich messages.

send_scheduled_messages

Send scheduled messages immediately.

send_screenshot_notification

Notify the other user that you took a screenshot.

send_sticker

Send static .webp or animated .tgs stickers.

send_venue

send_video

Send video files.

send_video_note

Send video messages.

send_voice

Send audio files.

stop_poll

Stop a poll which was sent by you.

stream_media

Stream the media from a message chunk by chunk.

summarize_text

Summarize text content using AI.

translate_text

Translate text or a message to another language.

view_messages

Increment the view counter of one or more messages.

vote_poll

Vote a poll.

Chats

add_chat_members

Add new chat members to a group, supergroup or channel

archive_chats

Archive one or more chats.

ban_chat_member

Ban a user from a group, a supergroup or a channel.

close_forum_topic

Close a forum topic.

create_channel

Create a new broadcast channel.

create_forum_topic

Create a new forum topic.

create_group

Create a new basic group.

create_supergroup

Create a new supergroup.

delete_all_message_reactions

Use this method to remove up to 10000 recent reactions in a group or a supergroup chat added by a given user or chat.

delete_channel

Delete a channel.

delete_chat_photo

Delete a chat photo.

delete_forum_topic

Delete a forum topic.

delete_message_reaction

Use this method to remove a reaction from a message in a group or a supergroup chat.

delete_supergroup

Delete a supergroup.

delete_user_history

Delete all messages sent by a certain user in a supergroup.

edit_forum_topic

Edit a forum topic.

get_chat

Get up to date information about a chat.

get_chat_event_log

Get the actions taken by chat members and administrators in the last 48h.

get_chat_member

Get information about one member of a chat.

get_chat_members

Get the members list of a chat.

get_chat_members_count

Get the number of members in a chat.

get_chat_online_count

Get the number of members that are currently online in a chat.

get_chat_settings

Get information about a chat settings.

get_dialogs

Get a user's dialogs sequentially.

get_dialogs_count

Get the total count of your dialogs.

get_direct_messages_topics

Get one or more topic from a direct messages channel chat.

get_direct_messages_topics_by_id

Get one or more direct message topic from a chat by using topic identifiers.

get_forum_topics

Get one or more topic from a chat.

get_forum_topics_by_id

Get one or more topic from a chat by using topic identifiers.

get_nearby_chats

Get nearby chats.

get_personal_channels

Get all your public channels.

get_send_as_chats

Get the list of "send_as" chats available.

get_similar_channels

Get similar channels.

get_suitable_discussion_chats

Return a list of basic group and supergroup chats, which can be used as a discussion group for a channel.

get_top_chats

Returns a list of frequently used chats.

join_chat

Join a group chat or channel.

leave_chat

Leave a group chat or channel.

mark_chat_unread

Mark a chat as unread.

pin_chat_message

Pin a message in a group, channel or your own chat.

promote_chat_member

Promote or demote a user in a supergroup or a channel.

restrict_chat_member

Restrict a user in a supergroup.

restrict_sponsored_messages

Restrict sponsored messages in a channel.

set_administrator_title

Set a custom title (rank) to an administrator of a supergroup.

set_chat_description

Change the description of a supergroup or a channel.

set_chat_permissions

Set default chat permissions for all members.

set_chat_photo

Set a new chat photo or video (H.264/MPEG-4 AVC video, max 5 seconds).

set_chat_protected_content

Set the chat protected content setting.

set_chat_title

Change the title of a chat.

set_chat_ttl

Set the auto-delete timer of a chat.

set_chat_username

Set a channel or a supergroup username.

set_send_as_chat

Set the default "send_as" chat for a chat.

set_slow_mode

Set the slow mode interval for a chat.

toggle_anti_spam

Toggle the anti-spam filter in a supergroup.

toggle_auto_translation

Toggle automatic message translation for a channel.

toggle_forum

Toggle forum mode in a supergroup.

toggle_join_to_send

Toggle whether users must join before sending messages.

toggle_participants_hidden

Toggle whether participant list is hidden.

toggle_pre_history_hidden

Toggle pre-history visibility for new members.

toggle_signatures

Toggle channel signatures.

toggle_slow_mode

Toggle slow mode in a supergroup.

toggle_view_forum_as_messages

Toggle whether forum topics are displayed as messages.

unarchive_chats

Unarchive one or more chats.

unban_chat_member

Unban a previously banned user in a supergroup or channel.

unpin_all_chat_messages

Use this method to clear the list of pinned messages in a chat.

unpin_chat_message

Unpin a message in a group, channel or your own chat.

update_channel_color

Update the accent color of a channel.

update_chat_notifications

Update the notification settings of a chat.

Users

block_user

Block a user.

check_username

Check if a username is available.

delete_profile_photos

Delete your own profile photos.

get_chat_audios

Get a user profile audios sequentially.

get_chat_audios_count

Get the total count of audios for a chat.

get_chat_photos

Get a chat or a user profile photos sequentially.

get_chat_photos_count

Get the total count of photos for a chat.

get_common_chats

Get the common chats you have with a user.

get_default_emoji_statuses

Get the default emoji statuses.

get_me

Get your own user identity.

get_users

Get information about a user.

set_emoji_status

Set the emoji status.

set_personal_channel

Set a personal channel in bio.

set_profile_photo

Set a new profile photo or video (H.264/MPEG-4 AVC video, max 5 seconds).

set_username

Set your own username.

unblock_user

Unblock a user.

update_birthday

Update birthday in your profile.

update_profile

Update your profile details such as first name, last name and bio.

update_status

Update your profile status.

Contacts

add_contact

Add an existing Telegram user as contact, even without a phone number.

delete_contacts

Delete contacts from your Telegram address book.

get_blocked_message_senders

Returns users and chats that were blocked by the current user.

get_contacts

Get contacts from your Telegram address book.

get_contacts_count

Get the total count of contacts from your Telegram address book.

import_contacts

Import contacts to your Telegram address book.

search_contacts

Returns users or channels found by name substring and auxiliary data.

set_contact_note

Changes a note of a contact user.

Folders

check_chat_folder_invite_link

Checks the validity of an invite link for a chat folder and returns information about the corresponding chat folder.

create_folder

Create new chat folder.

create_folder_invite_link

Create a new invite link for a chat folder.

delete_folder

Delete a user's folder.

delete_folder_invite_link

Deletes an invite link for a chat folder.

edit_folder

Update chat folder.

edit_folder_invite_link

Edits an invite link for a chat folder.

get_chats_for_folder_invite_link

Returns chats from a chat folder, suitable for adding to a chat folder invite link.

get_folder_invite_links

Returns invite links created by the current user for a shareable chat folder.

get_folders

Return information about a chat folders.

join_folder

Join a folder by its invite link.

leave_folder

Leave a folder by its invite link.

Password

change_cloud_password

Change your Two-Step Verification password (Cloud Password) with a new one.

enable_cloud_password

Enable the Two-Step Verification security feature (Cloud Password) on your account.

remove_cloud_password

Turn off the Two-Step Verification security feature (Cloud Password) on your account.

Bots

allow_bot_send_message

Allow a bot to send messages to the user.

answer_callback_query

Send answers to callback queries sent from inline keyboards.

answer_chat_join_request_query

Use this method to process a received chat join request query.

answer_guest_query

Use this method to reply to a received guest message.

answer_inline_query

Send answers to an inline query.

answer_pre_checkout_query

Send answers to pre-checkout queries.

answer_shipping_query

If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the API sends the confirmation in the form of an ShippingQueryHandler.

answer_web_app_query

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.

can_bot_send_message

Check if a bot can send messages to the user.

check_bot_username

Checks whether a username can be set for a new bot.

create_bot

Creates a bot which will be managed by another bot.

create_invoice_link

Create invoice link.

delete_bot_commands

Delete the list of the bot's commands for the given scope and user language.

edit_user_star_subscription

Cancels or re-enables Telegram Star subscription for a user.

get_admined_bots

Get a list of bots you administrate.

get_bot_commands

Get the current list of the bot's commands for the given scope and user language.

get_bot_default_privileges

Get the current default privileges of the bot.

get_bot_info

Get bot info (name, about, description).

get_bot_info_description

Use this method to get the current / owned bot description for the given user language.

get_bot_info_short_description

Use this method to get the current / owned bot short description for the given user language.

get_bot_name

Use this method to get the current / owned bot name for the given user language.

get_chat_menu_button

Get the current value of the bot's menu button in a private chat, or the default menu button.

get_game_high_scores

Get data for high score tables.

get_inline_bot_results

Get bot results via inline queries.

get_managed_bot_access_settings

Use this method to get the access settings of a managed bot.

get_managed_bot_token

Use this method to get the token of a managed bot.

get_owned_bots

Returns the list of bots owned by the current user.

refund_star_payment

Refunds a successful payment in Telegram Stars.

replace_managed_bot_token

Use this method to revoke the current token of a managed bot and generate a new one.

request_callback_answer

Request a callback answer from bots.

send_chat_join_request_web_app

Use this method to process a received chat join request query by showing a Mini App to the user before deciding the outcome.

send_game

Send a game.

send_inline_bot_result

Send an inline bot result.

send_invoice

Use this method to send invoices.

set_bot_commands

Set the list of the bot's commands.

set_bot_default_privileges

Change the default privileges requested by the bot when it's added as an administrator to groups or channels.

set_bot_info_description

Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.

set_bot_info_short_description

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.

set_bot_name

Use this method to get the current / owned bot name for the given user language.

set_chat_menu_button

Change the bot's menu button in a private chat, or the default menu button.

set_game_score

Set the score of the specified user in a game.

set_managed_bot_access_settings

Use this method to get the access settings of a managed bot.

Business

create_business_chat_link

Create a business chat link with a predefined message.

delete_business_chat_link

Delete a business chat link by slug.

delete_business_messages

Delete messages on behalf of a business account.

get_business_account_gifts

Return the gifts received and owned by a managed business account.

get_business_account_star_balance

Return the amount of Telegram Stars owned by a managed business account.

get_business_chat_links

Get all business chat links.

get_business_connection

Use this method to get information about the connection of the bot with a business account.

get_connected_bots

Get bots connected to your business account.

resolve_business_chat_link

Resolve a business chat link slug to its info.

transfer_business_account_stars

Transfers Telegram Stars from the business account balance to the bot’s balance.

update_business_away_message

Set an automatic away message when you are offline.

update_business_greeting_message

Set an automatic greeting message for new conversations.

update_business_intro

Update your business intro (title, description, sticker).

update_business_location

Update the business location shown on your business page.

update_business_work_hours

Update business work hours for your business account.

Payments

add_collection_gifts

Adds gifts to the beginning of a previously created collection.

apply_gift_code

Apply a gift code.

buy_gift_upgrade

Pays for upgrade of a regular gift that is owned by another user or channel chat.

check_gift_code

Get information about a gift code.

convert_gift_to_stars

Convert a given regular gift to Telegram Stars.

craft_gift

Crafts a new gift from other gifts that will be permanently lost.

create_gift_collection

Creates a collection from gifts on the current user's or a channel's profile page.

delete_gift_collection

Deletes a gift collection.

drop_gift_original_details

Drops original details for an upgraded gift.

edit_star_subscription

Cancels or re-enables Telegram Star subscription.

get_available_gifts

Get all available star gifts that can be sent to other users.

get_chat_gifts

Get all gifts owned by specified chat.

get_chat_gifts_count

Get the total count of owned gifts of specified chat.

get_gift_auction_state

Returns auction state for a gift.

get_gift_collections

Returns collections of gifts owned by the given user or chat.

get_gift_upgrade_preview

Return examples of possible upgraded gifts for a regular gift.

get_gift_upgrade_variants

Returns all possible variants of upgraded gifts for a regular gift.

get_gifts_for_crafting

Returns upgraded gifts of the current user that can be used to craft another gifts.

get_payment_form

Get an invoice payment form.

get_stars_balance

Get the current Telegram Stars balance of the current account.

get_ton_balance

Get the current TON balance of the current account.

get_upgraded_gift

Get information about upgraded gift.

get_upgraded_gift_value_info

Returns information about value of an upgraded gift by its name.

gift_premium_with_stars

Allows to buy a Telegram Premium subscription for another user with payment in Telegram Stars.

hide_gift

Hide gift on the current user's or the channel's profile page.

increase_gift_auction_bid

Increases a bid for an auction gift without changing gift text and receiver.

place_gift_auction_bid

Places a bid on an auction gift.

process_gift_purchase_offer

Handles a pending gift purchase offer.

remove_collection_gifts

Removes gifts from a collection.

reorder_collection_gifts

Changes order of gifts in a collection.

reorder_gift_collections

Changes order of gift collections.

reuse_star_subscription

Reuses an active Telegram Star subscription to a channel chat and joins the chat again.

search_gifts_for_resale

Get upgraded gifts that can be bought from other owners.

send_gift

Send a gift to another user or channel chat.

send_gift_purchase_offer

Sends an offer to purchase an upgraded gift.

send_payment_form

Send a filled-out payment form to the bot for final verification.

send_resold_gift

Send an upgraded gift that is available for resale to another user or channel chat.

set_gift_collection_name

Changes name of a gift collection.

set_gift_resale_price

Change resale price of a unique gift owned by the current user.

set_pinned_gifts

Change the list of pinned gifts on the current user.

show_gift

Display gift on the current user's or the channel's profile page.

suggest_birthday

Suggests a birthdate to another regular user with common messages and allowing non-paid messages.

transfer_gift

Transfers an owned unique gift to another user.

upgrade_gift

Upgrade a given regular gift to a unique gift.

Stories

can_post_stories

Check whether we can post stories as the specified chat.

copy_story

Copy story.

delete_stories

Delete posted stories.

edit_story_caption

Edit the caption of story.

edit_story_media

Edit story media.

edit_story_privacy

Edit the privacy of story.

enable_stealth_mode

Activates stories stealth mode.

forward_story

Forward story.

get_all_stories

Get all active or hidden stories that displayed on the action bar on the homescreen.

get_archived_stories

Get all archived stories from a chat by using chat identifier.

get_chat_stories

Get all non expired stories from a chat by using chat identifier.

get_pinned_stories

Get all pinned stories from a chat by using chat identifier.

get_stories

Get one or more stories from a chat by using stories identifiers.

get_story_views

Obtain the list of users that have viewed a specific story we posted.

hide_chat_stories

Hide the active stories of a user, preventing them from being displayed on the action bar on the homescreen.

pin_chat_stories

Pin one or more stories in a chat by using stories identifiers.

read_chat_stories

Mark all stories up to a certain identifier as read, for a given chat.

send_story

Post new story.

show_chat_stories

Show the active stories of a user and display them in the action bar on the homescreen.

unpin_chat_stories

Unpin one or more stories in a chat by using stories identifiers.

view_stories

Increment story views.

Phone

get_call_members

Get the members list of a chat call.

Premium

apply_boost

Apply boost

get_boosts

Get your boosts list

get_boosts_status

Get boosts status of channel

Decorators

on_business_connection

Decorator for handling changes in business connection.

on_business_message

Decorator for handling new messages from business connection.

on_callback_query

Decorator for handling callback queries.

on_chat_boost

Decorator for handling applied chat boosts.

on_chat_join_request

Decorator for handling chat join requests.

on_chat_member_updated

Decorator for handling event changes on chat members.

on_chosen_inline_result

Decorator for handling chosen inline results.

on_connect

Decorator for handling connections.

on_deleted_business_messages

Decorator for handling deleted messages from business connection.

on_deleted_messages

Decorator for handling deleted messages.

on_disconnect

Decorator for handling disconnections.

on_edited_business_message

Decorator for handling edited messages from business connection.

on_edited_message

Decorator for handling edited messages.

on_error

Decorator for handling unexpected errors.

on_guest_message

Decorator for handling new guest messages.

on_inline_query

Decorator for handling inline queries.

on_managed_bot

Decorator for handling new managed bot creation updates.

on_message

Decorator for handling new messages.

on_message_reaction

Decorator for handling reaction changes on messages.

on_message_reaction_count

Decorator for handling anonymous reaction changes on messages.

on_poll

Decorator for handling poll updates.

on_pre_checkout_query

Decorator for handling pre-checkout queries.

on_purchased_paid_media

Decorator for handling purchased paid media.

on_raw_update

Decorator for handling raw updates.

on_shipping_query

Decorator for handling shipping queries.

on_start

Decorator for handling client start.

on_stop

Decorator for handling client stop.

on_story

Decorator for handling new stories.

on_user_status

Decorator for handling user status updates.

Authorization

accept_terms_of_service

Accept the given terms of service.

change_phone_number

Change a user phone number in Telegram with a valid confirmation code.

check_password

Check your Two-Step Verification password and log in.

connect

Connect the client to Telegram servers.

disconnect

Disconnect the client from Telegram servers.

get_active_sessions

Returns all active sessions of the current user.

get_password_hint

Get your Two-Step Verification password hint.

initialize

Initialize the client by starting up workers.

log_out

Log out from Telegram and delete the *.session file.

recover_password

Recover your password with a recovery code and log in.

resend_code

Re-send the confirmation code using a different type.

resend_phone_number_code

Re-send the confirmation code using a different type.

reset_session

Log out an active authorized session by its hash.

reset_sessions

Terminates all user's authorized sessions except for the current one.

send_code

Send the confirmation code to the given phone number.

send_phone_number_code

Sends a code to the specified phone number.

send_recovery_code

Send a code to your email to recover your password.

sign_in

Authorize a user in Telegram with a valid confirmation code.

sign_in_bot

Authorize a bot using its bot token generated by BotFather.

sign_up

Register a new user in Telegram.

terminate

Terminate the client by shutting down workers.

Advanced

Methods used only when dealing with the raw Telegram API. Learn more about how to use the raw API at Advanced Usage.

get_session

Get existing session or create a new one.

invoke

recover_gaps

Restores updates for the time while the client was offline.

resolve_peer

Get the InputPeer of a known peer id.

save_file

Upload a file onto Telegram servers, without sending the message to anyone.

set_dc

Set configuration for the specified datacenter.