Telegram Bot API Proxy

A Cloudflare Worker that translates header-based auth into Telegram's token-in-URL format.

Overview

This proxy lets any API client that uses standard Authorization headers (like PromptQL) communicate with the Telegram Bot API seamlessly. Your bot token never appears in the URL.

Authentication

Pass your bot token in the Authorization header:

Authorization: Bearer <bot_token>

The token format is 123456789:ABCdefGHI-jklMNOpqrSTUvwxYZ (the one you get from @BotFather).

Base URL

https://tg.paritoshraj.com

Endpoints

Bot Info

GET /getMe
Returns basic information about the bot.

Messages

POST /sendMessage
Send a text message.
POST /sendPhoto
Send a photo (supports multipart/form-data).
POST /sendDocument
Send a document or file.
POST /forwardMessage
Forward a message from one chat to another.

Updates

GET /getUpdates?offset=0&limit=10
Receive incoming updates via long polling.
POST /setWebhook
Set a webhook URL for receiving updates.
POST /deleteWebhook
Remove the current webhook.

Chat Management

GET /getChat?chat_id=123
Get information about a chat.
GET /getChatMemberCount?chat_id=123
Get the number of members in a chat.

File Downloads

GET /getFile?file_id=xxx
Get file info (returns a file_path).
GET /file/<file_path>
Download a file using the path from getFile.

File Uploads (via Base64)

POST /sendDocument base64
Send a file using a base64 data URI in the JSON body. The proxy automatically converts it to multipart/form-data.
Base64 file uploads: If you can't send multipart/form-data (e.g. from PromptQL), you can pass a data:<mime>;base64,<data> URI in any file field (document, photo, audio, video, voice, sticker, animation, thumbnail). Include an optional filename field to set the file name. The proxy decodes the base64 and forwards it as a proper multipart upload to Telegram.
All Telegram Bot API methods are supported. Just use the method name as the path.

Examples

cURL

# Get bot info
curl -H "Authorization: Bearer YOUR_TOKEN" https://tg.paritoshraj.com/getMe

# Send a message
curl -X POST https://tg.paritoshraj.com/sendMessage \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"chat_id": 123456, "text": "Hello from the proxy!"}'

# Get updates
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "https://tg.paritoshraj.com/getUpdates?offset=0&limit=10"

# Download a file
curl -H "Authorization: Bearer YOUR_TOKEN" \
  https://tg.paritoshraj.com/file/photos/file_123.jpg -o photo.jpg

File Upload (base64 in JSON)

# Send a document using base64-encoded content
curl -X POST https://tg.paritoshraj.com/sendDocument \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 123456,
    "document": "data:text/vcard;base64,QkVHSU4OlZDQVJE...",
    "filename": "contacts.vcf",
    "caption": "Here are the contacts!"
  }'

JavaScript (fetch)

const TOKEN = "123456789:ABCdef...";

const res = await fetch("https://tg.paritoshraj.com/sendMessage", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    chat_id: 123456,
    text: "Hello!",
  }),
});

const data = await res.json();
console.log(data);

Python (requests)

import requests

TOKEN = "123456789:ABCdef..."
headers = {"Authorization": f"Bearer {TOKEN}"}

# Get bot info
r = requests.get("https://tg.paritoshraj.com/getMe", headers=headers)
print(r.json())

# Send message
r = requests.post("https://tg.paritoshraj.com/sendMessage", headers=headers, json={
    "chat_id": 123456,
    "text": "Hello from Python!"
})
print(r.json())

PromptQL Configuration

SettingValue
Base URLhttps://tg.paritoshraj.com
Auth TypeAPI Key
HeaderAuthorization
PrefixBearer
API KeyYour bot token from @BotFather

Error Responses

StatusMeaning
401Missing or invalid Authorization header or token format
4xxTelegram API error (passed through as-is)
502Could not reach the Telegram API