getUpdates
Nhận các bản cập nhật. Dùng nút 'Bắt đầu' cho long polling.
Giá trị trả về: Nếu thành công, trả về Array of Update.
Tham số
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
offset | Integer | Tùy chọn | Offset cho yêu cầu tiếp theo |
limit | Integer | Tùy chọn | Số lượng tối đa (1-100) |
timeout | Integer | Tùy chọn | Thời gian chờ tính bằng giây |
allowed_updates | Array of String | Tùy chọn | Mảng JSON các loại |
Ví dụ request
curl
curl -s "https://api.telegram.org/bot$TOKEN/getUpdates"
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.get(f"https://api.telegram.org/bot{TOKEN}/getUpdates", timeout=30)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/getUpdates`);
console.log(await res.json());
Hướng dẫn từng bước: Chat id Telegram lấy ở đâu? Cách lấy chat id cho người dùng, group, kênh và topic
Phương thức liên quan
getWebhookInfoTrả về thông tin webhook.setWebhookThiết lập webhook.deleteWebhookXóa webhook.