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")
Utilities
Start the client. |
|
Stop the Client. |
|
Start the client, idle the main script and finally stop the client. |
|
Runs the given sync function (optionally with arguments) on a separate thread. |
|
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. |
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. |
|
Copy a media group by providing one of the message ids. |
|
Send photos. |
|
Send audio files. |
|
Send generic files. |
|
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 text Web Page Preview. |
|
Send a group of photos or videos as an album. |
|
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. |
|
Use this method to send reactions on a message/stories. |
|
Adds the paid message reaction to a message. |
|
Use this method to send paid media. |
|
Edit the text of messages. |
|
Edit the caption of media messages. |
|
Edit animation, audio, document, photo or video 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. |
|
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. |
|
Delete messages, including service messages. |
|
Delete scheduled messages. |
|
Get all available effects. |
|
Get one or more messages from a chat by using message identifiers. |
|
Get one or more scheduled messages from a chat by using message identifiers. |
|
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 chat's message history as read. |
|
Send a new poll. |
|
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 messages globally from all of your chats. |
|
Get the count of messages resulting from a global search. |
|
Searches for public channel posts with the given hashtag. |
|
Get the count of messages with the provided hashtag. |
|
Download the media from a message. |
|
Stream the media from a message chunk by chunk. |
|
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. |
|
Get information about custom emoji stickers by their identifiers. |
|
Translates a text to the given language. |
Stories
Delete one or more story by using story identifiers. |
|
Edit story. |
|
Get one story link from an user by using story identifiers. |
|
Forward a story. |
|
Get all active stories. |
|
Get one or more story from an user by using story identifiers. |
|
Get stories history. |
|
Get all active stories from an user/channel by using user identifiers. |
|
Send new story. |
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. |
|
Delete a user's folder. |
|
Export link to a user's folder. |
|
Change the title of a chat. |
|
Change the description of a supergroup or a channel. |
|
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. |
|
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 folders by using folder identifiers. |
|
Get one or more topic from a chat. |
|
Get one or more topic from a chat by using topic identifiers. |
|
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. |
|
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. |
|
Close a forum topic. |
|
Create a new forum topic. |
|
Delete a forum topic. |
|
Edit a forum topic. |
|
Edit a general forum topic. |
|
hide a general forum topic. |
|
Reopen a forum topic. |
|
Reopen a general forum topic. |
|
unhide a general forum topic. |
|
Update color |
|
Delete the history of a chat. |
|
Create or update a user's folder. |
Stickers
Add a sticker to stickerset. |
|
Create a new stickerset. |
|
Get info about a stickerset. |
Telegram Business
Send answers to pre-checkout queries. |
|
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 |
|
Use this method to create a link for an invoice. |
|
Use this method to get information about the connection of the bot with a business account. |
|
Get stars transactions. |
|
Get stars transactions by transaction id. |
|
Refund the star to the user. |
|
Use this method to send invoices. |
|
Get information about a invoice or paid media. |
|
Pay an invoice. |
Users
Deletes the account of the current user, deleting all information associated with the user from the server. |
|
Get your own user identity. |
|
Get information about a user. |
|
Get a chat or a user profile photos sequentially. |
|
Get the total count of photos for a chat. |
|
Set a new profile photo or video (H.264/MPEG-4 AVC video, max 5 seconds). |
|
Delete your own profile photos. |
|
Set your own username. |
|
Update your birthday details. |
|
Update your birthday details. |
|
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. |
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. |
|
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. |
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. |
|
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. |
|
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. |
|
Get the bot info in given language. |
|
Get the bot info in given language. |
|
Returns information about a given collectible item that was purchased at https://fragment.com |
Authorization
Connect the client to Telegram servers. |
|
Disconnect the client from Telegram servers. |
|
Initialize the client by starting up workers. |
|
Terminate the client by shutting down workers. |
|
Send the confirmation code to the given phone number. |
|
Re-send the confirmation code using a different type. |
|
Authorize a user in Telegram with a valid confirmation code. |
|
Authorize a bot using its bot token generated by BotFather. |
|
Register a new user in Telegram. |
|
Get your Two-Step Verification password hint. |
|
Check your Two-Step Verification password and log in. |
|
Send a code to your email to recover your password. |
|
Recover your password with a recovery code and log in. |
|
Accept the given terms of service. |
|
Log out from Telegram and delete the *.session file. |
|
Returns all active sessions of the current user. |
|
Log out an active authorized session by its hash. |
|
Terminates all user's authorized sessions except for the current one. |
Account
Get days to live of account. |
|
Set days to live of account. |
|
Set account privacy rules. |
|
Get 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 raw Telegram functions. |
|
Get the InputPeer of a known peer id. |
|
Upload a file onto Telegram servers, without actually sending the message to anyone. |