Skip to content
Lonami edited this page Jun 9, 2017 · 27 revisions

This wiki page is meant to be a place where everyone can find and contribute examples on how to use Telethon. All examples shown here assume that you've successfully created a client as follows:

from telethon import TelegramClient

# Use your own values here
api_id = 12345
api_hash = '0123456789abcdef0123456789abcdef'
phone_number = '+34600000000'

client = TelegramClient('some_name', api_id, api_hash)
client.connect()  # Must return True, otherwise, try again

if not client.is_user_authorized():
    client.send_code_request(phone_number)
    client.sign_in(phone_number, input('Enter code: '))

# The `client´ is now ready

The online documentation for all available requests, types and constructors is available online at https://lonamiwebs.github.io/Telethon/.