搜索 Issues¶
GET /api/v5/search/issues
用户调用此接口,按关键字搜索 Issues,返回匹配的 Issue 对象数组。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
q |
query | string | 是 | 搜索关键字 |
page |
query | integer | 否 | 当前的页码,最大为 100 |
per_page |
query | integer | 否 | 每页的数量,最大为 50 |
sort |
query | string | 否 | 排序字段:created_at(创建时间)、last_push_at(更新时间),默认为最佳匹配 |
order |
query | string | 否 | 排序顺序,默认 desc |
repo |
query | string | 否 | 仓库路径 |
state |
query | string | 否 | 筛选指定状态的 issues:open(开启)、closed(完成) |
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | 是 | 否 | 问题 ID |
html_url |
string | 是 | 否 | 问题的 HTML 地址 |
number |
string | 是 | 否 | 问题编号 |
state |
string | 是 | 否 | 问题状态:open(开启)、closed(完成) |
title |
string | 是 | 否 | 问题标题 |
body |
string | 是 | 否 | 问题描述内容 |
repository |
object | 是 | 否 | 所属仓库信息 |
created_at |
string | 是 | 否 | 创建时间 |
updated_at |
string | 是 | 否 | 更新时间 |
labels |
array | 是 | 是 | 标签列表,具体结构以实际返回为准 |
priority |
integer | 是 | 否 | 优先级 |
comments |
integer | 是 | 否 | 评论数 |
parent_id |
integer | 是 | 否 | 父级问题 ID |
repository 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
repository.id |
integer | 是 | 否 | 仓库 ID |
repository.full_name |
string | 是 | 否 | 仓库完整名称(owner/name) |
repository.human_name |
string | 是 | 否 | 仓库显示名称 |
repository.path |
string | 是 | 否 | 仓库路径 |
repository.name |
string | 是 | 否 | 仓库名称 |
repository.url |
string | 是 | 否 | 仓库地址 |
repository.owner |
object | 是 | 否 | 仓库所有者信息 |
repository.owner 对象¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
repository.owner.avatar_url |
string | 是 | 否 | 用户头像地址 |
repository.owner.html_url |
string | 是 | 否 | 用户主页地址 |
repository.owner.id |
string | 是 | 否 | 用户 ID |
repository.owner.login |
string | 是 | 否 | 登录名 |
repository.owner.name |
string | 是 | 否 | 用户名 |
repository.owner.type |
string | 是 | 否 | 用户类型(如 User) |
失败响应¶
400 参数错误
401 未认证
以上错误字段名以后端实际返回为准,未能确认时请以实际响应为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
304 |
未修改(Not modified) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
429 |
请求过于频繁(Too many requests) |
500 |
系统内部错误(Internal server error) |
请求示例¶
参数说明¶
<q>替换为搜索关键字;<owner/repo>替换为仓库路径(如owner/name)。此接口允许匿名访问,无需携带令牌;如需认证也可携带 AtomGit 用户访问令牌。
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/search/issues?q=<keyword>&repo=<owner/repo>&state=open&sort=created_at&order=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/search/issues?q=<keyword>&repo=<owner/repo>&state=open&sort=created_at&order=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/search/issues",
params={
"q": "<keyword>",
"repo": "<owner/repo>",
"state": "open",
"sort": "created_at",
"order": "desc",
"page": 1,
"per_page": 20,
},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
[
{
"id": 548499,
"html_url": "https://api.atomgit.com/youlai/vue3-element-admin/issues/1",
"number": "1",
"state": "open",
"title": "test",
"body": "test",
"repository": {
"id": 3771502,
"full_name": "youlai/vue3-element-admin",
"human_name": "有来开源组织 / vue3-element-admin",
"path": "vue3-element-admin",
"name": "vue3-element-admin",
"url": "https://api.atomgit.com/youlai/vue3-element-admin",
"owner": {
"avatar_url": "https://api.atomgit.com/avatar.png",
"html_url": "https://api.atomgit.com/u013737132",
"id": "6553a045ac27540b6bfcb436",
"login": "u013737132",
"name": "有来技术",
"type": "User"
}
},
"created_at": "2024-11-07T18:11:23+08:00",
"updated_at": "2024-11-07T18:11:23+08:00",
"labels": [],
"priority": 0,
"comments": 0,
"parent_id": 0
}
]
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc