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

Uploaded CPython 3.9+Windows x86-64

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

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

ferogram-0.5.3b1-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.3b1-cp39-abi3-macosx_11_0_arm64.whl (5.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ferogram-0.5.3b1-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.3b1-cp39-abi3-android_24_x86_64.whl (5.8 MB view details)

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

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

Uploaded Android API level 24+ x86CPython 3.9+

ferogram-0.5.3b1-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.3b1-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.3b1.tar.gz.

File metadata

  • Download URL: ferogram-0.5.3b1.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.3b1.tar.gz
Algorithm Hash digest
SHA256 865491df175e7099a370717e8de8c954207b33c900a03782124b4a86aebff73b
MD5 3e8057dbfac6769c0db3f49f13076772
BLAKE2b-256 7172faab9f4495cd08b18566cd2e903f04686a55810e0bc8e542bc00bfec2e8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cacdb84a8ea86d5bbdfbc081560fa577458409e72ead060c388e4800f63577f8
MD5 1e5cab34b4de12857d54fbeb17b77127
BLAKE2b-256 b773ab708959c449fc323b6f9da34d893224eb8f6746442e7abc1c6a928456b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 afd263cf4213d4fc6f07e675e59ae9e192db7428153f21c537fc2141c01f6ddb
MD5 51efae32c7a56579af842c12b8a47eac
BLAKE2b-256 05ca6308596db2331760906c4138ffd86c8319ebe2f7f80a00f170d831ec670f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 18fab7d931d3d1b500c2ff6167d15756a755024bd6c8550df42074767596c74d
MD5 29fce234e8ee8d2def12240cbc870383
BLAKE2b-256 cb656530c7f9c1e08355748ed06a9a2f870fc1720c6efee73934621b9c0a1c57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8153a1286ea319875142ed6aaac2aefa1cc0095db5a1c268a587fa30aaff14cf
MD5 831f43818952544a6f4f33aec508d466
BLAKE2b-256 62d46416e69949cde2f1f06d309ce98127965c8d67a782dc9cd8cd179d77844a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 def48e37f64943af8eb9a8404686428bd6e57a6116ff4eedcb61b76279339ea6
MD5 d24d2d044043ed28765bf3b0c5274523
BLAKE2b-256 31f08ebbe6d2462b129b1601b79ad2820df6a30924af759bac6881e0689bad65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-android_24_x86_64.whl
Algorithm Hash digest
SHA256 dfc6a6c648062b2822370187d2fdf8b1c91d9a032fa652a2de4b1a5e6941fc81
MD5 44af0cfd46e32018346663b9b3400f1c
BLAKE2b-256 f50fd7bce35443eb923d5f852ac495db9118f6e8f56c72aab5bc4951791286c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-android_24_x86.whl
Algorithm Hash digest
SHA256 6cda03c7eb92bdc3a15656909325dc10319086785d62523779f58a7620f8f8f2
MD5 cd16a0f06fa5ecb1e3169df582ba1728
BLAKE2b-256 f9f10084d381828a76c11762eba20c21091f931f1eb596401b52a16b4ba4f321

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-android_24_armeabi_v7a.whl
Algorithm Hash digest
SHA256 724fac9e163a1fb1baa62c01b8d45c475f1d6b6b1795e9ab1eba0369758c2cd0
MD5 d708afdb1e482f049802e9f0e5529524
BLAKE2b-256 0c66991a7e8aabc9f295b8972d621bfc38cb4beda69718b7fe5193ed2f87d153

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.3b1-cp39-abi3-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 10e46a361a76458848aa567e4799f29a882b1bab43e15a2ecbe97ab5e08a3bb7
MD5 75953d44794e4b2564ab268461462564
BLAKE2b-256 745eab3b188ab69d0177a6e14de75ab4c2c10f5f14ad3cb93cded0a82e1feddb

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