A lightweight and fast Cloudflare Worker script that acts as a reverse proxy for the official Telegram Bot API.
Recently, access to api.telegram.org has been restricted or completely blocked by ISPs in certain regions. If you are hosting a Telegram bot on a server or local machine in an affected region, your bot will fail to send messages or fetch updates because it cannot connect to Telegram's servers.
Use this script when:
- Telegram is Blocked: You need a reliable way to bypass ISP or regional network blocks on
api.telegram.org. - IP Whitelisting: You want your API requests to originate from Cloudflare's IP ranges rather than your server's IP.
Instead of your bot code making requests directly to https://api.telegram.org/bot<TOKEN>/<METHOD>, you configure your bot library to send requests to your Cloudflare Worker URL: https://<YOUR_WORKER_URL>/bot<TOKEN>/<METHOD>.
The Worker receives the request, safely extracts your bot token and API method, forwards the exact request to Telegram's official API, and returns Telegram's response directly to your bot.
The easiest way to deploy this is directly through the Cloudflare Dashboard. It takes less than 5 minutes and requires no local installation.
- Log in or sign up at Cloudflare Dashboard.
- On the left sidebar, navigate to Workers & Pages.

- Click the Create application button.

- Click Start with Hello World!.

- Click Deploy.

- Once deployed, click the Edit code button to open the online code editor.

- Delete all the default boilerplate code in the
worker.jsfile.
- Copy the proxy script provided in
index.jsand paste it into the editor. - Click the Deploy button in the top right corner to save and publish your changes.

- After deploying, return to your Worker's overview page.
- You will see a domain assigned to your worker (e.g.,
https://tg-api-proxy.<your-username>.workers.dev). - Save this URL! This is your new Telegram API base URL.
To use the proxy, simply replace the standard Telegram API base URL (https://api.telegram.org) with your new Cloudflare Worker URL in your bot's code or library configuration.
Standard Request (Blocked):
curl "[https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe](https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe)"
Proxy Request (Working):
curl "https://tg-api-proxy.<your-username>.workers.dev/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe"
You can verify your proxy is active by visiting your worker's root URL in a web browser:
https://tg-api-proxy.<your-username>.workers.dev/
You should see:
{
"success": true,
"message": "Everything looks good and running."
}