You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过GitHub API获取Pull Request正文的Reactions?

获取Pull Request正文的Reactions(GitHub API)

Pull Request的正文(body)对应的Reactions是关联在PR资源本身的,而非评论(comments),你可以通过以下两种方式获取:

1. 获取Reactions统计数据

调用PR详情接口,返回结果中包含reactions字段,里面汇总了各类Reaction的数量:

curl -H "Authorization: token YOUR_GITHUB_TOKEN" https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}

返回的reactions字段示例:

"reactions": {
  "url": "https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}/reactions",
  "total_count": 5,
  "+1": 3,
  "-1": 0,
  "laugh": 1,
  "hooray": 0,
  "confused": 0,
  "heart": 1,
  "rocket": 0,
  "eyes": 0
}

2. 获取单个Reaction的详细信息

如果需要查看每个Reaction的具体详情(比如添加者、时间),调用专门的Reactions列表接口:

curl -H "Authorization: token YOUR_GITHUB_TOKEN" https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}/reactions

返回结果是一个数组,每个元素包含该Reaction的类型、创建者信息、创建时间等。

注意:这个接口和获取PR评论Reactions的接口不同——评论的Reactions需要针对具体评论ID调用/pulls/{pull_number}/comments/{comment_id}/reactions,而PR正文的Reactions直接绑定PR本身,无需评论ID。

内容的提问来源于stack exchange,提问作者38489344

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 00:50:40