Skip to content

getChat

获取聊天的详细信息。

请求

POST /:token/getchat

参数

参数类型必填描述
chat_idInteger/String目标聊天的唯一标识符或用户名

响应

返回 Chat 对象。

json
{
  "ok": true,
  "result": {
    "id": -1001234567890,
    "type": "supergroup",
    "title": "技术交流群",
    "username": "tech_group",
    "first_name": null,
    "description": "这是一个技术交流群组",
    "permissions": {
      "can_send_messages": true,
      "can_send_media_messages": true,
      "can_send_polls": true,
      "can_send_other_messages": true,
      "can_add_web_page_previews": true,
      "can_change_info": false,
      "can_invite_users": true,
      "can_pin_messages": false
    }
  }
}

返回字段说明

字段类型描述
idInteger聊天的唯一标识符
typeString聊天类型,可选值:privategroupsupergroupchannel
titleString群组或频道的标题,私聊时为空
usernameString聊天的用户名(如果设置了)
first_nameString私聊时对方的名字
descriptionString群组或频道的简介描述
permissionsChatPermissions群组的默认成员权限

错误码

错误码描述
400请求参数错误,如 chat_id 格式不正确
401Token 无效或已过期
403Bot 不是该聊天的成员,无权获取信息
404聊天不存在
500服务器内部错误

示例

cURL

bash
curl -X POST "https://api.example.com/<token>/getchat" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": -1001234567890
  }'