Python wrapper for ferogram, blazing-fast Rust MTProto library for Telegram.
Project description
ferogram-py
Python bindings for ferogram, a Telegram MTProto client written in Rust.
Built with PyO3 and maturin. Works on Linux, macOS, Windows, and Android (Termux).
What is ferogram-py?
ferogram-py is a Python interface for the ferogram MTProto client.
It uses a Rust core for networking, encryption, session handling, and updates, while exposing a simple async Python API on top.
You can use it to build userbots, bots, or automation tools with access to both high-level methods and raw Telegram APIs.
The Rust core handles crypto, transport, session management, and update processing. The Python layer provides async/await methods and decorator-based event handlers with minimal overhead.
Full API reference: FEATURES.md
Install
pip install ferogram
Pre-built wheels are available for:
| Platform | Arch |
|---|---|
| Linux (manylinux) | x86_64, aarch64 |
| macOS | x86_64, arm64 |
| Windows | x86_64 |
| Android / Termux | aarch64, x86_64 |
On Termux, pip install ferogram picks the correct Android wheel automatically.
Force local build
If the pre-built wheel does not work, or you want to compile for your exact machine:
# from PyPI source
pip install ferogram --no-binary ferogram
# from cloned repo
git clone https://github.com/ankit-chaubey/ferogram-py
cd ferogram-py
pip install . --no-binary ferogram
Termux source build prerequisites:
pkg install rust clang python
pip install ferogram --no-binary ferogram
Quick start
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.
Client setup
from ferogram import Client
app = Client(
session="mybot", # session file name (no extension)
api_id=123456,
api_hash="abc...",
bot_token="123:TOKEN", # omit for userbot
)
app.run() # blocking; starts and loops forever
# or
await app.start()
await app.run_until_disconnected()
# or as context manager
async with app as client:
...
Session is created on first run and reused automatically.
Raw API
Use client.raw for convenience. Use class-based calls only when you need full control.
Preferred (namespace proxy, peer strings auto-resolve):
result = await client.raw.messages.GetHistory(peer="@durov", limit=5)
result = await client.raw.messages.SendMessage(peer="@user", message="hi")
Class-based (full control):
from ferogram.raw.generated.functions.messages import GetHistory
result = await client.invoke(GetHistory(
peer=await client.resolve_peer("@durov"),
offset_id=0, offset_date=0, add_offset=0,
limit=5, max_id=0, min_id=0, hash=0,
))
# shorthand
result = await client(GetHistory(...))
Results are low-level TL objects (or dict-like structures) matching the Telegram schema. The generated/ directory is internal codegen output. Direct imports from it are considered advanced usage and may change.
All functions and types are available. See FEATURES.md for all import styles.
Userbot
from ferogram import Client, filters
app = Client("session", api_id=123456, api_hash="abc123")
@app.on_message(filters.private, filters.incoming, filters.text)
async def echo(client, message):
await message.reply(message.text)
app.run()
Logging
import ferogram.logging as fero_log
fero_log.setup() # INFO to stderr
fero_log.setup(level=10) # DEBUG
Architecture
Python caller
| asyncio await
v
ferogram-py (PyO3 .so extension)
| FFI, Rust holds GIL only at call boundary
v
ferogram (Rust, tokio async runtime)
| TCP / TLS
v
Telegram MTProto
License
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 commercial use), provided that the original license and copyright notice are included.
See LICENSE-MIT and LICENSE-APACHE for full details.
Developed by Ankit Chaubey
⭐ Star this repo if you find it useful
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ferogram-0.3.0.tar.gz.
File metadata
- Download URL: ferogram-0.3.0.tar.gz
- Upload date:
- Size: 444.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c850d8a0c744cca9d110dca5a9159afcbda9f141dd9aab4e18260b66ec15e4ad
|
|
| MD5 |
fa64f14c0ea291216a67e660025744f6
|
|
| BLAKE2b-256 |
1073e103acca825f2f25220a8552c27506037ee809cd39372e96de5ace42c294
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-win_amd64.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-win_amd64.whl
- Upload date:
- Size: 11.1 MB
- Tags: CPython 3.13+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c7ace55e453cc8c4a851d9c6d8536adf4fabb756e2a8793a7e94115813f8c47
|
|
| MD5 |
8d798dc880dc3a7a0c7ef0b802d255b2
|
|
| BLAKE2b-256 |
44ecc68387a432336ad97ff060d483360e1610f8cd099680ade89d703ee291ac
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 8.8 MB
- Tags: CPython 3.13+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00fbf5d2f2feca162ae2fa85d2628c932ba471a32ec0c76f4938f8068e321bce
|
|
| MD5 |
164cfbf4eface4f9baea77993e23159f
|
|
| BLAKE2b-256 |
b40872066707092c18103d1765a0e2b687d4bb283ff352a1e41d4aacf2c1a79a
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.13+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c4bab365b0cae009f6628b2bbb2f284373e3a32a0c6406793baa65d0218d792
|
|
| MD5 |
d383e66e9365b85c4266d35525704990
|
|
| BLAKE2b-256 |
ab6e649b37ede433237526ad9f378c56b1d4138dc858967a4d5ad3e4e1fcdbbe
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.1 MB
- Tags: CPython 3.13+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e8002cb7154898b3ae847502300da2c9f8c42bb346d7d313827d0981684aa2a
|
|
| MD5 |
1098aba110e9fc7d75a222462a1863e8
|
|
| BLAKE2b-256 |
3a7047f8fcc495deeaa3fdc9de56cfafe10097798aea703281b8cfeae38baa64
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.13+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd4bfd8c4cd19318ed09b808d10343aae5e7452696554531f9b65fc1c9bac93d
|
|
| MD5 |
52c641cf6f519685ed506945df3c8a09
|
|
| BLAKE2b-256 |
16d903be0a17017d645dcb67c9cb8b1406b927709a847ec60cdea4f47a752577
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-android_24_x86_64.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-android_24_x86_64.whl
- Upload date:
- Size: 8.8 MB
- Tags: Android API level 24+ x86-64, CPython 3.13+
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d04b2b2d2b58d4e4e821c1681df5e3de94266f74b6ddd15b7ed1a2c42d2ca0ee
|
|
| MD5 |
0585d5e9558b14b848b1a1584b99097b
|
|
| BLAKE2b-256 |
1fd741066d774949238b98243326a40919563f17489bdd0bd717136f7ffeb5f2
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-android_24_x86.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-android_24_x86.whl
- Upload date:
- Size: 8.2 MB
- Tags: Android API level 24+ x86, CPython 3.13+
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8368467b913d9b31736e3cef30bdfa93140bb2082dadb9a838954017d47e2986
|
|
| MD5 |
a1d998d0183cc47b864b488763987002
|
|
| BLAKE2b-256 |
395303eb2a57689e69185f681d59440db28536cf9948f343d344f24dab871c34
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-android_24_armeabi_v7a.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-android_24_armeabi_v7a.whl
- Upload date:
- Size: 7.3 MB
- Tags: Android API level 24+ ARM EABI v7a, CPython 3.13+
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9bd17ee988817681d3051b89df9dcafeebf1f6d9e9356156a779c7e489b1665
|
|
| MD5 |
5c715b3abedf939719c08b4a905bfddf
|
|
| BLAKE2b-256 |
56fa37c31427f1010cefb09313f95d522fdceba2dd113b6870a8f03b4a986bb2
|
File details
Details for the file ferogram-0.3.0-cp313-abi3-android_24_arm64_v8a.whl.
File metadata
- Download URL: ferogram-0.3.0-cp313-abi3-android_24_arm64_v8a.whl
- Upload date:
- Size: 8.2 MB
- Tags: Android API level 24+ ARM64 v8a, CPython 3.13+
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c34cb9c6c428e82cfd3c65f59b6edd786ab35c98c32b1f714f409205c0abfadc
|
|
| MD5 |
f9f59744dcd452f019ccb897b71593d8
|
|
| BLAKE2b-256 |
c47e0eab83ab6d0977a7ce2377d7025ffacebae6a8b3f3e63f09dd1ba4c7d6ce
|