Available Methods

This page is about Pyrogram methods. All the methods listed here are bound to a Client instance.

from pyrogram import Client

app = Client("my_account")

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

Utilities

start

Start the client.

idle

Block the main script execution until a signal is received.

stop

Stop the Client.

run

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

restart

Restart the Client.

add_handler

Register an update handler.

remove_handler

Remove a previously-registered update handler.

stop_transmission

Stop downloading or uploading a file.

export_session_string

Export the current authorized session as a serialized string.

set_parse_mode

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

Messages

send_message

Send text messages.

forward_messages

Forward messages of any kind.

send_photo

Send photos.

send_audio

Send audio files.

send_document

Send generic files.

send_sticker

Send static .webp or animated .tgs stickers.

send_video

Send video files.

send_animation

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

send_voice

Send audio files.

send_video_note

Send video messages.

send_media_group

Send a group of photos or videos as an album.

send_location

Send points on the map.

send_venue

Send information about a venue.

send_contact

Send phone contacts.

send_cached_media

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

edit_message_text

Edit the text of messages.

edit_message_caption

Edit the caption of media messages.

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_inline_text

Edit the text of inline messages.

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).

send_chat_action

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

delete_messages

Delete messages, including service messages.

get_messages

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

get_history

Retrieve a chunk of the history of a chat.

get_history_count

Get the total count of messages in a chat.

read_history

Mark a chat’s message history as read.

iter_history

Iterate through a chat history sequentially.

send_poll

Send a new poll.

vote_poll

Vote a poll.

stop_poll

Stop a poll which was sent by you.

retract_vote

Retract your vote in a poll.

download_media

Download the media from a message.

Chats

join_chat

Join a group chat or channel.

leave_chat

Leave a group chat or channel.

kick_chat_member

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

unban_chat_member

Unban a previously kicked user in a supergroup or channel.

restrict_chat_member

Restrict a user in a supergroup.

promote_chat_member

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

set_administrator_title

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

export_chat_invite_link

Generate a new invite link for a chat; any previously generated link is revoked.

set_chat_photo

Set a new profile photo for the chat.

delete_chat_photo

Delete a chat photo.

set_chat_title

Change the title of a chat.

set_chat_description

Change the description of a supergroup or a channel.

set_chat_permissions

Set default chat permissions for all members.

pin_chat_message

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

unpin_chat_message

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

get_chat

Get up to date information about a chat.

get_chat_member

Get information about one member of a chat.

get_chat_members

Get a chunk of the members list of a chat.

get_chat_members_count

Get the number of members in a chat.

iter_chat_members

Iterate through the members of a chat sequentially.

get_dialogs

Get a chunk of the user’s dialogs.

iter_dialogs

Iterate through a user’s dialogs sequentially.

get_dialogs_count

Get the total count of your dialogs.

update_chat_username

Update a channel or a supergroup username.

get_common_chats

Get the common chats you have with a user.

get_nearby_chats

Get nearby chats.

archive_chats

Archive one or more chats.

unarchive_chats

Unarchive one or more chats.

add_chat_members

Add new chat members to a group, supergroup or channel

create_channel

Create a new broadcast channel.

create_group

Create a new basic group.

create_supergroup

Create a new supergroup.

delete_channel

Delete a channel.

delete_supergroup

Delete a supergroup.

Users

get_me

Get your own user identity.

get_users

Get information about a user.

get_profile_photos

Get a list of profile pictures for a user or a chat.

get_profile_photos_count

Get the total count of profile pictures for a user.

iter_profile_photos

Iterate through a chat or a user profile photos sequentially.

set_profile_photo

Set a new profile photo.

delete_profile_photos

Delete your own profile photos.

update_username

Update your own username.

block_user

Block a user.

unblock_user

Unblock a user.

Contacts

add_contacts

Add contacts to your Telegram address book.

get_contacts

Get contacts from your Telegram address book.

get_contacts_count

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

delete_contacts

Delete contacts from your Telegram address book.

Password

enable_cloud_password

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

change_cloud_password

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

remove_cloud_password

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

Bots

get_inline_bot_results

Get bot results via inline queries.

send_inline_bot_result

Send an inline bot result.

answer_callback_query

Send answers to callback queries sent from inline keyboards.

answer_inline_query

Send answers to an inline query.

request_callback_answer

Request a callback answer from bots.

send_game

Send a game.

set_game_score

Set the score of the specified user in a game.

get_game_high_scores

Get data for high score tables.

Authorization

connect

Connect the client to Telegram servers.

disconnect

Disconnect the client from Telegram servers.

initialize

Initialize the client by starting up workers.

terminate

Terminate the client by shutting down workers.

send_code

Send the confirmation code to the given phone number.

resend_code

Re-send the confirmation code using a different type.

sign_in

Authorize a user in Telegram with a valid confirmation code.

sign_up

Register a new user in Telegram.

get_password_hint

Get your Two-Step Verification password hint.

check_password

Check your Two-Step Verification password and log in.

send_recovery_code

Send a code to your email to recover your password.

recover_password

Recover your password with a recovery code and log in.

accept_terms_of_service

Accept the given terms of service.

log_out

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

Advanced

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

send

Send raw Telegram queries.

resolve_peer

Get the InputPeer of a known peer id.

save_file

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