Client Reference

This page contains a summary of all the important methods and properties that you may need when using Grammers-Python. 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 a usage example or further description of the arguments, be sure to follow the links.

Client

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

Net

invoke

Invoke a raw API call.

invoke_raw

low-level api, send data to telegram directly.

Utilities

start

Start login in to telegram

stop

Stop client Calling clent's methods after stopping will raise ClientStoppedError.

idle

Block until the event pool finishes or a termination signal is received (SIGINT / SIGTERM).

run

Shortcut run method, which automatically invoke Client.start() and Client.stop().

Auth

is_authorized

Returns true if the current account is authorized.

authorize

Terminal interactive login.

bot_sign_in

Signs in to the bot account associated with this token.

request_login_code

Requests the login code for the account associated to the given phone number via another Telegram application or SMS.

sign_in

Signs in to the user account.

get_password_information

Extract information needed for the two-factor authentication It's called automatically when we get SESSION_PASSWORD_NEEDED error during sign in.

check_password

Sign in using two-factor authentication (user password).

sign_out

Signs out of the account authorized by this client's session.

disconnect

Signals all clients sharing the same sender pool to disconnect.

Chats

get_me

Fetch information about the currently logged-in user.

resolve_username

Resolves a username (not prefix with '@') into the peer that owns it, if any.

resolve_phone

Resolves a phone to a User.

resolve_input_peer

Resolves a InputPeer into a Peer.

resolve_peer

Resolves any InputPeerLike to a Peer.

resolve_peer_ref

Resolves any InputPeerLike to a PeerRef, with using cached access_hash.

check_invite_link

Check the validity of a chat invite link and get basic info about it.

accept_invite_link

Import a chat invite and join a private chat/supergroup/channel.

Messages

get_messages_by_id

Get messages by id

iter_history_messages

Returns the conversation history with one interlocutor / within a chat