Telegram Bot APIs
Quick-access to Telegram Bot APIs plus common troubleshooting steps.
✈️ Telegram snippet
Telegram Bot API — DevTools#
A complete reference of raw Telegram Bot API commands, cURL examples, Java integration, and error fixes.
Send a Simple Text Message#
curl -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage" \
-d "chat_id=<CHAT_ID>" \
-d "text=Hello from my DevTools!"bashSend Markdown Message#
curl -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage" \
-d chat_id=<CHAT_ID> \
-d parse_mode="Markdown" \
-d text="*Bold text* _Italic text_"bashSend Photo (URL)#
curl -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/sendPhoto" \
-d chat_id=<CHAT_ID> \
-d photo="https://example.com/image.png"bashSend Local Photo#
curl -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/sendPhoto" \
-F chat_id=<CHAT_ID> \
-F photo=@"/path/to/local/image.png"bashSend Document (PDF, ZIP, Logs)#
curl -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/sendDocument" \
-F chat_id=<CHAT_ID> \
-F document=@"/path/to/file.pdf"bashQuick GET Request (Browser Friendly)#
https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage?chat_id=<CHAT_ID>&text=HelloplaintextJava Snippets (Without telegrambots Library)#
Java: Send Text Message#
String token = "<YOUR_TOKEN>";
String chatId = "<CHAT_ID>";
String text = "Hello from Java!";
String url = "https://api.telegram.org/bot" + token +
"/sendMessage?chat_id=" + chatId +
"&text=" + URLEncoder.encode(text, "UTF-8");
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("GET");
int responseCode = conn.getResponseCode();
System.out.println("Response Code: " + responseCode);javaJava: Send Photo (Multipart Upload)#
String token = "<YOUR_TOKEN>";
String chatId = "<CHAT_ID>";
File file = new File("image.png");
String url = "https://api.telegram.org/bot" + token + "/sendPhoto";
HttpPost post = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addTextBody("chat_id", chatId);
builder.addBinaryBody("photo", new FileInputStream(file),
ContentType.APPLICATION_OCTET_STREAM, file.getName());
post.setEntity(builder.build());
HttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(post);
System.out.println(response.getStatusLine().getStatusCode());javaError Fixes#
401 Unauthorized#
Fix:
- Wrong bot token
- Wrong chat_id
Check updates:
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdatesbash400 Bad Request: chat not found#
Fix:
- User has not clicked Start
- Bot not added to group
- For groups: chat ID must be negative
Example:
-987654321plaintextJava Proxy Fix#
System.setProperty("http.proxyHost", "proxy.company.com");
System.setProperty("http.proxyPort", "8080");javaVariable Reference#
<YOUR_TOKEN> → Telegram Bot Token
<CHAT_ID> → User ID / Group ID / Channel ID
Group IDs → Negative (e.g., -123456789)plaintextRelated DevTools
Published: 12/9/2025
Back to DevTools