Sleek, advanced, and asynchronous Telegram MTProto API framework in Python, designed for fluid user and bot interactions. https://hydrogram.org
  • Python 99.8%
  • Makefile 0.2%
Find a file
Alisson Lauffer edb10c6027
fix(session): prevent race condition during connection cleanup
Reorder the stop() method to cancel recv_task BEFORE closing the
connection. Previously, closing the connection first would set asyncio
transport callbacks to None while recv_worker() might still be reading,
causing 'TypeError: NoneType object is not callable' in
_SelectorSocketTransport._read_ready().
2026-03-22 14:31:56 -03:00
.github chore: migrate from rye to uv 2025-04-17 15:39:05 -03:00
compiler chore: update docs json file 2026-03-21 14:25:24 -03:00
dev_tools style: apply ruff lint fixes and update ruff config 2026-03-21 14:04:51 -03:00
docs docs: update installation instructions and enhance quick start guide 2025-04-19 14:44:37 -03:00
hydrogram fix(session): prevent race condition during connection cleanup 2026-03-22 14:31:56 -03:00
news chore(pre-commit): add local hook for NEWS fragment file naming convention 2025-04-17 19:49:39 -03:00
tests refactor: optimize RLE encoding/decoding 2025-04-17 13:25:44 -03:00
.editorconfig chore: add readthedocs config file 2023-11-30 19:16:31 -03:00
.gitignore chore: migrate from rye to uv 2025-04-17 15:39:05 -03:00
.pre-commit-config.yaml chore(deps): bump ruff from 0.12.5 to 0.15.7 2026-03-21 14:13:35 -03:00
.python-version chore: migrate from rye to uv 2025-04-17 15:39:05 -03:00
.readthedocs.yaml fix(doc): run docs compiler in post installation 2023-12-02 01:33:48 -03:00
AGENTS.md chore: add AGENTS.md for project context 2026-03-21 14:56:28 -03:00
CONTRIBUTING.md chore: migrate from rye to uv 2025-04-17 15:39:05 -03:00
COPYING style: format the code wit pre-commit-hooks 2023-11-01 17:14:14 -03:00
COPYING.lesser style: format the code wit pre-commit-hooks 2023-11-01 17:14:14 -03:00
hatch_build.py refactor: improvements following pylint 2024-05-26 22:26:28 -03:00
Makefile feat: add new Makefile targets for API schema check, JSON generation, and bot API comparison 2025-04-17 19:58:57 -03:00
MANIFEST.in chore: fix makefile 2023-10-31 21:25:50 -03:00
NEWS.rst chore: update ruff to 0.5.1 2024-07-07 12:40:11 -03:00
NOTICE chore: migrate to our vanity domain and fix hyperlinks (#8) 2023-12-09 20:21:20 -03:00
pyproject.toml chore(deps): bump ruff from 0.12.5 to 0.15.7 2026-03-21 14:13:35 -03:00
README.md refactor(client)!: remove synchronous support 2024-05-26 17:57:58 -03:00
ruff.toml style: apply ruff lint fixes and update ruff config 2026-03-21 14:04:51 -03:00
uv.lock chore(deps): bump ruff from 0.12.5 to 0.15.7 2026-03-21 14:13:35 -03:00

Hydrogram
Python Framework for the Telegram MTProto API
Homepage Documentation Releases News

Hydrogram

We use Ruff PyPI package version PyPI license PyPI python versions PyPI download month GitHub Actions status

Description

Hydrogram is a Python library for interacting with the Telegram MTProto API. It provides a simple and intuitive interface for developers to leverage the power of Telegram's API in their Python applications.

Installation

To install Hydrogram, you need Python 3 installed on your system. If you don't have Python installed, you can download it from the official website.

To install Hydrogram, use pip:

pip install hydrogram -U

Usage

Here is a basic example of how to use Hydrogram:

from hydrogram import Client, filters

app = Client("my_account")


@app.on_message(filters.private)
async def hello(client, message):
    await message.reply("Hello from Hydrogram!")


app.run()

Features

  • Easy to use: Hydrogram provides a simple and intuitive interface for developers to leverage the power of Telegram's API in their Python applications, while still allowing advanced usages.
  • Elegant: Low-level details are abstracted and re-presented in a more convenient way, making the Telegram API more accessible.
  • Fast: Hydrogram is boosted by TgCrypto, a high-performance cryptography library written in C, which makes it faster than other Python Telegram libraries.
  • Type-hinted: Types and methods are all type-hinted, enabling excellent editor support and making it easier to write and maintain code.
  • Async: Hydrogram is fully asynchronous, which means it can handle multiple requests at the same time, making it faster and more efficient.
  • Powerful: Hydrogram provides full access to Telegram's API to execute any official client action and more, giving developers the flexibility to build powerful applications.

Resources

  • The documentation is the technical reference for Hydrogram. It includes detailed usage guides, API reference, and more.
  • The homepage is the official website for Hydrogram. It includes a quickstart guide, a list of features, and more.
  • Our Telegram channel is where we post news and updates about Hydrogram.

Contributing

Hydrogram is an open source project and we welcome contributions from the community. We appreciate all types of contributions, including bug reports, feature requests, documentation improvements, and code contributions.

To get started, please review our Contribution Guidelines for more information.

All contributors are expected to adhere to the Code of Conduct. Please read it before contributing.

We appreciate your help in making Hydrogram better!

Support

Hydrogram is an open source project. Your support helps us maintain and improve the library. You can support the development of Hydrogram through the following platforms:

Thanks

  • Pyrogram and its contributors for the inspiration and base code.

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.