Pytdbot
Pytdbot is an asynchronous TDLib wrapper for Telegram users/bots written in Python.
Features
Pytdbot offers numerous advantages, including:
- Easy to Use: Designed with simplicity in mind, making it accessible for developers
- Performance: Fast and powerful, making it ready to fight
- Asynchronous: Fully asynchronous that allows for non-blocking requests and improved responsiveness
- Scalable: Easily scalable using TDLib Server
- Well-typed: Provides clear and well-defined methods and types to enhance developer experience
- Decorator-Based Updates: Simplifies the implementation of update handlers through a decorator pattern
- Bound Methods: Features types bound methods for improved usability
- Unlimited Support: Supports Plugins, filters, TDLib types/functions and much more
Requirements
Installation
For better performance, it's recommended to install orjson or ujson.
You can install Pytdbot with TDLib included using pip:
pip install --upgrade pytdbot[tdjson]
If the installation fails, then install without pre-built TDLib:
pip install pytdbot
Then you need to build TDLib from source and pass it to Client.lib_path.
You could also install the development version using the following command:
pip install --pre pytdbot
Examples
Basic example:
import asyncio
import logging
from pytdbot import Client, types
logging.basicConfig(
level=logging.INFO,
format="[%(levelname)s][p %(process)d %(threadName)s][%(created)f][%(filename)s:%(lineno)d][%(funcName)s][%(name)s] %(message)s",
)
client = Client(
token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token
api_id=0,
api_hash="API_HASH",
files_directory="BotDB", # Path where to store TDLib files
database_encryption_key="1234echobot$",
td_verbosity=2, # TDLib verbosity level
td_log=types.LogStreamFile("tdlib.log", 104857600), # Set TDLib log file path
)
@client.on_updateNewMessage()
async def print_message(c: Client, message: types.UpdateNewMessage):
print(message)
@client.on_message()
async def say_hello(c: Client, message: types.Message):
msg = await message.reply_text(f"Hey {await message.mention(parse_mode='html')}! I'm cooking up a surprise... 🍳👨🍳", parse_mode="html")
async with message.action("choose_sticker"):
await asyncio.sleep(5)
await msg.edit_text("Boo! 👻 Just kidding.")
# Run the client
asyncio.run(client.run())
For more examples, check the examples folder.
Thanks to
-
You for viewing or using this project.
-
@levlam for maintaining TDLib and for the help to create Pytdbot.
License
MIT License
Metadata
Release files for Pytdbot 0.10.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytdbot-0.10.1.tar.gz | 558.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytdbot-0.10.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / pytdbot-0.10.1.tar.gz
| Download URL | pytdbot-0.10.1.tar.gz |
|---|---|
| Size | 558.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
121e2456da6b112da63436ee267ae35df7e6e34086ac618f912503f3df7fab36
|
|
BLAKE2b-256 checksum How to use checksums |
adb73dcfac2045106ebfdeb514eaf15987d2df720ec174ead890b694fa606901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.
Transparency logRelease files / pytdbot-0.10.1-py3-none-any.whl
| Download URL | pytdbot-0.10.1-py3-none-any.whl |
|---|---|
| Size | 571.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7190cbfdb0c86e9ecc81aec09402ad6d5e08ba0f5bca93e792ed5fd644d6f46
|
|
BLAKE2b-256 checksum How to use checksums |
c16a9a37f566855910daf039701d7739f71bba08ad57b0a47836cdf9e359014e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.
Transparency log