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.0b1.tar.gz (606.3 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.0b1-cp39-abi3-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.9+Windows x86-64

ferogram-0.5.0b1-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.0b1-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.0b1-cp39-abi3-macosx_11_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ferogram-0.5.0b1-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.0b1-cp39-abi3-android_24_x86_64.whl (4.3 MB view details)

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

ferogram-0.5.0b1-cp39-abi3-android_24_x86.whl (4.2 MB view details)

Uploaded Android API level 24+ x86CPython 3.9+

ferogram-0.5.0b1-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.0b1-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.0b1.tar.gz.

File metadata

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

File hashes

Hashes for ferogram-0.5.0b1.tar.gz
Algorithm Hash digest
SHA256 20e8ad2fbab117e5bc6f9fa2dacb3bdca5eb19ac34c92f361f6ecfe6784b9c12
MD5 b50fbf4ee9086d834a5f14997338d9b9
BLAKE2b-256 40011670770d792e20e4cb62fc8512f5111c4bccffe1b81ddc7cf1b90e3f789f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ebd37b1c915dcd3839e7ba1fd3a03b97a7fe35aed34cdea6ce03dd3669ed677e
MD5 1ddb708507a116c48734289157e6df5b
BLAKE2b-256 4b723f89bdbf449ace25f115f824dc143614a1fb08a73be3487d1d380a0d4f28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce750a8a8f02dc08092f8eb7927634d517bfa9897f7c72c3a378e35a3f041710
MD5 25c7992643d1948a1ca11b14009220df
BLAKE2b-256 b87f0b718c7e3b6932a4da534844a547836d6d81117bdae5c68238dc7ca1baeb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ecc830a7af5aeaec6b4198b24601dfd9ca2ac88333b68e98948f202c593f6e02
MD5 ebdba2d2051484e7a8a61510e6cfb691
BLAKE2b-256 d0f11d0e6be73f3d7cccae8f776d296dd4cf801b439fc1a7e449b522a8527fc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92b33f4f3722dcc6c178c9457358befefd54fd1fc48d59f03243ce154f0f251d
MD5 3fbb2401cb1bc10b9d4c890429fdce6e
BLAKE2b-256 2a1f51f28222877ee8bef465d3446e22deab2f3eec06ab05635cc56a500e98be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1c2f224e6bdb48e620ba6a563147f9da6ebf7407988111bd9e1194d138bc7240
MD5 c6c74dec2cdafd6fc54ec0fc4a3b0c18
BLAKE2b-256 959207596e74ebd233190e3dc65612cd64da8818866208f4f3c4f0a35b15bf95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-android_24_x86_64.whl
Algorithm Hash digest
SHA256 2c5eda26dc08ec8fec50d37d85e85c51d1b65bfd6c7156476ac62f0b5f5f946f
MD5 f10e387269d2dc77265b44933efeec55
BLAKE2b-256 ed986b0ed9eaaa73476dce179dcdda2b14cc05469d2e23f87a864f04343c63f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-android_24_x86.whl
Algorithm Hash digest
SHA256 5c14759eaba340bf715fe79fa063cd89678802dfa1c7541ddb6c64af6430fde4
MD5 a97723973f5971097abc55a3373115f5
BLAKE2b-256 a438939bcefa40d0894afdc4c08bfd451b0b108017280a4c810f5012e4eeffdd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-android_24_armeabi_v7a.whl
Algorithm Hash digest
SHA256 a1700ed84f8e191849cdac44a85bc4d95c02b9aebeb27284cccc0e1447272013
MD5 ad37fcca461544aa8cde5f7801e42926
BLAKE2b-256 b581eb5e1d67ed60c0226396fe935693605fde4a2bad12da1e34cd98abac0689

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.0b1-cp39-abi3-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 5a85caab36a430967ce9267d1646cadae42f1df97a8d073431dc8ead44a25d16
MD5 6c4b1cc362ff76f28a283ae6bea630bd
BLAKE2b-256 d2ab3395da4a83d7700d5798a5b39130a15c38d138323fba604d11c4debb2c62

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