인증 방식
🔑 API Key
요금
완전 무료
Base URL
api.telegram.org
태그
Telegram, 봇
서비스 소개
Telegram Bot API는 완전 무료로 봇을 만들어 메시지 전송, 명령어 처리, 파일 전송, 그룹 관리 등을 구현할 수 있습니다. 서버 모니터링 알림, 배포 알림, 주문 알림 등 개발자 도구로 많이 활용됩니다. 글로벌 사용자에게 알림을 보내는 용도로도 적합합니다.
🚀 시작하기
- 1
BotFather로 봇 생성
Telegram에서 @BotFather → /newbot → 이름·username 설정 → 토큰 발급
- 2
Chat ID 확인
봇에게 메시지 전송 후 getUpdates API로 chat_id 확인
- 3
메시지 전송
sendMessage API로 바로 사용 — 별도 SDK 불필요
💡 코드 예제
JavaScriptJavaScript (SDK 없이)
const BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN!
const CHAT_ID = process.env.TELEGRAM_CHAT_ID!
const BASE = `https://api.telegram.org/bot${BOT_TOKEN}`
// 텍스트 메시지
async function sendMessage(text: string, chatId = CHAT_ID) {
await fetch(`${BASE}/sendMessage`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: chatId,
text,
parse_mode: 'HTML', // <b>볼드</b>, <i>이탤릭</i>, <code>코드</code>
}),
})
}
// Chat ID 확인
async function getChatId() {
const res = await fetch(`${BASE}/getUpdates`)
const data = await res.json()
return data.result[0]?.message?.chat?.id
}
// 사용 예
await sendMessage('🚨 <b>에러 발생!</b>\n<code>TypeError: Cannot read...</code>')
await sendMessage('✅ 배포 완료 — v1.2.3')PythonPython
import requests
BOT_TOKEN = "YOUR_BOT_TOKEN"
CHAT_ID = "YOUR_CHAT_ID"
def send_telegram(text: str) -> None:
requests.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
json={"chat_id": CHAT_ID, "text": text, "parse_mode": "HTML"},
)
# 에러 알림
try:
risky_operation()
except Exception as e:
send_telegram(f"🔴 <b>서버 에러</b>\n<code>{e}</code>")