Skip to main content

A modern, elegant, asynchronous MTProto framework for building Telegram clients and bots in Python.

Project description

ferogram-py

PyPI Python Downloads License Telegram

A modern, elegant, asynchronous MTProto framework for building Telegram user clients and bots in Python.

Powered by a high-performance Rust core that takes care of networking, encryption, TL parsing, and session management so you can focus on writing clean, idiomatic Python.


Why ferogram-py?

Most of the heavy lifting in an MTProto client happens behind the scenes; networking, encryption, TL parsing, and keeping up with updates. ferogram-py lets a Rust core handle all of that, while exposing a clean, Pythonic API.

For most applications, the high-level API is all you'll need. But if you want to use a brand-new Telegram feature or need something more advanced, you can always drop down to the raw MTProto API and invoke requests directly.

The goal is to stay out of your way: simple things should be simple, and advanced things should still be possible.

Quick API reference: FEATURES.md


Install

pip install ferogram
Building from source
make dev      # editable install into .venv (builds the Rust extension)
make build    # release wheel for this machine
make codegen  # regenerate TL code without a Rust rebuild
make test     # run tests
make clean    # wipe .venv, target, dist, generated/

On Termux: pkg install rust clang python first. Rust-only change, don't want to wait on codegen: FEROGRAM_SKIP_CODEGEN=1 maturin develop


Quick start

Bot:

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

User:

import asyncio
from ferogram import Client

app = Client("myaccount", api_id=0, api_hash="", phone="+1234567890")

async def main():
    async with app as client:
        await client.send_message("me", "logged in")

asyncio.run(main())

Credentials also work from env vars: API_ID, API_HASH, BOT_TOKEN.

Logging

import ferogram.logging as fero_log

fero_log.setup()           # INFO to stderr
fero_log.setup(level=10)   # DEBUG

Architecture

architecture

The compiled extension (_ferogram.so) stays deliberately small: networking, encryption, session storage, and MTProto internals live in Rust. Everything you touch day to day, the client, handlers, filters, is plain Python and can change without a recompile.

Prebuilt Wheels for your platform

Wheels ship prebuilt for Linux (x86_64, aarch64), macOS (x86_64, arm64), Windows (x86_64), and Android/Termux (aarch64, x86_64). pip install ferogram grabs the right one on its own.


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 for commercial use, provided the original license and copyright notice are included.

See LICENSE-MIT and LICENSE-APACHE for full details.


Developer

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, bugs report and feedback are always welcome. As the project grows, we'll eventually split Python and Rust discussions into dedicated spaces.

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.3.tar.gz (675.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.3-cp39-abi3-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

ferogram-0.5.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.0 MB view details)

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

ferogram-0.5.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

