svglogo Welcome to Telethon’s documentation!

import asyncio
from telethon import Client, events
from telethon.events import filters

async def main():
    async with Client('name', api_id, api_hash) as client:
        me = await client.interactive_login()
        await client.send_message(me, f'Hello, {me.name}!')

        @client.on(events.NewMessage, filters.Text(r'(?i)hello'))
        async def handler(event):
            await event.reply('Hey!')

        await client.run_until_disconnected()

asyncio.run(main())

Preface

What is this?

Telegram is a popular messaging application. This library is meant to make it easy for you to write Python programs that can interact with Telegram. Think of it as a wrapper that has already done the hard work for you, so you can focus on developing an application.

How should I use the documentation?

This documentation is divided in multiple sections. The first few sections are a guide, while others contain the API reference or a glossary of terms. The documentation assumes some familiarity with Python.

If you are getting started with the library, you should follow the documentation in order by pressing the “Next” button at the bottom-right of every page.

You can also use the menu on the left to quickly skip over sections if you’re looking for something in particular or want to continue where you left off.

First steps

In this section you will learn how to install the library and login to your Telegram account.

‣ Start reading Installation

Concepts

A more in-depth explanation of some of the concepts and words used in Telethon.

‣ Start reading Chat concept

API reference

This section contains all the functions and types offered by the library.

‣ Start reading Client API

Development resources

Tips and tricks to develop both with the library and for the library.

‣ Start reading Changelog