Skip to main content

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.

ferogram-py keeps the Telegram-specific work in a Rust core and exposes a small async Python layer on top. That gives you a Python-friendly API for bots, userbots, and automation, while the heavy lifting stays in Rust.

Highlights

  • Rust-powered MTProto transport, encryption, sessions, and update handling
  • Async Python API with decorators and raw TL access
  • Session backends for files, SQLite, memory, StringSession, libSQL, and custom stores
  • High-level helpers for messages, media, chats, polls, inline bots, privacy, and bot management
  • Prebuilt wheels for Linux, macOS, Windows, and Android/Termux

Install

pip install ferogram

Prebuilt wheels are available for:

Platform Arch
Linux (manylinux) x86_64, aarch64
macOS x86_64, arm64
Windows x86_64
Android / Termux aarch64, x86_64

If you need a local build:

pip install ferogram --no-binary ferogram

On Termux:

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 client.send_message(message.chat_id, "Hello!")

app.run()

Credentials can also come from environment variables:

  • API_ID
  • API_HASH
  • BOT_TOKEN

Client setup

from ferogram import Client

app = Client(
    session="mybot",       # session file name, or a session object
    api_id=123456,
    api_hash="abc...",
    bot_token="123:TOKEN", # omit for userbot
)

app.run()
# or
await app.start()
await app.run_until_disconnected()
# or
async with app as client:
    ...

Raw API

Use client.raw when you want a convenient proxy for TL methods.

result = await client.raw.messages.GetHistory(peer="@durov", limit=5)
result = await client.raw.messages.SendMessage(peer="@user", message="hi")

For explicit control, import generated classes directly:

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,
))

Architecture

Python caller
   ↓ await
ferogram-py (PyO3 extension)
   ↓ FFI
ferogram (Rust / tokio)
   ↓ TCP / TLS
Telegram MTProto

License

Dual-licensed under MIT or Apache 2.0.

Developed by Ankit Chaubey

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ferogram-0.5.0b2.tar.gz (624.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ferogram-0.5.0b2-cp39-abi3-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.9+Windows x86-64

ferogram-0.5.0b2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

ferogram-0.5.0b2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

ferogram-0.5.0b2-cp39-abi3-macosx_11_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ferogram-0.5.0b2-cp39-abi3-macosx_10_12_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

ferogram-0.5.0b2-cp39-abi3-android_24_x86_64.whl (4.3 MB view details)

Uploaded Android API level 24+ x86-64CPython 3.9+

ferogram-0.5.0b2-cp39-abi3-android_24_x86.whl (4.3 MB view details)

Uploaded Android API level 24+ x86CPython 3.9+

ferogram-0.5.0b2-cp39-abi3-android_24_armeabi_v7a.whl (3.8 MB view details)

Uploaded Android API level 24+ ARM EABI v7aCPython 3.9+

ferogram-0.5.0b2-cp39-abi3-android_24_arm64_v8a.whl (4.1 MB view details)

Uploaded Android API level 24+ ARM64 v8aCPython 3.9+

File details

Details for the file ferogram-0.5.0b2.tar.gz.

File metadata

  • Download URL: ferogram-0.5.0b2.tar.gz
  • Upload date:
  • Size: 624.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for ferogram-0.5.0b2.tar.gz
Algorithm Hash digest
SHA256 f68ba9e37c676e85bfe002cb654460a390258b4be32a92340b1ac322ef6267a4
MD5 31a447fa545274b9d8c5b7d5482ea9a6
BLAKE2b-256 da6c37dd2f1bfef90cda27cee38f5e61b52c91073f87f6193c0310de5a2e68d5

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0d96a491debbb92566ffc0e8387e97b0419cab6e2a2eb3bb30a77c4e01c801db
MD5 b932fd43072c608ff2a4837a8fd03e9a
BLAKE2b-256 fbc41c1e88cb47ca9586cdd4678a85eac64bd310ca251ea75ed1de28f1c2889f

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61df4bef74199678605fb1070e7e893c2ebb95c45c0749b1826cc5c8209c6b31
MD5 826047b97e7a152c750ed46dd6f78144
BLAKE2b-256 f791366f8a088412957502bddf5425f8d07ceb87b2197b557f1e4efb0a2493f9

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9de1d7fe02a8b33d5c02de28f3ed8f59438c1e613a61486f8f1b6546dcb6c0ca
MD5 e9dd9d40bfcd0a0ff8a04f7851864660
BLAKE2b-256 051309e2c849e63485290fecf573186ca07c70cf9fe66367462d2c0a0f149520

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7428d9756874a0195983f64b03e98dceef1d667de41cd47d3dd1688649580d43
MD5 2759b8a421cf8a90569841616f06c97e
BLAKE2b-256 cec3e962313058bbec104d8dae999bc49e90994781a4aedafe56aadebfa10c58

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3f9b570050adc96e676957d8df2eefe6e31c2d437c3b21d64f9e1e1759d600fb
MD5 10459d94249ba899e2bbfcc1f7cd31db
BLAKE2b-256 07648aa0196df5616ab6a04454d41177f444a456f58c9cef3a83e40301e764f1

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-android_24_x86_64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-android_24_x86_64.whl
Algorithm Hash digest
SHA256 6ec189abde0f0f43c4936dee2cdb91e8e4159746388f977e8a44c579e52e1c66
MD5 076c61d5cfe326ca5412a0594ecface2
BLAKE2b-256 a31ea561b7ef9427131457fae7c137fb7fe8218c145110626586d663c07f2a86

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-android_24_x86.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-android_24_x86.whl
Algorithm Hash digest
SHA256 10d0a1d6bb15c278e108b93f7fa28397426f1ab5a6fec2c76b88dddd6341cd64
MD5 5b1c48b06ea0281a5d9411bcb1f0e9e1
BLAKE2b-256 6701c2f7dd61e89587dec3f96eacb621f6724919427c9e54345a256095fd48e0

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-android_24_armeabi_v7a.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-android_24_armeabi_v7a.whl
Algorithm Hash digest
SHA256 10dff6aaa606010d50f6d15bbe0aba64a7fd2febf54de5f62802d5596d320379
MD5 a452ff6f56a74de5d9e4a21c00ba6e15
BLAKE2b-256 7dfa6cfe584164917183a78de30c45fd6890766a6a3939d3faf2c19e55bd7d39

See more details on using hashes here.

File details

Details for the file ferogram-0.5.0b2-cp39-abi3-android_24_arm64_v8a.whl.

File metadata

File hashes

Hashes for ferogram-0.5.0b2-cp39-abi3-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 5fd19a56aedddae8570e170797ebb734553c288a863cfa403a83dc3d298f6ddd
MD5 a60aa54ea9c52b2ff25823660dacfcbf
BLAKE2b-256 c16a24f45cebcd94f835423d07ff766b83d8d9df10afe2a95050f5f5002637c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page