ferogram-0.5.3-cp39-abi3-macosx_11_0_arm64.whl (5.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ferogram-0.5.3-cp39-abi3-macosx_10_12_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

ferogram-0.5.3-cp39-abi3-android_24_x86_64.whl (5.8 MB view details)

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

ferogram-0.5.3-cp39-abi3-android_24_x86.whl (5.7 MB view details)

Uploaded Android API level 24+ x86CPython 3.9+

ferogram-0.5.3-cp39-abi3-android_24_armeabi_v7a.whl (5.1 MB view details)

Uploaded Android API level 24+ ARM EABI v7aCPython 3.9+

ferogram-0.5.3-cp39-abi3-android_24_arm64_v8a.whl (5.5 MB view details)

Uploaded Android API level 24+ ARM64 v8aCPython 3.9+

File details

Details for the file ferogram-0.5.3.tar.gz.

File metadata

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

File hashes

Hashes for ferogram-0.5.3.tar.gz
Algorithm Hash digest
SHA256 9382eacdbe5f73ab038907fa3d0850b33543ffcbc8e8a4ffda61f8df37bbcc04
MD5 31bc26286540842f47306c43107fe994
BLAKE2b-256 688c619a8e98ebce22ebce08d6c2ef838f4ef40d000f59fe59bfc1c0f87fe5b1

See more details on using hashes here.

File details

Details for the file ferogram-0.5.3-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: ferogram-0.5.3-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.3 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8d56740993a26d977c590c9aa61c79f72ab27cc50b60ebd1880e8cf9f233a312
MD5 0c5f826e1e4bb8ace438f6b9e86b959d
BLAKE2b-256 0800011fa6c7a0810743655399ffcf4098eb8e94f72608ad69c42a9443616189

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0eeb10ebcecc3f2331d1837344b43df54a81258547a0558b1e340a689c29b3ce
MD5 e5a7f5fb270bf9e956b623b4f0b86412
BLAKE2b-256 9f2edbaad51b355361a6d67928f7c7179db90749a998a2fd72cf2647f8bddac3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e9010b969f24478fb7d353d81541f1b7f6c34d85af04236dc0e14a22d0b6a746
MD5 13b7a77ad7adf035593e235f10797980
BLAKE2b-256 998e591ca10469f4ee05b90e4ce9675912f9e784e3422441de452f52c48baa81

See more details on using hashes here.

File details

Details for the file ferogram-0.5.3-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5728566f58a4bb2fdcbdfa667a90bae759444f3107fe0a11bb74fdc3c5f8279
MD5 e7470af7883699cdeecb2b77744ae0ba
BLAKE2b-256 10407e017c8704ccf9808fed1741cac00ea66eeb73d4c0ed0c54196be1ffc925

See more details on using hashes here.

File details

Details for the file ferogram-0.5.3-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fd68d63ca81b5c53b31392d9ed736b83c4bf76fb1903895e40ec4cd7626ed532
MD5 8ef77414f863dd51d180cb8ef99fd68b
BLAKE2b-256 c97f2f12a773e27294e5b9a0f314cff7b34c71411eca50d769bd27d38eb4bc98

See more details on using hashes here.

File details

Details for the file ferogram-0.5.3-cp39-abi3-android_24_x86_64.whl.

File metadata

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-android_24_x86_64.whl
Algorithm Hash digest
SHA256 09276d5ca74efee7b965441eebe7867a2054f69dcfa4b94022f1cd643d445ec9
MD5 0cb023a4e9bbb316518796c4a12eed47
BLAKE2b-256 e45d6bac0dab08c2c848942c38c9e9740823dd47b51756c4924229ed5a30ee39

See more details on using hashes here.

File details

Details for the file ferogram-0.5.3-cp39-abi3-android_24_x86.whl.

File metadata

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-android_24_x86.whl
Algorithm Hash digest
SHA256 873e421552bf4264525d24534507da563b9345cedc8528b5087b16fb84ea7d12
MD5 9fba0599c7e5524e16c238465372c605
BLAKE2b-256 ef9ef3afa2e9bc55df527bb25e61c3613c99aa51784fefcaa5c444c8db080df3

See more details on using hashes here.

File details

Details for the file ferogram-0.5.3-cp39-abi3-android_24_armeabi_v7a.whl.

File metadata

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-android_24_armeabi_v7a.whl
Algorithm Hash digest
SHA256 b422800c8c5e971a6c40decd7cb857057b08ef508591dae71c4f9e5f25b1639c
MD5 59864e66398b7c4e2e31abbc1b14fc0f
BLAKE2b-256 27be0fc7525b93cdab5358c10ff9df1298f7ca4afbe45319dff8580ef4fcc8af

See more details on using hashes here.

File details

Details for the file ferogram-0.5.3-cp39-abi3-android_24_arm64_v8a.whl.

File metadata

File hashes

Hashes for ferogram-0.5.3-cp39-abi3-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 4f7b1cd486fe4a566979b163ad8bb8a3e4bb30448b918306a3b58d2a92e689ad
MD5 86a2e1a05388cfd7429c53311a51ffd7
BLAKE2b-256 13ef359df03943d24148ef8304704735069496f9a7e41fd8a7c976f9c200e043

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