获取仓库所有 Issue 评论¶
GET /api/v5/repos/{owner}/{repo}/issues/comments
该接口用于获取指定仓库中所有 Issue 的评论,支持按创建或更新时间排序、指定排序方向以及分页查询,并可按时间筛选最新更新的评论。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
sort |
query | string | 否 | 按字段排序,支持 created 或 updated,默认 created |
direction |
query | string | 否 | 排序方向,支持 asc / desc |
since |
query | string | 否 | 只返回在此时间或之后更新的评论。例如:2024-11-20T13:00:21+08:00(注意 + 号需 URL 编码为 %2B) |
page |
query | integer | 否 | 当前页码 |
per_page |
query | integer | 否 | 每页数量,最大 100,默认 20 |
响应参数¶
该接口返回一个数组,数组元素为评论对象,各字段说明如下:
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | 是 | 否 | 评论 ID |
body |
string | 是 | 否 | 评论内容 |
user |
object | 是 | 否 | 评论者用户信息 |
target |
object | 是 | 否 | 评论目标对象 |
created_at |
string | 是 | 否 | 创建时间 |
updated_at |
string | 是 | 是 | 更新时间,可能为 null |
user 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
user.avatar_url |
string | 是 | 否 | 用户头像 URL |
user.html_url |
string | 是 | 否 | 用户主页 URL |
user.id |
string | 是 | 否 | 用户 ID |
user.login |
string | 是 | 否 | 用户登录名 |
user.name |
string | 是 | 否 | 用户昵称 |
user.events_url |
string | 是 | 是 | 事件 URL,可能为 null |
user.followers_url |
string | 是 | 是 | 关注者 URL,可能为 null |
user.following_url |
string | 是 | 是 | 关注列表 URL,可能为 null |
user.gists_url |
string | 是 | 是 | Gist URL,可能为 null |
user.member_role |
string | 是 | 是 | 成员角色,可能为 null |
user.organizations_url |
string | 是 | 是 | 组织 URL,可能为 null |
user.received_events_url |
string | 是 | 是 | 接收事件 URL,可能为 null |
user.remark |
string | 是 | 是 | 备注,可能为 null |
user.repos_url |
string | 是 | 是 | 仓库 URL,可能为 null |
user.starred_url |
string | 是 | 是 | 星标 URL,可能为 null |
user.subscriptions_url |
string | 是 | 是 | 订阅 URL,可能为 null |
user.type |
string | 是 | 是 | 用户类型,可能为 null |
user.url |
string | 是 | 是 | 用户 URL,可能为 null |
target 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
target.issue |
object | 是 | 否 | 评论关联的 Issue 对象 |
target.issue 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
target.issue.id |
integer | 是 | 否 | Issue ID |
target.issue.title |
string | 是 | 否 | Issue 标题 |
target.issue.nubmer |
integer | 是 | 否 | Issue 编号 |
target.issue.created_at |
string | 是 | 否 | Issue 创建时间 |
target.issue.updated_at |
string | 是 | 是 | Issue 更新时间,可能为 null |
失败响应¶
该接口在参考文档中未定义具体的业务失败响应体,失败时的响应结构以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not Found) |
500 |
系统内部错误(Internal Server Error) |
请求示例¶
参数说明¶
<owner>— 替换为仓库所属空间地址(企业、组织或个人的地址 path)<repo>— 替换为仓库路径(path)
本接口允许匿名访问,示例中可不携带访问令牌;如需携带,请在 URL 中追加 access_token=<token>。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/comments?sort=created&direction=desc&page=1&per_page=20' \
-H 'Accept: application/json'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/comments?sort=created&direction=desc&page=1&per_page=20", {
headers: {
"Accept": "application/json",
},
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/comments",
params={"sort": "created", "direction": "desc", "page": 1, "per_page": 20},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
[
{
"id": 272201,
"body": "这是一条评论内容",
"user": {
"avatar_url": "https://api.atomgit.com/avatar.png",
"events_url": null,
"followers_url": null,
"following_url": null,
"gists_url": null,
"html_url": "https://api.atomgit.com/dengmengmian",
"id": "661ce4eab470b1430d456154",
"login": "dengmengmian",
"member_role": null,
"name": "麻凡_",
"organizations_url": null,
"received_events_url": null,
"remark": null,
"repos_url": null,
"starred_url": null,
"subscriptions_url": null,
"type": null,
"url": null
},
"target": {
"issue": {
"id": 152642,
"title": "半月据",
"nubmer": 15,
"created_at": "2024-04-20T15:20:30.104+08:00",
"updated_at": null
}
},
"created_at": "2024-04-20T15:20:30.104+08:00",
"updated_at": null
}
]
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc