Client Reference

This page contains a summary of all the important methods and properties that you may need when using Telethon. They are sorted by relevance and are not in alphabetical order.

You should use this page to learn about which methods are available, and if you need an usage example or further description of the arguments, be sure to follow the links.

TelegramClient

This is a summary of the methods and properties you will find at TelegramClient.

Auth

start Starts the client (connects and logs in if necessary).
send_code_request Sends the Telegram code needed to login to the given phone number.
sign_in Logs in to Telegram to an existing user or bot account.
sign_up Signs up to Telegram as a new user account.
log_out Logs out Telegram and deletes the current *.session file.
edit_2fa Changes the 2FA settings of the logged in user.

Base

connect Connects to Telegram.
disconnect Disconnects from Telegram.
is_connected Returns True if the user has connected.
disconnected Property with a Future that resolves upon disconnection.
loop Property with the asyncio event loop used by this client.

Messages

send_message Sends a message to the specified user, chat or channel.
edit_message Edits the given message to change its text or media.
delete_messages Deletes the given messages, optionally “for everyone”.
forward_messages Forwards the given messages to the specified entity.
iter_messages Iterator over the messages for the given chat.
get_messages Same as iter_messages(), but returns a TotalList instead.
pin_message Pins or unpins a message in a chat.
send_read_acknowledge Marks messages as read and optionally clears mentions.

Uploads

send_file Sends message with the given file to the specified entity.
upload_file Uploads a file to Telegram’s servers, without sending it.

Downloads

download_media Downloads the given media from a message object.
download_profile_photo Downloads the profile photo from the given user, chat or channel.
download_file Low-level method to download files from their input location.

Dialogs

iter_dialogs Iterator over the dialogs (open conversations/subscribed channels).
get_dialogs Same as iter_dialogs(), but returns a TotalList instead.
edit_folder Edits the folder used by one or more dialogs to archive them.
iter_drafts Iterator over draft messages.
get_drafts Same as iter_drafts(), but returns a list instead.
delete_dialog Deletes a dialog (leaves a chat or channel).
conversation Creates a Conversation with the given entity.

Users

get_me Gets “me”, the current User who is logged in.
is_bot Return True if the signed-in user is a bot, False otherwise.
is_user_authorized Returns True if the user is authorized (logged in).
get_entity Turns the given entity into a valid Telegram User, Chat or Channel.
get_input_entity Turns the given entity into its input entity version.
get_peer_id Gets the ID for the given entity.

Chats

iter_participants Iterator over the participants belonging to the specified chat.
get_participants Same as iter_participants(), but returns a TotalList instead.
iter_admin_log Iterator over the admin log for the specified channel.
get_admin_log Same as iter_admin_log(), but returns a list instead.
iter_profile_photos Iterator over a user’s profile photos or a chat’s photos.
get_profile_photos Same as iter_profile_photos(), but returns a TotalList instead.
edit_admin Edits admin permissions for someone in a chat.
edit_permissions Edits user restrictions in a chat.
action Returns a context-manager object to represent a “chat action”.

Parse Mode

parse_mode This property is the default parse mode used when sending messages.

Updates

on Decorator used to add_event_handler more conveniently.
run_until_disconnected Runs the event loop until the library is disconnected.
add_event_handler Registers a new event handler callback.
remove_event_handler Inverse operation of add_event_handler().
list_event_handlers Lists all registered event handlers.
catch_up “Catches up” on the missed updates while the client was offline.

Bots

inline_query Makes an inline query to the specified bot (@vote New Poll).

Account

takeout Returns a TelegramClient which calls methods behind a takeout session.
end_takeout Finishes the current takeout session.