Telegram Bot API
🌐 中文

getUpdates

分类: 更新 · Bot API 10.3 · 官方文档

获取更新。点击“开始”按钮可进行 Long Polling。

返回值: 调用成功时返回 Array of Update。

参数

参数类型必填说明
offsetInteger可选下一次请求的偏移量
limitInteger可选最大数量(1-100)
timeoutInteger可选超时时间(秒)
allowed_updatesArray of String可选类型的 JSON 数组

参数说明为简要概括,完整内容请参阅官方文档。

请求示例

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());

分步教程: Telegram chat id 获取教程:查看用户、群组、频道和话题的聊天 ID