Available Methods

This page is about Electrogram 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")

Account

get_account_ttl

Get days to live of account.

get_privacy

Get account privacy rules.

set_account_ttl

Set days to live of account.

set_privacy

Set account privacy rules.

Advanced

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

invoke

Invoke raw Telegram functions.

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.

Authorization

accept_terms_of_service

Accept the given terms of service.

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.

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

Bots

answer_callback_query

Send answers to callback queries sent from inline keyboards.

answer_inline_query

Send answers to an inline query.

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.

delete_bot_commands

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

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 the bot info in given 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_collectible_item_info

Returns information about a given collectible item that was purchased at https://fragment.com

get_game_high_scores

Get data for high score tables.

get_inline_bot_results

Get bot results via inline queries.

request_callback_answer

Request a callback answer from bots.

send_game

Send a game.

send_inline_bot_result

Send an inline bot result.

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

Get the bot info in given 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.

Telegram Business

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.

create_invoice_link

Use this method to create a link for an invoice.

get_available_gifts

Get all gifts that can be sent to other users.

get_business_connection

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

get_payment_form

Get information about a invoice or paid media.

get_stars_transactions

Get stars transactions.

get_stars_transactions_by_id

Get stars transactions by transaction id.

get_user_gifts

Get gifts saved to profile by the given user.

refund_stars_payment

Refund the stars to the user.

sell_gift

Sells a gift received by the current user for Telegram Stars.

send_gift

Sends a gift to another user.

send_invoice

Use this method to send invoices.

send_payment_form

Pay an invoice.

toggle_gift_is_saved

Toggles whether a gift is shown on the current user's profile page.

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.

close_general_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_channel

Delete a channel.

delete_chat_photo

Delete a chat photo.

delete_folder

Delete a user's folder.

delete_forum_topic

Delete a forum topic.

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.

edit_general_topic

Edit a general forum topic.

export_folder_link

Export link to a user's folder.

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_dialogs

Get a user's dialogs sequentially.

get_dialogs_count

Get the total count of your dialogs.

get_folders

Get one or more folders by using folder 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_send_as_chats

Get the list of "send_as" chats available.

hide_general_topic

hide a general forum topic.

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.

reopen_forum_topic

Reopen a forum topic.

reopen_general_topic

Reopen a general forum topic.

restrict_chat_member

Restrict a user in a supergroup.

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

unarchive_chats

Unarchive one or more chats.

unban_chat_member

Unban a previously banned user in a supergroup or channel.

unhide_general_topic

unhide a general forum topic.

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_color

Update color

update_folder

Create or update a user's folder.

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

approve_all_chat_join_requests

Approve all pending join requests in a chat.

approve_chat_join_request

Approve a chat join request.

create_chat_invite_link

Create an additional invite link for a chat.

decline_all_chat_join_requests

Decline all pending join requests in a chat.

decline_chat_join_request

Decline a chat join request.

delete_chat_admin_invite_links

Delete all revoked invite links of an administrator.

delete_chat_invite_link

Delete an already revoked invite link.

edit_chat_invite_link

Edit a non-primary invite link.

export_chat_invite_link

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

get_chat_admin_invite_links

Get the invite links created by an administrator in a chat.

get_chat_admin_invite_links_count

Get the count of the invite links created by an administrator in a chat.

get_chat_admins_with_invite_links

Get the list of the administrators that have exported invite links in a chat.

get_chat_invite_link

Get detailed information about a chat invite link.

get_chat_invite_link_joiners

Get the members who joined the chat with the invite link.

get_chat_invite_link_joiners_count

Get the count of the members who joined the chat with the invite link.

get_chat_join_requests

Get the pending join requests of a chat.

revoke_chat_invite_link

Revoke a previously created invite link.

Messages

copy_media_group

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

copy_message

Copy messages of any kind.

delete_chat_history

Delete the history of a chat.

delete_messages

Delete messages, including service messages.

delete_scheduled_messages

Delete scheduled messages.

download_media

Download the media from a message.

edit_inline_caption

Edit the caption of inline media messages.

edit_inline_media

Edit animation, audio, document, photo or video messages, or replace text with 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_media

Edit animation, audio, document, photo or video messages, or replace text with 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 messages.

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_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_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_scheduled_messages

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

read_chat_history

Mark a chat's message history 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_global_hashtag_messages

Searches for public channel posts with the given hashtag.

search_global_hashtag_messages_count

Get the count of messages with the provided hashtag.

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_contact

Send phone contacts.

send_dice

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

send_document

Send generic files.

send_location

Send points on the map.

send_media_group

Send a group of photos or videos as an album.

send_message

Send text messages.

send_paid_media

Use this method to send paid media.

send_paid_reaction

Adds the paid message reaction to a message.

send_photo

Send photos.

send_poll

Send a new poll.

send_reaction

Use this method to send reactions on a message/stories.

send_sticker

Send static .webp or animated .tgs stickers.

send_venue

Send information about a venue.

send_video

Send video files.

send_video_note

Send video messages.

send_voice

Send audio files.

send_web_page

Send text Web Page Preview.

stop_poll

Stop a poll which was sent by you.

stream_media

Stream the media from a message chunk by chunk.

translate_text

Translates a text to the given language.

vote_poll

Vote a poll.

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.

Stickers

add_sticker_to_set

Add a sticker to stickerset.

create_sticker_set

Create a new stickerset.

get_sticker_set

Get info about a stickerset.

Stories

delete_stories

Delete one or more story by using story identifiers.

edit_story

Edit story.

export_story_link

Get one story link from an user by using story identifiers.

forward_story

Forward a story.

get_all_stories

Get all active stories.

get_peer_stories

Get all active stories from an user/channel by using user identifiers.

get_stories

Get one or more story from an user by using story identifiers.

get_stories_history

Get stories history.

send_story

Send new story.

Users

block_user

Block a user.

delete_account

Deletes the account of the current user, deleting all information associated with the user from the server.

delete_profile_photos

Delete your own profile photos.

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_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 your birthday details.

update_personal_chat

Update your birthday details.

update_profile

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

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.

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.