Skip to main content

A modern, elegant, asynchronous MTProto framework for building Telegram user 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.2b2.tar.gz (656.2 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.2b2-cp39-abi3-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

ferogram-0.5.2b2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5 MB view details)

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

ferogram-0.5.2b2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

ferogram-0.5.2b2-cp39-abi3-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ferogram-0.5.2b2-cp39-abi3-macosx_10_12_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

ferogram-0.5.2b2-cp39-abi3-android_24_x86_64.whl (4.4 MB view details)

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

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

Uploaded Android API level 24+ x86CPython 3.9+

ferogram-0.5.2b2-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.2b2-cp39-abi3-android_24_arm64_v8a.whl (4.2 MB view details)

Uploaded Android API level 24+ ARM64 v8aCPython 3.9+

File details

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

File metadata

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

File hashes

Hashes for ferogram-0.5.2b2.tar.gz
Algorithm Hash digest
SHA256 a95ae755dafbc9575948b312d0f6bdc74a9cf4f79e755e275ee5b579df76cb61
MD5 2bfb74cada616d05f9082996f8f503d1
BLAKE2b-256 89b23ea2cdc0a13fe131adde77646680a63768b2b0b3a9849684f8534e447387

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 32032145e0d7da44bc23979712ce29344641522710590ba9f03a449990b04341
MD5 510aa19e6200692b3ed90b95c368f933
BLAKE2b-256 b41546159ac02fc6ecece5aa3080a7174833ee7e5bf5527a8e798842c755a887

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb086a465de6ca93431d552861fd0e286f00c7cb8dcfe099163380c763bdbf5f
MD5 c67b200d4dc23fac15a3342b56fae876
BLAKE2b-256 f955e3073509b9007331be589f93e3a5155043c55f8f49db74a516d668137608

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b6cafb895a10bd80626833e9d3c21e1c10185ffeeecec941e451cd670f6d6aa6
MD5 82e8c43fccda22723aad23a5a4938bf1
BLAKE2b-256 54493b4045195fc21fa0e8a24b69d533046e6d21d3afa0433de9ef606534b192

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d2dde9a9d220e88025cfb46887403b339764a073700bfc0973a7a75004ce66b5
MD5 4d9c325435bf4a7a7d38be9355ab9db3
BLAKE2b-256 79b4f40dad17295e3ce9ac19e73f6eb457946eae262adf582b1c1548b27c52ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f36e9b8ed999d15839fc8149a2c099183ce0ee8c5d3c03410922bd0e64e3c823
MD5 129e5e1742619d8cc3d9347299e24f11
BLAKE2b-256 769e62d69cdd7a74c72eae87c2faa0164fc19a244dd5f3fd99341599e854f8f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-android_24_x86_64.whl
Algorithm Hash digest
SHA256 168745c94592422986e65239c5525f449d94dc22258b6c87486e5226dbfbe1b0
MD5 a88d192a30a7c7e89b274a5424f1387e
BLAKE2b-256 802fd458d3578ffae0749bcb13344db20afac74dd2802cf34b234b0364691e6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-android_24_x86.whl
Algorithm Hash digest
SHA256 8b00c7cb5d526346649fe926d517e9d62aca614087014163b0ef63cc151ec1bd
MD5 85d675e58e3a4b54f6ff44f4f3976dc5
BLAKE2b-256 44f199d02923abd3ff735990682070fb3d4efa55aceae4dac96273955b195faf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-android_24_armeabi_v7a.whl
Algorithm Hash digest
SHA256 6f73b65614c9b733b0d08565ab6d8ce83b2472c3225adcdbb10723a84cfd83b1
MD5 a31fab260a1641bf7c6fe70eac560162
BLAKE2b-256 c7c23f3983f3fda4b825400513c0e383b844476190e34c5d1a1c35209b484973

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b2-cp39-abi3-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 eb6eb4927f070cf9e1b3b1e9a1969c3c153f2bacd0a1710a6537548b86968bd9
MD5 d0585e761951ebfc1307aa58831084e7
BLAKE2b-256 62f53bc330e4bf3482f1536198cc8e9b7a99d7286af8aa6b317f752237881d7b

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