Serverless Edge Gateway • Cloudflare Workers

Telegram Bot API
Powered by MTProto

Bypass standard 50 MB upload and 20 MB download limits. Stream files up to 2,000 MB (2 GB) directly through Telegram Data Centers with 100% Bot API drop-in compatibility.

curl "https://mtproto-tgbot.mehrnet.com/v1/{app_id}:{app_hash}/bot{token}/getMe"

Why Use This Gateway?

Get the best of both worlds: standard Bot API convenience with native MTProto high-capacity file handling.

🚀

2,000 MB File Limits

Unlocks Telegram's maximum 2 GB bot file limit for both uploads and downloads without hosting a bulky telegram-bot-api Docker daemon.

⚡

100% Bot API Compatible

Works out-of-the-box with python-telegram-bot, aiogram, grammY, telegraf, or raw HTTP cURL requests.

🧠

L1 RAM + L2 D1 Sessions

Zero cold-start login overhead. Auth keys are cached in Worker memory and persisted in Cloudflare D1 SQLite database.

🌐

Remote URL Streaming

Send files up to 2 GB simply by supplying a remote URL: document=https://example.com/large.zip. The edge pipes it directly to Telegram.

🛡️

Zero Idle Costs

True serverless computing. No monthly container bills, no idle VPS memory charges—you pay only for the milliseconds your requests execute.

🌍

Global Edge Network

Runs on Cloudflare’s 300+ edge data centers worldwide for low latency and high-speed streaming directly into Telegram DCs.

Interactive API Tester & cURL Generator

Configure your Telegram credentials and test endpoints directly against mtproto-tgbot.mehrnet.com.

Obtain from my.telegram.org
Hex string from my.telegram.org
Issued by @BotFather
Generated cURL Command
curl "https://mtproto-tgbot.mehrnet.com/v1/123456:0123456789abcdef0123456789abcdef/bot123456789:AAHTestBotTokenExample/getMe"

Drop-in SDK Integration

Simply change the base URL in your favorite Telegram bot framework.

from telegram.ext import ApplicationBuilder

# Configure custom base URL pointing to the MTProto gateway
APP_ID = 123456
APP_HASH = "your_app_hash"
BOT_TOKEN = "your_bot_token"

app = (
    ApplicationBuilder()
    .token(BOT_TOKEN)
    .base_url(f"https://mtproto-tgbot.mehrnet.com/v1/{APP_ID}:{APP_HASH}/bot")
    .base_file_url(f"https://mtproto-tgbot.mehrnet.com/v1/{APP_ID}:{APP_HASH}/file/bot")
    .build()
)

# You can now upload files up to 2,000 MB!
# context.bot.send_document(chat_id=chat_id, document="https://example.com/2gb_file.iso")
app.run_polling()
import asyncio
from aiogram import Bot, Dispatcher
from aiogram.client.session.aiohttp import AiohttpSession
from aiogram.client.telegram import TelegramAPIServer

APP_ID = 123456
APP_HASH = "your_app_hash"
BOT_TOKEN = "your_bot_token"

# Custom Telegram API server base URL
api_server = TelegramAPIServer.from_base(
    f"https://mtproto-tgbot.mehrnet.com/v1/{APP_ID}:{APP_HASH}"
)
session = AiohttpSession(api=api_server)
bot = Bot(token=BOT_TOKEN, session=session)
dp = Dispatcher()

async def main():
    await dp.start_polling(bot)

if __name__ == "__main__":
    asyncio.run(main())
import { Bot } from "grammy";

const APP_ID = 123456;
const APP_HASH = "your_app_hash";
const BOT_TOKEN = "your_bot_token";

const bot = new Bot(BOT_TOKEN, {
  client: {
    apiRoot: `https://mtproto-tgbot.mehrnet.com/v1/${APP_ID}:${APP_HASH}`,
  },
});

bot.command("start", async (ctx) => {
  await ctx.reply("Connected to MTProto edge gateway!");
});

bot.start();
const { Telegraf } = require("telegraf");

const APP_ID = 123456;
const APP_HASH = "your_app_hash";
const BOT_TOKEN = "your_bot_token";

const bot = new Telegraf(BOT_TOKEN, {
  telegram: {
    apiRoot: `https://mtproto-tgbot.mehrnet.com/v1/${APP_ID}:${APP_HASH}`,
  },
});

bot.start((ctx) => ctx.reply("Running on Mehrnet MTProto Gateway"));
bot.launch();

How It Works Behind The Scenes

A state-of-the-art serverless architecture eliminating traditional server bottlenecks.

1

API Request

Your client makes standard Telegram Bot API calls to mtproto-tgbot.mehrnet.com.

→
2

Session Lookup

Checks in-memory L1 cache (0ms). On miss, restores the MTProto session from Cloudflare D1.

→
3

Smart Routing

Standard calls proxy transparently; files >50MB stream via MTProto WebSockets/TCP.

→
4

Telegram DC

Uploads 512KB chunks directly using saveBigFilePart up to 2,000 MB.