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

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

Built distribution (wheel)

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

Total release size: 20.3 MB

Release files / ftmgram-3.5.4.tar.gz

Download URL ftmgram-3.5.4.tar.gz
Size 14.3 MB
Tags Source
SHA-256 checksum
How to use checksums
a00fcc5ef81a74fddb9bd1c7530bc1cbd5606b488c5798c364c23ef7ee9013d3
BLAKE2b-256 checksum
How to use checksums
3a45d3d381d99e89496d1aad2e723bf44b41ddb1692dbda585a2bf989efc24b0
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.4-py3-none-any.whl

Download URL ftmgram-3.5.4-py3-none-any.whl
Size 6.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
731fc25f67d395119a701ab8049beb3a06d57d7aaca13ed0eb6d4fc697cd153f
BLAKE2b-256 checksum
How to use checksums
c78b872b3bbafe36b60be2f6c2129ea04ce4e65a6b55468b78e4da4a25e9ebd0
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

This release

3.5.4 This release

2 release files

3.5.3

2 release files

3.5.2

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