Available Methods#
This page is about Pyrogram 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(chat_id="me", text="hi")
Utilities#
Start the client, idle the main script and finally stop the client. |
|
Start the client. |
|
Stop the Client. |
|
Restart the Client. |
|
Export the current authorized session as a serialized string. |
|
Register an update handler. |
|
Remove a previously-registered update handler. |
|
Stop downloading or uploading a file. |
|
Set the parse mode to be used globally by the client. |
Block the main script execution until a signal is received. |
|
Run multiple clients at once. |
Messages#
Send text messages. |
|
Forward messages of any kind. |
|
Copy messages of any kind. |
|
Send photos. |
|
Send audio files. |
|
Send generic files. |
|
Send video files. |
|
Send animation files (animation or H.264/MPEG-4 AVC video without sound). |
|
Send audio files. |
|
Send video messages. |
|
Send any media stored on the Telegram servers using a file_id. |
|
Use this method to send paid media. |
|
Send a group of photos or videos as an album. |
|
Get the media group a message belongs to. |
|
Copy a media group by providing one of the message ids. |
|
Send points on the map. |
|
Send information about a venue. |
|
Send phone contacts. |
|
Send a new poll. |
|
Send a dice with a random value from 1 to 6. |
|
Use this method when you need to tell the user that something is happening on the bot's side. |
|
Adds the paid message reaction to a message. |
|
Use this method to change the chosen reactions on a message. |
|
Download the media from a message. |
|
Stream the media from a message chunk by chunk. |
|
Edit the text of messages. |
|
Edit the text of inline messages. |
|
Edit the caption of media messages. |
|
Edit the caption of inline media messages. |
|
Edit animation, audio, document, photo or video messages, or to add media to text messages. |
|
Edit inline animation, audio, document, photo or video messages, or to add media to text messages. |
|
Edit only the reply markup of messages sent by the bot. |
|
Edit only the reply markup of inline messages sent via the bot (for inline bots). |
|
Edit a media stored on the Telegram servers using a file_id. |
|
Stop a poll which was sent by you. |
|
Delete messages, including service messages, with the following limitations: |
|
Returns sponsored messages to be shown in a chat; for channel chats only. |
|
Get messages from a chat history. |
|
Get the total count of messages in a chat. |
|
Mark a chat's message history as read. |
|
Get one or more messages from a chat by using message identifiers. |
|
Informs the server that messages are being viewed by the current user. |
|
Get the first discussion message of a channel post or a discussion thread in a group. |
|
Get the message replies of a discussion thread. |
|
Get the total count of replies in a discussion thread. |
|
Search messages globally from all of your chats. |
|
Get the count of messages resulting from a global search. |
|
Search for text and media messages inside a specific chat. |
|
Get the count of messages resulting from a search inside a chat. |
|
Searches for public channel posts containing the given hashtag or cashtag. |
|
Get the count of messages with the provided hashtag or cashtag. |
|
Vote a poll. |
|
Retract your vote in a poll. |
|
Translates a text to the given language. |
|
Extracts text or caption of the given message and translates it to the given language. |
Chats#
Ban a user from a group, a supergroup or a channel. |
|
Unban a previously banned user in a supergroup or channel. |
|
Restrict a user in a supergroup. |
|
Promote or demote a user in a supergroup or a channel. |
|
Set a custom title (rank) to an administrator of a supergroup. |
|
Set default chat permissions for all members. |
|
Set a new chat photo or video (H.264/MPEG-4 AVC video, max 5 seconds). |
|
Delete a chat photo. |
|
Change the title of a chat. |
|
Change the description of a supergroup or a channel. |
|
Pin a message in a group, channel or your own chat. |
|
Unpin a message in a group, channel or your own chat. |
|
Use this method to clear the list of pinned messages in a chat. |
|
Searches for the specified query in the title and username of already known chats via request to the server. |
|
Join a group chat or channel. |
|
Leave a group chat or channel. |
|
Get up to date information about a chat. |
|
Get the members list of a chat. |
|
Get the number of members in a chat. |
|
Get information about one member of a chat. |
|
Get a user's dialogs sequentially. |
|
Get the total count of your dialogs. |
|
Set a channel or a supergroup username. |
|
Returns a list of users and location-based supergroups nearby. |
|
Archive one or more chats. |
|
Unarchive one or more chats. |
|
Add new chat members to a group, supergroup or channel |
|
Create a new broadcast channel. |
|
Create a new basic group. |
|
Create a new supergroup. |
|
Delete a channel. |
|
Delete a supergroup. |
|
Delete all messages sent by a certain user in a supergroup. |
|
Set the slow mode interval for a chat. |
|
Changes the message auto-delete or self-destruct (for secret chats) time in a chat. |
|
Mark a chat as unread. |
|
Get the actions taken by chat members and administrators in the last 48h. |
|
Get the number of members that are currently online in a chat. |
|
Get the list of "send_as" chats available. |
|
Set the default "send_as" chat for a chat. |
|
Set the chat protected content setting. |
|
Get a list of chats of the specified type of the current user account |
|
Changes the owner of a chat. |
Invite Links#
Generate a new primary invite link for a chat; any previously generated primary link is revoked. |
|
Create an additional invite link for a chat. |
|
Edit a non-primary invite link. |
|
Revoke a previously created invite link. |
|
Get the invite links created by an administrator in a chat. |
|
Get the count of the invite links created by an administrator in a chat. |
|
Get the list of the administrators that have exported invite links in a chat. |
|
Get detailed information about a chat invite link. |
|
Get the members who joined the chat with the invite link. |
|
Get the count of the members who joined the chat with the invite link. |
|
Delete an already revoked invite link. |
|
Delete all revoked invite links of an administrator. |
|
Get the pending join requests of a chat. |
|
Approve a chat join request. |
|
Approve all pending join requests in a chat. |
|
Decline a chat join request. |
|
Decline all pending join requests in a chat. |
Chat Forum Topics#
Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. |
|
Use this method to create a topic in a forum supergroup chat. |
|
Use this method to edit name and icon of a topic in a forum supergroup chat. |
|
Use this method to close an open topic in a forum supergroup chat. |
|
Use this method to reopen a closed topic in a forum supergroup chat. |
|
Use this method to delete a forum topic along with all its messages in a forum supergroup chat. |
|
Use this method to hide a topic in a forum supergroup chat. |
|
Use this method to unhide a topic in a forum supergroup chat. |
|
Get one or more topic from a chat. |
|
Get one or more topic from a chat by using topic identifiers. |
|
Changes the pinned state of a forum topic; requires can_manage_topics right in the supergroup. |
Users#
Get a chat or a user profile photos sequentially. |
|
Get the total count of photos for a chat. |
|
Get information about a user. |
|
Set a new profile photo or video (H.264/MPEG-4 AVC video, max 5 seconds). |
|
Delete your own profile photos. |
|
Changes the editable username of the current user. |
|
Update your profile details such as first name, last name and bio. |
|
Block a user. |
|
Unblock a user. |
|
Get the common chats you have with a user. |
|
Get the default emoji statuses. |
|
Set the emoji status. |
|
Changes the birthdate of the current user |
|
Changes the personal chat of the current user |
|
Deletes the account of the current user, deleting all information associated with the user from the server. |
|
Updates online user status. |
Contacts#
Add an existing Telegram user as contact, even without a phone number. |
|
Delete contacts from your Telegram address book. |
|
Import contacts to your Telegram address book. |
|
Get contacts from your Telegram address book. |
|
Get the total count of contacts from your Telegram address book. |
Password#
Enable the Two-Step Verification security feature (Cloud Password) on your account. |
|
Change your Two-Step Verification password (Cloud Password) with a new one. |
|
Turn off the Two-Step Verification security feature (Cloud Password) on your account. |
Bots#
Send answers to callback queries sent from inline keyboards. |
|
Request a callback answer from bots. |
|
Set the list of the bot's commands. |
|
Delete the list of the bot's commands for the given scope and user language. |
|
Get the current list of the bot's commands for the given scope and user language. |
|
Use this method to get the current / owned bot name for the given user language. |
|
Use this method to get the current / owned bot name for the given user language. |
|
Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. |
|
Use this method to get the current / owned bot description for the given user language. |
|
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. |
|
Use this method to get the current / owned bot short description for the given user language. |
|
Change the bot's menu button in a private chat, or the default menu button. |
|
Get the current value of the bot's menu button in a private chat, or the default menu button. |
|
Change the default privileges requested by the bot when it's added as an administrator to groups or channels. |
|
Get the current default privileges of the bot. |
|
Send a game. |
|
Set the score of the specified user in a game. |
|
Get data for high score tables. |
|
Send answers to an inline query. |
|
Get bot results via inline queries. |
|
Send an inline bot result. |
|
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. |
|
Sends a custom request from a Web App. |
|
Returns the list of bots owned by the current user. |
|
Returns a list of bots similar to the given bot. |
Stickers#
Send static .webp or animated .tgs stickers. |
|
Get information about custom emoji stickers by their identifiers. |
|
Returns information about all available message effects. |
|
Get all stickers from set by short name. |
Stories#
Get one or more stories from a chat by using stories identifiers. |
Payments#
Use this method to send invoices. |
|
Use this method to create a link for an invoice. |
|
If you sent an invoice requesting a shipping address and the parameter |
|
Once the user has confirmed their payment and shipping details, the API sends the final confirmation in the form of an |
|
Refunds a successful payment in Telegram Stars. |
|
Use this method to get information about the connection of the bot with a business account. |
|
Returns information about a given collectible item that was purchased at https://fragment.com |
|
Get information about a invoice or paid media. |
|
Pay an invoice. |
|
Get all gifts that can be sent to other users. |
|
Get gifts saved to profile by the given user. |
|
Sells a gift received by the current user for Telegram Stars. |
|
Sends a gift to another user. |
|
Toggles whether a gift is shown on the current user's profile page. |
|
Get the number of Telegram Stars count owned by the current account or the specified bot. |
Phone#
Creates a video chat (a group call bound to a chat). |
|
Terminate a group/channel call or livestream |
|
Returns RTMP URL for streaming to the chat; requires owner privileges. |
|
Invites users to an active group call. |
|
Loads participants list in a group call of a chat. |
Advanced#
Methods used only when dealing with the raw Telegram API. Learn more about how to use the raw API at Advanced Usage.
Invoke raw Telegram functions. |
|
Get the InputPeer of a known peer id. |
|
Upload a file onto Telegram servers, without actually sending the message to anyone. |