Skip to main content
FTMGram Logo

FTMGram v3.5.0

Next-Gen Telegram MTProto & Bot API 10.3 Framework for Python

Docs PyPI Telegram License


FTMGram is a high-performance, asynchronous Telegram MTProto client library and Bot API framework for Python. It supercharges both user accounts and bots with modern features like In-Message Buttons, AI Response Token Streaming, Bot Chat History Scanning, Turbo Multi-Worker Transfers, Ephemeral Overlays, and Telegram Stars 2.0.


⚡ Key Highlights in v3.5.0

  • 🤖 Bot Chat History (get_bot_chat_history): Allows bots to retrieve message history across private chats and groups using safe, high-speed 100-ID batch scanning.
  • ⚡ Turbo Multi-Worker Media Engine (fast_download): Download photos, videos, and large files at maximum network saturation with parallel chunk workers.
  • 🎨 Fluent RichMessageBuilder DSL: Construct structured rich messages with in-message buttons (<tg-button-row>), expandable quotes, tables, and paragraphs effortlessly in Python.
  • 🧠 Real-Time AI Streaming (stream_text & thinking): Seamlessly stream LLM tokens (OpenAI, Anthropic, Gemini, Groq, Ollama) directly to chat drafts with animated thinking placeholders and stop buttons.
  • 🧹 Batch Chat Purge (purge_messages): Safely delete hundreds of messages in seconds with automatic RPC chunking and rate-limit handling.
  • 💾 Memory Media Streaming (download_media_to_memory): Download media straight into an in-memory io.BytesIO buffer without disk I/O bottlenecks.
  • 👥 Multi-Client Orchestrator (MultiClient): Manage and run dozens of bots and user accounts concurrently in a single event loop.

📦 Installation

pip install -U ftmgram

Or install with fast cryptographic acceleration:

pip install -U "ftmgram[fast]"

🚀 Quick Examples

1. Echo Bot with Filters

from ftmgram import Client, filters

app = Client("my_bot", bot_token="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11")

@app.on_message(filters.text & filters.private)
async def echo(client, message):
    await message.reply(f"You said: {message.text}")

app.run()

2. In-Message Buttons (Bot API 10.3)

from ftmgram import Client
from ftmgram.helpers import RichMessageBuilder, Button

app = Client("my_bot", bot_token="TOKEN")

async def send_menu(chat_id: int):
    async with app:
        rich = (
            RichMessageBuilder()
            .title("💎 VIP Subscription")
            .paragraph("Select your desired membership tier:")
            .button_row(
                Button("Starter ($5)", data="plan_starter", style="primary"),
                Button("Pro ($15)", data="plan_pro", style="success"),
                Button("VIP ($25)", data="plan_vip", style="danger")
            )
            .build()
        )
        await app.send_rich_message(chat_id, rich)

app.run(send_menu(123456789))

3. Real-Time AI Token Streaming

from ftmgram import Client

app = Client("my_bot", bot_token="TOKEN")

async def fake_ai_stream():
    for word in ["Generating ", "answers ", "with ", "FTMGram ", "v3.5.0! 🚀"]:
        yield word

async def main():
    async with app:
        await app.stream_text(
            chat_id=123456789,
            stream=fake_ai_stream(),
            placeholder="AI is reasoning..."
        )

app.run(main())

4. Bot Chat History Retrieval

from ftmgram import Client

app = Client("my_bot", bot_token="TOKEN")

async def scan_history(chat_id: int):
    async with app:
        async for msg in app.get_bot_chat_history(chat_id, start_message_id=1, limit=50):
            print(f"[{msg.id}] {msg.text}")

app.run(scan_history(123456789))

📚 Documentation

Visit the official documentation portal: https://ftmgram.ftmbotzx.dev/


📜 License

FTMGram is licensed under the GNU Lesser General Public License v3.0 (LGPL-3.0). Copyright (C) 2024-present FTM DEVELOPERZ.

Release files for ftmgram 3.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ftmgram 3.5.0
File Size Uploaded
ftmgram-3.5.0.tar.gz 13.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for ftmgram 3.5.0
File Interpreter ABI Platform
ftmgram-3.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.5 MB

Release files / ftmgram-3.5.0.tar.gz

Download URL ftmgram-3.5.0.tar.gz
Size 13.4 MB
Tags Source
SHA-256 checksum
How to use checksums
f8b0c7f636b141669cb932de5ab50286f1a7d3e71debf09eaffb8d3b853d5bdb
BLAKE2b-256 checksum
How to use checksums
2b9896e9cc400848563c856d107e210d59a802fc2df4168765892dbf9a773726
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / ftmgram-3.5.0-py3-none-any.whl

Download URL ftmgram-3.5.0-py3-none-any.whl
Size 6.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
272abfb80a63b824511204f2f0da4654c07a8b84508aec89b19ecdb0ded38d6c
BLAKE2b-256 checksum
How to use checksums
6ef0f033e38f765da35ce433630399319dd1d021ecb01a47c14899deb1107a70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

3.5.8

2 release files

3.5.7

2 release files

3.5.6

2 release files

3.5.4

2 release files

3.5.3

2 release files

3.5.2

2 release files

3.5.1

2 release files

This release

3.5.0 This release

2 release files

3.3.0

2 release files

3.1.0

2 release files

3.0.25

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.17

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page