DryGram
Modern, fully asynchronous, production-ready Telegram MTProto v2.0 client framework built from scratch in Python.
Introduction
DryGram is a production-grade, highly-optimized, fully asynchronous Telegram MTProto client framework built from scratch in Python 3.13+. It implements the secure MTProto v2.0 protocol and integrates the latest Telegram features natively.
Designed with architectural originality at its core, DryGram does NOT duplicate or copy Pyrogram, Telethon, or other existing wrappers. It features a decoupled structure, pluggable session stores, extensible middleware chains, and a robust update dispatcher system to achieve maximum performance and scalability.
Features
| Feature | Description |
|---|---|
| Authentication | Support for Bot authorization, User authorization, 2FA password verification, and QR Login flows. |
| Sessions | Pluggable, highly-concurrent database storage backends: SQLite, MongoDB, Redis, and PostgreSQL. |
| Stories | High-level APIs for publishing stories, reacting to them, archiving stories, and adjusting story privacy. |
| Business | Full support for Telegram Business greeting/away responses, custom business links, and short reply templates. |
| Premium | Operations for Telegram Star payments, upgradeable gifts, collectibles, and custom Premium Emoji Statuses. |
| Media | Chunked uploads, high-speed concurrent downloads, and representations for Photos, Videos, Documents, Audios, and VoiceNotes. |
| Text Formatting | Built-in, high-speed parsers for Markdown and HTML messages. |
| Keyboards | Declarative markup interfaces for Reply and Inline keyboards, callback button handlers, and interactive menus. |
| Plugin System & Middleware | Extensible middleware pipelines, priority-based command watchers, and modular update routing. |
| Raw MTProto & AsyncIO | Direct invocation of raw TL schema functions via async loops. |
Installation
Installation Options
1. Standard Installation (No native compilers required)
Install the core package via PyPI:
pip install drygram
2. Optional Crypto Installation
Install with the optional crypto dependency group:
pip install "drygram[crypto]"
Note: Installs the required standard cryptography package without requiring native compilers or Visual Studio Build Tools.
3. Optional Voice & Calling Support
Install with integrations for voice and video calling:
pip install "drygram[calls]"
4. Optional Database Support
Install pluggable session database stores:
# MongoDB support
pip install "drygram[mongodb]"
# Redis support
pip install "drygram[redis]"
# PostgreSQL support
pip install "drygram[postgres]"
5. Development Installation
Install for library contribution and testing:
pip install "drygram[dev]"
Alternative Package Managers
Using uv:
uv pip install drygram
Using Poetry:
poetry add drygram
Installation from Source
To install the latest development code from GitHub:
git clone https://github.com/TG-BOTSNETWORK/drygram.git
cd drygram
pip install -e .
To install development and testing dependencies:
pip install -e .[dev]
Quick Start
The following is a complete runnable bot that responds to /start messages:
from drygram import (
DryClient, filters, enums, errors, types, idle, StringSessionGenerator
)
# Initialize bot client
app = DryClient(api_id=12345, api_hash="abcdef", bot_token="YOUR_BOT_TOKEN")
# Register an update observer for /start command with filters
@app.route("/start", gate=filters.private)
async def start_handler(client, msg: types.Message):
await msg.reply("Hello! Welcome to DryGram.")
if __name__ == "__main__":
app.run()
Top-Level Public API Exports
DryGram provides a clean, Pyrogram/Telethon-friendly top-level import structure:
from drygram import (
DryClient, # Main MTProto client engine
filters, # Pyrogram/Telethon compatible update filter factory
enums, # Telegram enumerations (ChatType, ParseMode, etc.)
errors, # Framework and MTProto RPC exception module
types, # Type dataclasses (Message, User, Chat, Media)
idle, # Signal-safe event loop blocking helper
StringSessionGenerator # Tool for generating DRY1 String Sessions
)
Client Authentication Methods
DryGram supports both Bot and User authentication out of the box.
1. Bot Authentication (Recommended)
Automatically starts the client in Bot Mode. No session file is created; everything runs in memory.
from drygram import DryClient
app = DryClient(
api_id=12345,
api_hash="abcdef",
bot_token="YOUR_BOT_TOKEN" # recommended for bots, no session_name required
)
2. User Authentication
Starts the client in User Mode. Instead of saving .session files on disk, DryGram uses stateless MTProto String Sessions loaded via the session_name parameter.
from drygram import DryClient
# The session_name parameter stores the generated MTProto String Session, not a filename
app = DryClient(
api_id=12345,
api_hash="abcdef",
session_name="DRY1U_..." # generated string session
)
To export the authenticated session to a string:
import asyncio
from drygram import DryClient
async def main():
# If starting without credentials, log in interactively or import string session
async with DryClient(api_id=12345, api_hash="abc", session_name="DRY1U_...") as app:
# Export the active session to a string
sess_str = await app.export_session()
print("Exported String Session:", sess_str)
if __name__ == "__main__":
asyncio.run(main())
Project Structure
drygram/
├── drygram/ # Primary package source code
├── docs/ # Detailed guides and manuals
├── examples/ # Complete client usage examples
├── tests/ # Comprehensive testing suite
├── pyproject.toml # Project metadata and configurations
└── setup.py # Legacy installer script
Documentation
The full documentation is available under the docs/ directory, containing tutorials and details about the architecture. You can also build it locally using MkDocs:
pip install mkdocs-material
mkdocs serve
Supported Platforms
- Windows: x86, x64, ARM64, and WSL.
- Linux: Ubuntu, Debian, Arch Linux, Fedora, CentOS, and Alpine.
- macOS: Intel and Apple Silicon (M1/M2/M3).
- Containerization: Full support for Docker and Kubernetes environments.
Cryptographic Backend & Performance
DryGram dynamically manages cryptographic execution via its built-in Backend Manager:
| Backend | Implementation | Acceleration | Performance Note |
|---|---|---|---|
| Cryptography | Pure Python Engine | Disabled | High compatibility; works out-of-the-box on any platform without compiler tools. |
DryGram operates exclusively on standard Python-compatible cryptography libraries, ensuring compiled C extensions or platform-specific Visual Studio Build Tools are never required.
Optional Voice Support
Voice and video calling functionality are supported through external integrations. Users can utilize third-party WebRTC/calling libraries alongside DryClient for streaming capabilities:
- py-tgcalls ==
2.3.3 - ntgcalls ==
2.2.5
These dependencies can be installed using the optional calls extra group:
pip install "drygram[calls]"
Community
- Support Chat: DryGram Support Chat
- Updates Channel: DryGram Updates Channel
- GitHub Repository: GitHub Issues & Code
Special Thanks
- Telegram Team for providing public MTProto documentation and protocol specifications.
- The Python Open-Source Community for developing the underlying dependencies and testing systems that power modern async development.
- Contributors and community members helping review code and report issues.
Credits
- Designed and Developed by: Santhu
- Project Name: DryGram
- Source Code: TG-BOTSNETWORK/drygram
License
This project is licensed under the GNU General Public License v3.0.
Metadata
Release files for DryGram 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drygram-1.0.2.tar.gz | 142.6 kB | Without provenance | Details for drygram-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drygram-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for drygram-1.0.2-py3-none-any.whl |
Total release size: 261.6 kB
Release files / drygram-1.0.2.tar.gz
| Download URL | drygram-1.0.2.tar.gz |
|---|---|
| Size | 142.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5345d0d5f304479620adba7b67314dc88cde769b3124ee7a494dbb852733a19
|
|
BLAKE2b-256 checksum How to use checksums |
994b432d7ceef9b6bc02e91d5e734d8e22d5f88fe3b699fe65dfeeb5523d7ff4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / drygram-1.0.2-py3-none-any.whl
| Download URL | drygram-1.0.2-py3-none-any.whl |
|---|---|
| Size | 119.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f01abc4d7fca818137cf27fdafc8a8b59c2f0bfcd17605ed885425d1fabac33
|
|
BLAKE2b-256 checksum How to use checksums |
c67cdd39b914f411b290891047d1a0a5dbf868fcc819e867b207b8b37d19c722
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for DryGram 1.0.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.