A Python MTProto library powered by the Rust-based ferogram engine, delivering near-native performance with minimal Python overhead.
Built with PyO3 and maturin. Works on Linux, macOS, Windows, and Android (Termux).
ferogram-py combines Python's simplicity with the speed and efficiency of a native Rust implementation.
Performance-critical components such as networking, encryption, session management, and MTProto internals run natively in Rust, reducing Python overhead while exposing a clean and Pythonic API.
Whether you're building userbots, bots, or automation tools, ferogram-py provides both high-level abstractions and direct access to raw Telegram APIs when needed.
Quick API reference: FEATURES.md
pip install ferogramPre-built wheels are available for Linux (x86_64, aarch64), macOS (x86_64, arm64), Windows (x86_64), and Android/Termux (aarch64, x86_64).
pip install ferogram picks the correct wheel automatically.
Clone the repository, then run:
make dev # editable install into .venv (builds Rust extension)
make build # release wheel for this machine
make codegen # regen TL generated code without a Rust build
make test # run tests
make clean # remove .venv, target, dist, generated/Termux prerequisites: pkg install rust clang python
To skip TL codegen on a Rust-only change: FEROGRAM_SKIP_CODEGEN=1 maturin develop
from ferogram import Client, filters
app = Client("mybot", api_id=0, api_hash="", bot_token="123:TOKEN")
@app.on_message(filters.command("start"))
async def start(client, message):
await message.reply("Hello!")
app.run()Credentials can also come from env vars: API_ID, API_HASH, BOT_TOKEN.
import ferogram.logging as fero_log
fero_log.setup() # INFO to stderr
fero_log.setup(level=10) # DEBUGThe compiled extension (_ferogram.so) is intentionally minimal. Networking, encryption, session management, and MTProto internals are implemented in Rust, while the high-level API remains entirely in Python and can be updated without recompiling rust core.
This project is dual-licensed under:
- MIT License
- Apache License 2.0
You may choose either license.
You are free to use, modify, and distribute this software, including for commercial use, provided the original license and copyright notice are included.
See LICENSE-MIT and LICENSE-APACHE for full details.
Developed by Ankit Chaubey
Don't forget to explore the Rust engine powering ferogram-py: ferogram. Thanks for being part of the journey.
Join the ferogram community! Questions, discussions, and feedback are always welcome. As the project grows, we'll eventually split Python and Rust discussions into dedicated spaces.
-
Channel (releases & announcements): @Ferogram
-
(questions & discussion): @FerogramChat