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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

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

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

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

Uploaded Android API level 24+ x86CPython 3.9+

ferogram-0.5.2b1-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.2b1-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.2b1.tar.gz.

File metadata

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

File hashes

Hashes for ferogram-0.5.2b1.tar.gz
Algorithm Hash digest
SHA256 631a131be8808b4d2402baa26a6eda84b836277c1f426a1db58e614ae4cfca6a
MD5 2b4bdfba229eb551e10fdd61e4f6529d
BLAKE2b-256 a215f9ea58934acadfb03fd1b5f78b89193168e009aae5c0589a4dcd0eb2d091

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7342c39881760be9a08d4154aecde5fa96c838224411b6c9092ddb0939ef4f14
MD5 e371f3fc8524ea087943cfde9a7b150f
BLAKE2b-256 fd84d30a25e17546b7cefbd10a077d6dbf25c30103b4963801da280c889b01ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63edbc364c2c85cb3520714bfea9f6e36ccd4289287a21c829ec4765e84a37d4
MD5 d694bb5213b80a0b28e2285e68393520
BLAKE2b-256 37eb9078dac25ae76f6a9b590745a62b642e5161b88553af552117d6a3135c1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 eebaea92b53457b3b1075a93a47361c12ce476da78162be56432e667d4a3b286
MD5 f84d63ffde3eb135415914e96f0ed1a4
BLAKE2b-256 1cf7d87b2280ca110aee87abb2edd7e74c9cc24542e9a25dcd811edbc9bce3e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9bc66afdc0842d21d26d6df7f4cffb5029700662fa439c3bbb5ab2318109cb6
MD5 09fb2dd741172c02b4474cc0c19c2d0f
BLAKE2b-256 6d4ee71e80a8cf03acf48e0c15c01a01a15d8a9a3e73462aabeb8cebeb4afb75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ffe9460dcc62bd31fbc427182e63ff2442b2438637ee1a800c09189f80423665
MD5 ac11fcdd314d352957fe3579f31af087
BLAKE2b-256 deecb78725ddf2ed14e69504c1d9108b9166eb0a0274b1a97470685255d1d66d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-android_24_x86_64.whl
Algorithm Hash digest
SHA256 3bdc44bd96548660d10cbb87b4f797e8b710fc33fb0e3dc762fd2fa6ba82749e
MD5 27840c58af1edf4efc62313ca4da0af1
BLAKE2b-256 0707a5432ecc18c2627ae6c7478269cd7e292c748cfd650f007c741f8d76d61e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-android_24_x86.whl
Algorithm Hash digest
SHA256 cbfed1e1f2c86db32c61f427e09c774b6f8427b93419843949b2495758307bbf
MD5 86eabc058b444847586eb1b431349386
BLAKE2b-256 7e65e378bacdc91029e6ff35e34800f794cc1216837909937089b102c5acacc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-android_24_armeabi_v7a.whl
Algorithm Hash digest
SHA256 b730a77a2d3513ab45b172810622a9e51f8d698f8d3d2288b8b7bbe1229edc3e
MD5 eb5f77b5a5a37d6cafbbabb8d8691c50
BLAKE2b-256 55101bd88c317d3e57c102bf6270c93946f7f7e2cda3214bb20669482691b331

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferogram-0.5.2b1-cp39-abi3-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 321fc3e0ac5f6e2afd313e19dd5062f612c075374a46a5911d081d9b006baccb
MD5 71c739769dcc6d29037338ea44695e56
BLAKE2b-256 149e56d3699996d077209b1f5298383c77e40fe82497ed02256570497eed513a

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