getChatGifts
返回聊天的礼物。
返回值: 调用成功时返回 OwnedGifts。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
chat_id | Integer or String | 是 | 聊天 ID 或 @username |
exclude_unsaved | Boolean | 可选 | 排除未保存到个人资料页的礼物 |
exclude_saved | Boolean | 可选 | 排除已保存到个人资料页的礼物 |
exclude_unlimited | Boolean | 可选 | 排除可无限次购买的礼物 |
exclude_limited_upgradable | Boolean | 可选 | 排除可升级为唯一礼物的限量礼物 |
exclude_limited_non_upgradable | Boolean | 可选 | 排除不可升级为唯一礼物的限量礼物 |
exclude_from_blockchain | Boolean | 可选 | 排除从 TON 区块链分配的礼物 |
exclude_unique | Boolean | 可选 | 排除唯一礼物 |
sort_by_price | Boolean | 可选 | 按礼物价格而非发送日期排序 |
offset | String | 可选 | 分页偏移量 |
limit | Integer | 可选 | 数量(1-100) |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/getChatGifts" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/getChatGifts",
json={
"chat_id": 123456789
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/getChatGifts`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
sendInvoice发送支付账单。createInvoiceLink创建支付链接。refundStarPayment退还 Telegram Stars 付款。sendGift向用户或聊天发送礼物。getMyStarBalance返回机器人的 Telegram Stars 余额。getStarTransactions返回机器人的 Telegram Stars 交易记录。editUserStarSubscription取消或续订 Telegram Stars 订阅。giftPremiumSubscription赠送 Telegram Premium 订阅。answerShippingQuery响应配送查询。answerPreCheckoutQuery响应预结账查询。getAvailableGifts返回机器人可发送的礼物。getUserGifts返回用户的礼物。