使用 REST API 与 GitHub 上的反应进行交互。
您可以在 GitHub 上创建和管理对评论、问题、请求和讨论的反应。创建反应时,content 参数允许的值如下(并带有相应的 emoji 以供参考)
content
+1
-1
laugh
confused
heart
hooray
rocket
eyes
列出对 团队讨论评论 的反应。
注意:您还可以使用路由 GET /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions 按 org_id 和 team_id 指定团队。
GET /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions
org_id
team_id
OAuth 应用令牌和个人访问令牌(经典)需要 read:discussion 范围才能使用此端点。
read:discussion
accept
建议设置为 application/vnd.github+json。
application/vnd.github+json
org
组织名称。名称不区分大小写。
team_slug
团队名称的 slug。
discussion_number
标识讨论的数字。
comment_number
标识评论的数字。
返回单个 反应类型。省略此参数可列出团队讨论评论的所有反应。
可以是以下之一: +1, -1, laugh, confused, heart, hooray, rocket, eyes
per_page
每页的结果数(最大 100)。有关详细信息,请参阅“在 REST API 中使用分页”。
默认值: 30
30
page
要获取的结果的页码。有关详细信息,请参阅“在 REST API 中使用分页”。
默认值: 1
1
200
OK
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER/comments/COMMENT_NUMBER/reactions
响应
状态:200
[ { "id": 1, "node_id": "MDg6UmVhY3Rpb24x", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "content": "heart", "created_at": "2016-05-20T20:09:31Z" } ]
为 团队讨论评论 创建反应。
HTTP 200 状态的响应表示你已将反应类型添加到此团队讨论评论。
注意:您还可以使用路由POST /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions通过org_id和team_id指定一个团队。
POST /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions
OAuth 应用令牌和个人访问令牌(经典)需要write:discussion范围才能使用此端点。
write:discussion
要添加到团队讨论评论的反应类型。
当反应类型已添加到此团队讨论评论时的响应
201
已创建
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER/comments/COMMENT_NUMBER/reactions \ -d '{"content":"heart"}'
{ "id": 1, "node_id": "MDg6UmVhY3Rpb24x", "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "content": "heart", "created_at": "2016-05-20T20:09:31Z" }
注意:您还可以使用路由DELETE /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions/:reaction_id通过team_id和org_id指定一个团队或组织。
DELETE /organizations/:org_id/team/:team_id/discussions/:discussion_number/comments/:comment_number/reactions/:reaction_id
删除对 团队讨论评论 的反应。
此端点适用于以下细粒度令牌类型
细粒度令牌必须具有以下权限集
reaction_id
反应的唯一标识符。
204
无内容
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER/comments/COMMENT_NUMBER/reactions/REACTION_ID
状态:204
列出对 团队讨论 的反应。
注意:你还可以使用路由 GET /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions 通过 org_id 和 team_id 指定团队。
GET /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions
返回单个 反应类型。省略此参数可列出对团队讨论的所有反应。
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER/reactions
对团队讨论创建反应。
HTTP 200 状态的响应表示您已将反应类型添加到此团队讨论中。
注意:您还可以使用路由 POST /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions 通过 org_id 和 team_id 指定团队。
POST /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions
要添加到团队讨论中的反应类型。
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER/reactions \ -d '{"content":"heart"}'
注意:您还可以使用路由 DELETE /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions/:reaction_id 通过 team_id 和 org_id 指定团队或组织。
DELETE /organizations/:org_id/team/:team_id/discussions/:discussion_number/reactions/:reaction_id
删除对团队讨论的反应。
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER/reactions/REACTION_ID
列出对提交注释的反应。
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
owner
存储库的帐户所有者。名称不区分大小写。
repo
不带 .git 扩展名的存储库名称。名称不区分大小写。
.git
comment_id
评论的唯一标识符。
返回单个 反应类型。省略此参数以列出对提交评论的所有反应。
404
未找到资源
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/comments/COMMENT_ID/reactions
为 提交评论 创建反应。HTTP 200 状态的响应表示您已将反应类型添加到此提交评论。
要添加到提交评论的 反应类型。
反应已存在
已创建反应
422
验证失败,或端点已收到垃圾邮件。
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/comments/COMMENT_ID/reactions \ -d '{"content":"heart"}'
注意:你还可以使用路由 DELETE /repositories/:repository_id/comments/:comment_id/reactions/:reaction_id 通过 repository_id 指定存储库。
DELETE /repositories/:repository_id/comments/:comment_id/reactions/:reaction_id
repository_id
删除对 提交评论 的反应。
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/comments/COMMENT_ID/reactions/REACTION_ID
列出对 问题评论 的反应。
返回单个 反应类型。省略此参数以列出对问题评论的所有反应。
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/comments/COMMENT_ID/reactions
为 问题评论 创建反应。HTTP 200 状态的响应表示你已将反应类型添加到此问题评论。
要添加到问题评论中的反应类型。
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/comments/COMMENT_ID/reactions \ -d '{"content":"heart"}'
注意:你还可以使用路由 DELETE delete /repositories/:repository_id/issues/comments/:comment_id/reactions/:reaction_id 通过 repository_id 指定存储库。
DELETE delete /repositories/:repository_id/issues/comments/:comment_id/reactions/:reaction_id
删除对问题评论的反应。
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/comments/COMMENT_ID/reactions/REACTION_ID
列出对问题的反应。
issue_number
标识问题的编号。
返回单个反应类型。省略此参数以列出对问题的全部反应。
410
已删除
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/reactions
为 议题 创建反应。HTTP 200 状态的响应表示您已将反应类型添加到此议题。
要添加到议题的 反应类型。
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/reactions \ -d '{"content":"heart"}'
注意:您还可以使用 repository_id 通过路由 DELETE /repositories/:repository_id/issues/:issue_number/reactions/:reaction_id 指定存储库。
DELETE /repositories/:repository_id/issues/:issue_number/reactions/:reaction_id
删除对 议题 的反应。
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/reactions/REACTION_ID
列出对 Pull Request 评论 的反应。
返回单个 反应类型。省略此参数以列出对 Pull Request 评论的所有反应。
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/pulls/comments/COMMENT_ID/reactions
为拉取请求审查评论创建反应。HTTP 200 状态的响应表示您已将反应类型添加到此拉取请求审查评论。
反应类型,用于添加到拉取请求审查评论。
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/pulls/comments/COMMENT_ID/reactions \ -d '{"content":"heart"}'
注意:您还可以使用路由 DELETE /repositories/:repository_id/pulls/comments/:comment_id/reactions/:reaction_id.按 repository_id 指定存储库。
DELETE /repositories/:repository_id/pulls/comments/:comment_id/reactions/:reaction_id.
删除对拉取请求审查评论的反应。
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/pulls/comments/COMMENT_ID/reactions/REACTION_ID
列出对 版本 的反应。
细粒度令牌不需要任何权限。
release_id
版本的唯一标识符。
返回单个 反应类型。省略此参数以列出对版本的所有反应。
可以是: +1, laugh, heart, hooray, rocket, eyes
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/RELEASE_ID/reactions
对 版本 创建反应。Status: 200 OK 的响应表示您已向此版本添加反应类型。
Status: 200 OK
要添加到版本的 反应类型。
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/RELEASE_ID/reactions \ -d '{"content":"heart"}'
注意:您还可以使用路由 DELETE delete /repositories/:repository_id/releases/:release_id/reactions/:reaction_id 通过 repository_id 指定存储库。
DELETE delete /repositories/:repository_id/releases/:release_id/reactions/:reaction_id
删除对 发行版 的反应。
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/RELEASE_ID/reactions/REACTION_ID
弃用通知:此端点路由已弃用,将从团队 API 中移除。我们建议将现有代码迁移到使用新的 列出团队讨论评论的反应 端点。
列出团队讨论评论的反应
团队的唯一标识符。
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions/DISCUSSION_NUMBER/comments/COMMENT_NUMBER/reactions
弃用通知:此端点路由已弃用,将从团队 API 中移除。我们建议将现有代码迁移到使用新的 "为团队讨论评论创建反应" 端点。
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions/DISCUSSION_NUMBER/comments/COMMENT_NUMBER/reactions \ -d '{"content":"heart"}'
状态:201
弃用通知:此端点路由已弃用,并将从 Teams API 中移除。我们建议将现有代码迁移到使用新的 列出团队讨论的反应 端点。
列出团队讨论的反应
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions/DISCUSSION_NUMBER/reactions
弃用通知:此端点路由已弃用,并将从 Teams API 中移除。我们建议将现有代码迁移到使用新的 为团队讨论创建反应 端点。
为团队讨论创建反应
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions/DISCUSSION_NUMBER/reactions \ -d '{"content":"heart"}'