Skip to main content
FTMGram Logo

FTMGram v3.5.1

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

Docs PyPI Telegram License


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


⚡ Key Highlights in v3.5.1

  • 🛡️ 100% Rock-Solid Stability: Zero file descriptor leaks on Linux / uvloop containers ([Errno 24] Too many open files completely eliminated).
  • ⚡ Turbo Multi-Worker Upload Engine (fast_upload): Upload videos, documents, and large files up to 2GB/4GB at maximum speed using concurrent multi-worker chunk streaming.
  • ⚡ Turbo Multi-Worker Download Engine (fast_download): Download media files concurrently with parallel chunk workers for gigabit saturation.
  • 🤖 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.
  • 🎨 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. Fast Upload & Fast Download (Turbo Transfers)

from ftmgram import Client

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

async def upload_and_download():
    async with app:
        # Fast Upload with 8 parallel workers
        uploaded_file = await app.fast_upload("large_video.mp4", workers=8)
        msg = await app.send_video(123456789, video=uploaded_file, caption="Sent via Turbo Upload! 🚀")

        # Fast Download with 8 parallel workers
        await app.fast_download(msg, file_name="downloads/", workers=8)

app.run(upload_and_download())

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. 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.2

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.2
File Size Uploaded
ftmgram-3.5.2.tar.gz 14.3 MB Details

Built distribution (wheel)

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

Total release size: 20.3 MB

Release files / ftmgram-3.5.2.tar.gz

Download URL ftmgram-3.5.2.tar.gz
Size 14.3 MB
Tags Source
SHA-256 checksum
How to use checksums
6647bcdb661e19e7cf05027cbebe3487c5cb61b377271ac325bfb0bb790aa62c
BLAKE2b-256 checksum
How to use checksums
3110e3fbd08c305454ae07645341f97a5215bbd9fc76a16f06b4432f272e379e
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.2-py3-none-any.whl

Download URL ftmgram-3.5.2-py3-none-any.whl
Size 6.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7183b6e98d663be665261d26812033e74567bd71ecf85166352aa688efb31351
BLAKE2b-256 checksum
How to use checksums
8b267276415548d446baf4fb68629172ab62f63c9d76a9575abe2b6852fa6805
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

This release

3.5.2 This release

2 release files

3.5.1

2 release files

3.5.0

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