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.2.tar.gz (650.4 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.2-cp39-abi3-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

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

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

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

Uploaded Android API level 24+ x86CPython 3.9+

ferogram-0.5.2-cp39-abi3-android_24_armeabi_v7a.whl (3.9 MB view details)

Uploaded Android API level 24+ ARM EABI v7aCPython 3.9+

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

Uploaded Android API level 24+ ARM64 v8aCPython 3.9+

File details

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

File metadata

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

File hashes

Hashes for ferogram-0.5.2.tar.gz
Algorithm Hash digest
SHA256 c99a9a16cf29250de1d6bf6392917d4b159c3d7bcdd0440e284885739c285d6f
MD5 27dd58a3005bbfa4f72e0b05958d15b8
BLAKE2b-256 0fb9a4e119e9255080dd4668c7b6a1ab7d8a70cf57f46fbd35f4bbcbe8de22a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ferogram-0.5.2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.6 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.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a0d5c6f07a76c404053977a2d365a2cdd9b13108320417da9835e1b9ebabbcb9
MD5 6ee082a4ed6524b71307c694501cfcd0
BLAKE2b-256 021684f03bc5085386739104c98e74e11a14e1a391179a166f5b2bf6ab7c7b4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d0c23fb5b366657de8ffa982188537d3f957894b3a98c451ac9de147c3792f56
MD5 3fe31960f22496bb5e3b9293acbefb62
BLAKE2b-256 652d9b173ea4b9741c1561696dd7312a1250c697cc2dcccfd77ada8d6bcf3913

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8cbd788d7000ad46198648ca4de79a88c09c703081dd8b9d3c19ba7876d9de8f
MD5 93bcf26133ccdc12bb0ef209816e1100
BLAKE2b-256 8373a1d62271a6623b2f646ce0254f5c22a51a5ce2a42b60e4643b352b4ba7e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b9b7f8cc04c83648f54346ce08f309cc74110ec42f4e4c0e22e87f8ffc86469
MD5 8eb3c62e96c6532a4e748b4a1eb6083b
BLAKE2b-256 bdcdf4b77c532e1e47ecab25d92b7a16dae9b6d96e2187125e6ef3d10ffc981a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 46f7a1d2d65d468f64d7cf8d8e9c8e3b234f72a43646670f97c5e3bc837b5d66
MD5 7e4bd7211f6a26be5433198dd03b82a1
BLAKE2b-256 a15580f738084692b7a905687de361873fc0f1e251108ce73d747a9bb30fa919

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2-cp39-abi3-android_24_x86_64.whl
Algorithm Hash digest
SHA256 b1d1a4ba2e55c7f456331a07cc32b9c804ddc3941723ee1b4b8fab321ecd76da
MD5 87ade304565233f5c3824a0990f97d89
BLAKE2b-256 56a67462e724ce099a51c2779323081e3f2bcb5f9d71564a141561572aea1ed5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2-cp39-abi3-android_24_x86.whl
Algorithm Hash digest
SHA256 4126d5790293401c71f399d02e10a29da1c7040051d3c2e0f8ee05a376b7d2c9
MD5 4e3321d7aa09432bf998d4b5f45abd0b
BLAKE2b-256 196d51655ba0f5f3f21feab60848d3b7856d32ec400f20984f7a8b58da12c87f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2-cp39-abi3-android_24_armeabi_v7a.whl
Algorithm Hash digest
SHA256 c39e31f4bc493dc064c7b9d54572611916a3aa7cbf00e935f683feba47555729
MD5 5c5902cb2fa7901f484698e2cae72524
BLAKE2b-256 e29359e4b8355245d7f4f280a9b7b71c18d2f9953d91c4a434395bf037f8ce05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2-cp39-abi3-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 6e41309dc8d842ce8cc1eed851d1e8b789f461a9dae297fe68d836313563de56
MD5 b529551a3c22974e7c5474762993f46c
BLAKE2b-256 fe32ea8c0f6203a931cc748c1d0b2e3ca1fb41f3b2114e2d4ee27f776a2fa0aa

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