Skip to main content
python-telegram-bot Logo

We have made you a wrapper you can’t refuse

We have a vibrant community of developers helping each other in our Telegram group. Join us!

Stay tuned for library updates and new releases on our Telegram Channel.

PyPi Package Version Supported Python versions Supported Bot API versions PyPi Package Monthly Download Documentation Status LGPLv3 License Github Actions workflow Code coverage Median time to resolve an issue Code quality: Codacy Code quality: DeepSource https://img.shields.io/badge/code%20style-black-000000.svg Telegram Group

Table of contents

Introduction

This library provides a pure Python interface for the Telegram Bot API. It’s compatible with Python versions 3.7+. PTB might also work on PyPy, though there have been a lot of issues before. Hence, PyPy is not officially supported.

In addition to the pure API implementation, this library features a number of high-level classes to make the development of bots easy and straightforward. These classes are contained in the telegram.ext submodule.

A pure API implementation without telegram.ext is available as the standalone package python-telegram-bot-raw. See here for details.

Note

Installing both python-telegram-bot and python-telegram-bot-raw in conjunction will result in undesired side-effects, so only install one of both.

Telegram API support

All types and methods of the Telegram Bot API 6.2 are supported.

Installing

You can install or upgrade python-telegram-bot with:

$ pip install python-telegram-bot --upgrade

Or you can install from source with:

$ git clone https://github.com/python-telegram-bot/python-telegram-bot --recursive
$ cd python-telegram-bot
$ python setup.py install

In case you have a previously cloned local repository already, you should initialize the added urllib3 submodule before installing with:

$ git submodule update --init --recursive

Optional Dependencies

PTB can be installed with optional dependencies:

  • pip install python-telegram-bot[passport] installs the cryptography library. Use this, if you want to use Telegram Passport related functionality.

  • pip install python-telegram-bot[ujson] installs the ujson library. It will then be used for JSON de- & encoding, which can bring speed up compared to the standard json library.

  • pip install python-telegram-bot[socks] installs the PySocks library. Use this, if you want to work behind a Socks5 server.

Getting started

Our Wiki contains a lot of resources to get you started with python-telegram-bot:

Other references:

Learning by example

We believe that the best way to learn this package is by example. Here are some examples for you to review. Even if it is not your approach for learning, please take a look at echobot.py, it is the de facto base for most of the bots out there. Best of all, the code for these examples are released to the public domain, so you can start by grabbing the code and building on top of it.

Visit this page to discover the official examples or look at the examples on the wiki to see other bots the community has built.

Logging

This library uses the logging module. To set up logging to standard output, put:

import logging
logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

at the beginning of your script.

You can also use logs in your application by calling logging.getLogger() and setting the log level you want:

logger = logging.getLogger()
logger.setLevel(logging.INFO)

If you want DEBUG logs instead:

logger.setLevel(logging.DEBUG)

Documentation

python-telegram-bot’s documentation lives at readthedocs.io.

Getting help

You can get help in several ways:

  1. We have a vibrant community of developers helping each other in our Telegram group. Join us!

  2. Report bugs, request new features or ask questions by creating an issue or a discussion.

  3. Our Wiki pages offer a growing amount of resources.

  4. You can even ask for help on Stack Overflow using the python-telegram-bot tag.

Contributing

Contributions of all sizes are welcome. Please review our contribution guidelines to get started. You can also help by reporting bugs.

Donating

Occasionally we are asked if we accept donations to support the development. While we appreciate the thought, maintaining PTB is our hobby and we have almost no running costs for it. We therefore have nothing set up to accept donations. If you still want to donate, we kindly ask you to donate to another open source project/initiative of your choice instead.

License

You may copy, distribute and modify the software provided that modifications are described and licensed for free under LGPL-3. Derivatives works (including modifications or anything statically linked to the library) can only be redistributed under LGPL-3, but applications that use the library don’t have to be.

Release files for python-telegram-bot 13.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-telegram-bot 13.15
File Size Uploaded
python-telegram-bot-13.15.tar.gz 357.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-telegram-bot 13.15
File Interpreter ABI Platform
python_telegram_bot-13.15-py3-none-any.whl Python 3 none any Details

Total release size: 877.0 kB

Release files / python-telegram-bot-13.15.tar.gz

Download URL python-telegram-bot-13.15.tar.gz
Size 357.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b4047606b8081b62bbd6aa361f7ca1efe87fa8f1881ec9d932d35844bf57a154
BLAKE2b-256 checksum
How to use checksums
0dbc89cd44af162c3f5bf1bd50f4beb9f47353f027552e290899b55723746509
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Release files / python_telegram_bot-13.15-py3-none-any.whl

Download URL python_telegram_bot-13.15-py3-none-any.whl
Size 519.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06780c258d3f2a3c6c79a7aeb45714f4cd1dd6275941b7dc4628bba64fddd465
BLAKE2b-256 checksum
How to use checksums
14db29356a2f43052af470993fdf2083ca8bf28da4586da836aa609de2d86a06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Release history Release notifications | RSS feed

22.8

2 release files

22.7

2 release files

22.6

2 release files

22.5

2 release files

22.4

2 release files

22.3

2 release files

22.2

2 release files

22.1

2 release files

22.0

2 release files

21.11

2 release files

21.10

2 release files

21.9

2 release files

21.8

2 release files

21.7

2 release files

21.6

2 release files

21.5

2 release files

21.4

2 release files

21.3

2 release files

21.2

2 release files

21.1.1

2 release files

21.1

2 release files

21.0

2 release files

20.8

2 release files

20.7

2 release files

20.6

2 release files

20.5

2 release files

20.4

2 release files

20.3

2 release files

20.2

2 release files

20.1

2 release files

20.0

2 release files

This release

13.15 This release

2 release files

13.14

2 release files

13.13

2 release files

13.12

2 release files

13.11

2 release files

13.10

2 release files

13.9

2 release files

13.8

2 release files

13.7

2 release files

13.6

2 release files

13.5

2 release files

13.4.1

2 release files

13.4

2 release files

13.3

2 release files

13.2

2 release files

13.1

2 release files

13.0

2 release files

12.8

2 release files

12.7

2 release files

12.6.1

2 release files

12.6

2 release files

12.5.1

2 release files

12.5

2 release files

12.4.2

2 release files

12.3.0

2 release files

12.2.0

2 release files

12.1.1

2 release files

12.1.0

2 release files

12.0.0

2 release files

11.0.0

2 release files

10.0.2

2 release files

9.0.0

2 release files

8.1.1

2 release files

8.1.0

2 release files

8.0

2 release files

7.0.1

2 release files

7.0.0

2 release files

6.1.0

2 release files

6.0.3

2 release files

6.0.2

2 release files

6.0.1

2 release files

6.0.0

3 release files

5.3.1

3 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.3.4

2 release files

4.3.3

2 release files

4.3.2

2 release files

4.3.1

2 release files

4.3

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.4

2 release files

3.3

2 release files

3.2.0

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.9.2

2 release files

2.9.1

2 release files

2.9

2 release files

2.8.7

2 release files

2.8.6

2 release files

2.8.5

2 release files

2.8.4

2 release files

2.8.3

2 release files

2.8.2

2 release files

2.8.1

2 release files

2.8

2 release files

2.7.1

2 release files

2.7

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.3

2 release files

2.5.2

2 release files

2.5.1

1 release file

2.5

1 release file

2.4

1 release file

2.3

1 release file

2.2

1 release file

2.1

1 release file

2.0

1 release file

1.9

1 release file

1.8

1 release file

1.7

1 release file

1.6

1 release file

1.5

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page