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("me", "hi")
Utilities¶
Start the client. |
|
Stop the Client. |
|
Start the client, idle the main script and finally stop the client. |
|
Restart the Client. |
|
Register an update handler. |
|
Remove a previously-registered update handler. |
|
Stop downloading or uploading a file. |
|
Export the current authorized session as a serialized string. |
|
Set the parse mode to be used globally by the client. |
|
Set configuration for the specified datacenter. |
|
Get existing session or create a new one. |
|
Block the main script execution until a signal is received. |
|
Run multiple clients at once. |
Messages¶
Send text messages. |
|
Forward a media group by providing one of the message ids. |
|
Forward messages of any kind. |
|
Copy messages of any kind. |
|
Copy a media group by providing one of the message ids. |
|
Send photos. |
|
Send audio files. |
|
Send generic files. |
|
Notify the other user in a private chat that a screenshot of the chat was taken. |
|
Send static .webp or animated .tgs stickers. |
|
Send video files. |
|
Send animation files (animation or H.264/MPEG-4 AVC video without sound). |
|
Send audio files. |
|
Send video messages. |
|
Send a group of photos or videos as an album. |
|
Use this method to stream a partial message to a user while the message is being generated. |
|
Send points on the map. |
|
Send information about a venue. |
|
Send phone contacts. |
|
Send any media stored on the Telegram servers using a file_id. |
|
Send a reaction to a message or story. |
|
Edit the text of messages. |
|
Fixes text using an AI model. |
|
Edit the caption of media messages. |
|
Use this method to edit a checklist. |
|
Edit 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 the text of inline messages. |
|
Edit the caption of inline media messages. |
|
Edit inline animation, audio, document, photo or video messages, or to add media to text messages. |
|
Edit only the reply markup of inline messages sent via the bot (for inline bots). |
|
Tell the other party that something is happening on your side. |
|
Send a new checklist. |
|
Delete messages, including service messages. |
|
Get all available effects. |
|
Get one or more messages from a chat by using message identifiers or link. |
|
Get one or more scheduled messages from a chat. |
|
Get all stickers from set by short name. |
|
Returns an HTTPS URL of a Web App to open. |
|
Returns an HTTPS URL of a Web App to open from the side menu, a |
|
Add tasks of a checklist in a message as done or not done. |
|
Informs pyrogram that a Web App is being opened from the attachment menu, a |
|
Get the media group a message belongs to. |
|
Get messages from a chat history. |
|
Get the total count of messages in a chat. |
|
Mark a mention in the chat as read. |
|
Mark a reaction in the chat as read. |
|
Mark a chat's message history as read. |
|
A message with a poll. |
|
Increment message views counter. |
|
Vote a poll. |
|
Stop a poll which was sent by you. |
|
Retract your vote in a poll. |
|
Send a dice with a random value from 1 to 6. |
|
Search for text and media messages inside a specific chat. |
|
Get the count of messages resulting from a search inside a chat. |
|
Search posts globally by hashtag. |
|
Get the count of posts with hashtag resulting from a search. |
|
Search messages globally from all of your chats. |
|
Get the count of messages resulting from a global search. |
|
Download the media from a message. |
|
Stream the media from a message chunk by chunk. |
|
Extract text or caption of the given message and translates it to the given language. |
|
Translate a text to the given language. |
|
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. |
|
Returns information needed to open the main Web App of a bot. |
|
Get information about custom emoji stickers by their identifiers. |
|
Return messages in the topic in a channel direct messages chat administered by the current user. |
|
Delete messages in the topic in a channel direct messages chat administered by the current user. |
|
Change the marked as unread state of the topic in a channel direct messages chat administered by the current user. |
|
Start bot |
|
Delete the history of a chat. |
|
Send a group or one paid photo/video. |
|
Send a paid reaction to a message. |
|
Add a GIF to the list of saved GIFs. |
|
Use this method to approve a suggested post in a direct messages chat. |
|
Changes text using an AI model. |
|
Use this method to decline a suggested post in a direct messages chat. |
|
Add tasks to a checklist in a message. |
|
Adds an option to a poll. |
|
Deletes an option from a poll. |
|
Summarizes content of the message with non-empty summary_language_code. |
Chats¶
Join a group chat or channel. |
|
Leave a group chat or channel. |
|
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 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. |
|
Change direct messages group settings for a channel chat. |
|
Set default chat permissions for all members. |
|
Pin a message in a group, channel or your own chat. |
|
Unpin a message in a group, channel or your own chat. |
|
Pin a forum topic. |
|
Processes request to disable has_protected_content in a chat. |
|
Unpin a forum topic. |
|
Use this method to clear the list of pinned messages in a chat. |
|
Get up to date information about a chat. |
|
Get information about one member of a chat. |
|
Get the members list of a chat. |
|
Get the number of members in a chat. |
|
Get a user's dialogs sequentially. |
|
Get the total count of your dialogs. |
|
Get one or more direct message topic from a chat by using topic identifiers. |
|
Get one or more topic from a direct messages channel chat. |
|
Set a channel or a supergroup username. |
|
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. |
|
Deletes an invite link for a chat folder. |
|
Returns invite links created by the current user for a shareable chat folder. |
|
Delete a supergroup. |
|
Delete all messages sent by a certain user in a supergroup. |
|
Set the slow mode interval for 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. |
|
Close a forum topic. |
|
Create a new forum topic. |
|
Delete a forum topic. |
|
Edit a forum topic. |
|
Get one or more topic from a chat. |
|
Get one or more topic from a chat by using topic identifiers. |
|
Update color |
|
Changes color scheme for the current user based on an owned or a hosted upgraded gift. |
|
Update the notification settings for the selected chat |
|
Enable or disable forum functionality in a supergroup. |
|
Create a new invite link for a chat folder. |
|
Returns chats from a chat folder, suitable for adding to a chat folder invite link. |
|
Return information about a chat folders. |
|
Create new chat folder. |
|
Delete a user's folder. |
|
Change the order of chat folders. |
|
Update chat folder. |
|
Get similar channels. |
|
Join a folder by its invite link. |
|
Leave a folder by its invite link. |
|
Enable or disable guest users' ability to send messages in a supergroup. |
|
Toggles whether chat folder tags are enabled. |
|
Set the time-to-live for the chat. |
|
Get all your public channels. |
|
Get information about a chat settings. |
|
Change the owner of a chat or channel. |
|
Return a list of basic group and supergroup chats, which can be used as a discussion group for a channel. |
|
Change the discussion group of a channel chat. |
|
Use this method to set a tag for a regular member in a group or a supergroup. |
|
Changes the main profile tab of the user or channel. |
Users¶
Get your own user identity. |
|
Get information about a user. |
|
Get a chat or a user profile photos sequentially. |
|
Get a user profile audios sequentially. |
|
Get the total count of photos for a chat. |
|
Get the total count of audios for a chat. |
|
Changes a profile photo for the current user. |
|
Set a personal channel in bio. |
|
Delete your own profile photos. |
|
Set your own username. |
|
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. |
|
Update your profile status. |
|
Check if a username is available. |
|
Update birthday in your profile. |
Invite Links¶
Get detailed information about a chat invite link. |
|
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. |
|
Delete an already revoked 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. |
|
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 the pending join requests of a chat. |
|
Delete all revoked invite links of an administrator. |
|
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. |
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. |
|
Returns users and chats that were blocked by the current user. |
|
Get contacts from your Telegram address book. |
|
Get the total count of contacts from your Telegram address book. |
|
Returns users or channels found by name substring and auxiliary data. |
|
Changes a note of a contact user. |
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¶
Get bot results via inline queries. |
|
Send an inline bot result. |
|
Use this method to send invoices. |
|
Send answers to callback queries sent from inline keyboards. |
|
Send answers to an inline query. |
|
Request a callback answer from bots. |
|
Send a game. |
|
Set the score of the specified user in a game. |
|
Get data for high score tables. |
|
Set the list of the bot's commands. |
|
Get the current list of the bot's commands for the given scope and user language. |
|
Delete the list of the bot's commands for the given scope and user language. |
|
Cancels or re-enables Telegram Star subscription for a user. |
|
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. |
|
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. |
|
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. |
|
Checks whether a username can be set for a new bot. |
|
Creates a bot which will be managed by another bot. |
|
Send answers to pre-checkout queries. |
|
If you sent an invoice requesting a shipping address and the parameter |
|
Create invoice link. |
|
Refunds a successful payment in Telegram Stars. |
|
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. |
|
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 get the token of a managed bot. |
|
Use this method to revoke the current token of a managed bot and generate a new one. |
|
Returns the list of bots owned by the current user. |
Stories¶
Check whether we can post stories as the specified chat. |
|
Copy story. |
|
Delete posted stories. |
|
Edit the caption of story. |
|
Edit story media. |
|
Edit the privacy of story. |
|
Forward story. |
|
Get all active or hidden stories that displayed on the action bar on the homescreen. |
|
Get all non expired stories from a chat by using chat identifier. |
|
Get all pinned stories from a chat by using chat identifier. |
|
Get all archived stories from a chat by using chat identifier. |
|
Get one or more stories from a chat by using stories identifiers. |
|
Hide the active stories of a user, preventing them from being displayed on the action bar on the homescreen. |
|
Show the active stories of a user and display them in the action bar on the homescreen. |
|
Increment story views. |
|
Pin one or more stories in a chat by using stories identifiers. |
|
Unpin one or more stories in a chat by using stories identifiers. |
|
Mark all stories up to a certain identifier as read, for a given chat. |
|
Post new story. |
|
Activates stories stealth mode. |
|
Obtain the list of users that have viewed a specific story we posted. |
Phone¶
Get the members list of a chat call. |
Business¶
Delete messages on behalf of a business account. |
|
Return the gifts received and owned by a managed business account. |
|
Return the amount of Telegram Stars owned by a managed business account. |
|
Use this method to get information about the connection of the bot with a business account. |
|
Transfers Telegram Stars from the business account balance to the bot’s balance. |
Payments¶
Apply a gift code. |
|
Pays for upgrade of a regular gift that is owned by another user or channel chat. |
|
Get information about a gift code. |
|
Convert a given regular gift to Telegram Stars. |
|
Get all available star gifts that can be sent to other users. |
|
Get all gifts owned by specified chat. |
|
Returns auction state for a gift. |
|
Get the total count of owned gifts of specified chat. |
|
Adds gifts to the beginning of a previously created collection. |
|
Creates a collection from gifts on the current user's or a channel's profile page. |
|
Deletes a gift collection. |
|
Drops original details for an upgraded gift. |
|
Cancels or re-enables Telegram Star subscription. |
|
Returns collections of gifts owned by the given user or chat. |
|
Removes gifts from a collection. |
|
Changes order of gifts in a collection. |
|
Changes order of gift collections. |
|
Reuses an active Telegram Star subscription to a channel chat and joins the chat again. |
|
Changes name of a gift collection. |
|
Return examples of possible upgraded gifts for a regular gift. |
|
Returns all possible variants of upgraded gifts for a regular gift. |
|
Returns upgraded gifts of the current user that can be used to craft another gifts. |
|
Crafts a new gift from other gifts that will be permanently lost. |
|
Get an invoice payment form. |
|
Get the current Telegram Stars balance of the current account. |
|
Get the current TON balance of the current account. |
|
Returns information about value of an upgraded gift by its name. |
|
Get information about upgraded gift. |
|
Allows to buy a Telegram Premium subscription for another user with payment in Telegram Stars. |
|
Hide gift on the current user's or the channel's profile page. |
|
Increases a bid for an auction gift without changing gift text and receiver. |
|
Places a bid on an auction gift. |
|
Get upgraded gifts that can be bought from other owners. |
|
Send a gift to another user or channel chat. |
|
Send a filled-out payment form to the bot for final verification. |
|
Send an upgraded gift that is available for resale to another user or channel chat. |
|
Change resale price of a unique gift owned by the current user. |
|
Change the list of pinned gifts on the current user. |
|
Display gift on the current user's or the channel's profile page. |
|
Suggests a birthdate to another regular user with common messages and allowing non-paid messages. |
|
Transfers an owned unique gift to another user. |
|
Upgrade a given regular gift to a unique gift. |
|
Handles a pending gift purchase offer. |
|
Sends an offer to purchase an upgraded gift. |
Account¶
Adds an audio file to the beginning of the profile audio files of the current user. |
|
Removes an audio file from the profile audio files of the current user. |
|
Changes position of an audio file in the profile audio files of the current user. |
|
Get days to live of account. |
|
Set days to live of account. |
|
Set account privacy rules. |
|
Get account privacy rules. |
|
Set account global privacy settings. |
|
Changes the period of inactivity after which sessions will automatically be terminated. |
|
Get account global privacy settings. |
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. |
|
Restores updates for the time while the client was offline. |
|
Get the InputPeer of a known peer id. |
|
Upload a file onto Telegram servers, without actually sending the message to anyone. |