Elegant, modern and asynchronous Telegram MTProto framework.
For users and bots · Python on top · Rust core underneath
Features · Install · Quick start · Rust core · Development
✦ About
cbgram is a modern, async-first framework for the Telegram MTProto API. Log in as a user account or run as a bot, and get full access to everything Telegram lets an official client do.
It is a drop-in replacement for Pyrogram: write from cbgram import ... in new code, and existing from pyrogram import ... codebases keep working unchanged, because both names resolve to the same module.
Under the hood, crypto and file transfers run in Rust through cbcrypto, while the API, handlers, sessions and types stay in friendly Python.
✦ Features
| Feature | ||
|---|---|---|
| 🔁 | Drop-in replacement | Migrate from Pyrogram with zero code changes. |
| 🆕 | Up to date | Gifts, Stories, Topics, Business Accounts, Giveaways and the latest Telegram layer. |
| ⚡ | Async natively | Fully async/await, and still usable synchronously via app.run(). |
| 🦀 | Rust core | MTProto crypto plus the file download and upload engine run in compiled Rust. |
| 🧩 | Type-hinted | Every type and method is annotated for great editor support. |
| 👤 | Users and bots | One framework for custom clients and bot identities. |
| 🔌 | Proxy support | Built on python-socks with asyncio. |
| 🗄️ | Flexible storage | SQLite sessions by default, with optional Mongo and Redis extras. |
| 🚀 | Optional speed-ups | Add uvloop on Linux and macOS with a single extra. |
✦ Install
Latest from GitHub
pip install git+https://github.com/abhiadi23/cbgram.git@main
With uvloop (Linux · macOS)
pip install "cbgram[fast] @ git+https://github.com/abhiadi23/cbgram.git@main"
In requirements.txt
cbgram @ git+https://github.com/abhiadi23/cbgram.git@main
Requires Python 3.10+ and cbcrypto. It is installed automatically as a dependency, and cbgram will not start without it.
Optional extras
| Extra | Adds |
|---|---|
fast |
uvloop for a faster event loop |
mongo |
MongoDB storage via motor |
redis |
Redis storage |
✦ Quick start
A tiny greeter
from cbgram import Client, filters
app = Client("my_account")
@app.on_message(filters.private)
async def hello(client, message):
await message.reply("Hello from cbgram!")
app.run()
A bot with inline buttons
from cbgram import Client, filters
from cbgram.types import InlineKeyboardMarkup, InlineKeyboardButton
app = Client("my_bot")
@app.on_message(filters.command("start"))
async def start(client, message):
await message.reply(
"Choose an option:",
reply_markup=InlineKeyboardMarkup([
[
InlineKeyboardButton("Website", url="https://example.com"),
InlineKeyboardButton("Help", callback_data="help"),
],
[InlineKeyboardButton("About", callback_data="about")],
]),
)
app.run()
✦ The Rust core
Python where it is friendly, Rust where it counts.
| Python | Rust (cbcrypto) |
|
|---|---|---|
| Auth handshake, sessions, handlers, TL types, API methods | ✔ | |
| MTProto crypto (AES-IGE / CTR, KDF) | ✔ | |
File downloads (download_media) |
request logic, progress | sockets, transport, pacing, file writes |
File uploads (save_file by path) |
request logic, progress | same |
Anything the core cannot handle, such as proxies or in-memory targets, falls back to the original Python path, so nothing that worked before stops working.
What you actually gain: no GIL contention, real multi-core use and zero-copy file writes. It does not make Telegram or your network faster.
Handy switches
| Variable | Default | Meaning |
|---|---|---|
CBGRAM_RUST_CORE |
1 |
Set to 0 to force the pure-Python transfer path (debugging). |
CBGRAM_UVLOOP |
off | Set to 1 to use uvloop on Linux and macOS. |
CBCRYPTO_DEBUG |
off | Per-request engine trace on stderr. |
✦ Development
git clone https://github.com/abhiadi23/cbgram.git
cd cbgram
pip install uv
uv sync --frozen --extra dev
uv run poe api # generate TL API types
uv run poe test # run the tests
✦ Resources
- 💬 Source code
- 🐞 Issue tracker
- 🤝 Contributing guide
- 🔒 cbcrypto, the Rust crypto engine
✦ License
cbgram is released under the GNU LGPL v3 or later. See COPYING and COPYING.lesser.
Made with ♥ by abhiadi23
Metadata
Release files for cbgram 3.1.7
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 |
|---|---|---|---|---|
| cbgram-3.1.7.tar.gz | 980.4 kB | With provenance | Details for cbgram-3.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cbgram-3.1.7-py3-none-any.whl | Python 3 | none | any | Details for cbgram-3.1.7-py3-none-any.whl |
Total release size: 7.5 MB
Release files / cbgram-3.1.7.tar.gz
| Download URL | cbgram-3.1.7.tar.gz |
|---|---|
| Size | 980.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a8ad5e1b9e77c615612f9debce769bd415562dac93ea8d5a76e56f39ef2591c
|
|
BLAKE2b-256 checksum How to use checksums |
11c403737434cea1adc33765b192f77f980d28083c8cbe246e5a4225f3e9d4c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 24, 2026.
Transparency logRelease files / cbgram-3.1.7-py3-none-any.whl
| Download URL | cbgram-3.1.7-py3-none-any.whl |
|---|---|
| Size | 6.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe3ecbbc649ead37081a5db16ba76ddd5169d787c12f8907a2f60812d83487e6
|
|
BLAKE2b-256 checksum How to use checksums |
d33c9c0fe27953d156dbd50497ab2e530592bd48987e226776c642ace9747f0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 24, 2026.
Transparency logSecurity for cbgram 3.1.7
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cbgram-3.1.7.tar.gz
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 Nov 24, 2026.
Transparency logA 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.