sendVideo
发送视频。
返回值: 调用成功时返回 Message。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
business_connection_id | String | 可选 | 商业连接 ID |
chat_id | Integer or String | 是 | 聊天 ID 或 @username |
message_thread_id | Integer | 可选 | 论坛话题 ID |
direct_messages_topic_id | Integer | 可选 | 私信话题 ID (Bot API 10.0) |
ephemeral_message_parameters | EphemeralMessageParameters | 可选 | EphemeralMessageParameters JSON 对象——仅对单个用户可见的临时消息 (Bot API 10.3) |
video | InputFile or String | 是 | 视频 URL 或 file_id |
duration | Integer | 可选 | 时长(秒) |
width | Integer | 可选 | 视频宽度 |
height | Integer | 可选 | 视频高度 |
thumbnail | InputFile or String | 可选 | 缩略图 URL 或 file_id |
cover | InputFile or String | 可选 | 视频封面 (Bot API 10.0) |
start_timestamp | Integer | 可选 | 视频起始时间戳 (Bot API 10.0) |
caption | String | 可选 | 说明文字(0-1024) |
parse_mode | String | 可选 | HTML、Markdown 或 MarkdownV2 |
caption_entities | Array of MessageEntity | 可选 | MessageEntity JSON 数组 |
show_caption_above_media | Boolean | 可选 | 在视频上方显示说明文字 |
has_spoiler | Boolean | 可选 | 隐藏内容(剧透效果) |
supports_streaming | Boolean | 可选 | 支持流式播放 |
disable_notification | Boolean | 可选 | 静默发送 |
protect_content | Boolean | 可选 | 保护内容 |
allow_paid_broadcast | Boolean | 可选 | 允许付费广播 |
message_effect_id | String | 可选 | 消息特效 ID |
suggested_post_parameters | SuggestedPostParameters | 可选 | SuggestedPostParameters JSON 对象 |
reply_parameters | ReplyParameters | 可选 | ReplyParameters JSON 对象 |
reply_markup | InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply | 可选 | JSON 对象:InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendVideo" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789,"video":"https://example.com/video.mp4"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendVideo",
json={
"chat_id": 123456789,
"video": "https://example.com/video.mp4"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendVideo`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"video": "https://example.com/video.mp4"
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
sendPhoto发送照片。sendDocument发送文件。sendAudio发送音频。sendAnimation发送动画(GIF)。sendSticker发送贴纸。sendVoice发送语音消息。sendVideoNote发送视频消息(圆形视频)。sendMediaGroup发送一组媒体(相册)。sendPaidMedia发送付费媒体 (Bot API 8.0+)。sendDice发送骰子。sendLivePhoto发送实况照片(照片 + 视频,Bot API 10.0)。