Telegram Bot API
api.telegram.org · Communication
Build Telegram bots — send messages, photos, documents, polls, and keyboards. Handle user interactions, manage groups, and build inline experiences. Free, no cost per message.
Authentication
Sample Requests
Verify your token and get bot info.
Hover any highlighted part to learn what it does
curl -X GET "https://api.telegram.org/botYOUR_TOKEN/getMe"
import requests
response = requests.get(
"https://api.telegram.org/botYOUR_TOKEN/getMe",
)
print(response.json())const url = 'https://api.telegram.org/botYOUR_TOKEN/getMe'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://api.telegram.org/botYOUR_TOKEN/getMe"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.telegram.org/botYOUR_TOKEN/getMe")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.telegram.org/botYOUR_TOKEN/getMe";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Send a message to a chat.
Hover any highlighted part to learn what it does
| Content-Type | application/json |
{
"text": "Hello from the Telegram Bot API!",
"chat_id": "CHAT_ID"
}
curl -X POST "https://api.telegram.org/botYOUR_TOKEN/sendMessage" \
-H "Content-Type: application/json" \
-H "Content-Type: application/json" \
-d '{"text":"Hello from the Telegram Bot API!","chat_id":"CHAT_ID"}'import requests
headers = {
"Content-Type": "application/json"
}
data = {
"text": "Hello from the Telegram Bot API!",
"chat_id": "CHAT_ID"
}
response = requests.post(
"https://api.telegram.org/botYOUR_TOKEN/sendMessage",
headers=headers,
json=data,
)
print(response.json())const url = 'https://api.telegram.org/botYOUR_TOKEN/sendMessage';
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"text": "Hello from the Telegram Bot API!",
"chat_id": "CHAT_ID"
}),
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"bytes"
"encoding/json"
)
func main() {
targetURL := "https://api.telegram.org/botYOUR_TOKEN/sendMessage"
jsonData, _ := json.Marshal({"text":"Hello from the Telegram Bot API!","chat_id":"CHAT_ID"})
req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.telegram.org/botYOUR_TOKEN/sendMessage")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Content-Type"] = "application/json"
req.body = "{\"text\":\"Hello from the Telegram Bot API!\",\"chat_id\":\"CHAT_ID\"}"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.telegram.org/botYOUR_TOKEN/sendMessage";
$opts = ["http" => [
"method" => "POST",
"header" => implode("\r\n", [
"Content-Type: application/json",
"Content-Type: application/json"
]),
"content" => json_encode({"text":"Hello from the Telegram Bot API!","chat_id":"CHAT_ID"}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Open Telegram and message @BotFather
- Send /newbot and follow prompts to get your token
- Token is embedded in the URL: /botYOUR_TOKEN/method
- Get your chat ID: message your bot, then GET /getUpdates to see the chat_id
- Webhook or polling (getUpdates) for receiving messages
What can you build with Telegram Bot API?
Telegram Bot API is a Communication API. Developers commonly use communication APIs for:
- sending SMS alerts and notifications
- building in-app chat and messaging features
- automating email sequences and transactional emails
- creating voice bots and IVR systems
- verifying phone numbers at signup
API Key authentication. You'll receive a key after signing up. Send it with every request — in a header or query parameter. Keep it out of client-side code and never commit it to version control. Telegram Bot API is free to use, making it a low-risk choice to experiment with.
New to APIs? Read our beginner's guide