{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
{{< /details >}}
每一个 API 调用搜索都必须经过身份验证。
当高级搜索启用时,这些附加的范围可用于高级搜索、群组搜索和项目搜索 API:
wiki_blobs
commits
blobs
notes
如果您想使用基本搜索,请参阅指定搜索类型。
高级搜索 API
在整个极狐GitLab 实例中搜索一个术语。响应取决于请求的范围。
GET /search
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
scope |
string | 是 | 要搜索的范围。值包括 projects 、issues 、merge_requests 、milestones 、snippet_titles 和 users 。附加的范围包括 wiki_blobs 、commits 、blobs 和 notes 。 |
search |
string | 是 | 搜索术语。 |
confidential |
boolean | 否 | 按保密性筛选。支持 issues 范围;其他范围被忽略。 |
order_by |
string | 否 | 允许的值仅为 created_at 。如果未设置,结果将按基本搜索中的 created_at 降序排列,或按高级搜索中最相关的文档排列。 |
sort |
string | 否 | 允许的值仅为 asc 或 desc 。如果未设置,结果将按基本搜索中的 created_at 降序排列,或按高级搜索中最相关的文档排列。 |
state |
string | 否 | 按状态筛选。支持 issues 和 merge_requests 范围;其他范围被忽略。 |
fields |
array of strings | 否 | 您希望搜索的字段数组,允许的值仅为 title 。支持 issues 和 merge_requests 范围;其他范围被忽略。仅限专业版和旗舰版。 |
范围:projects
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=projects&search=flight"
示例响应:
[
{
"id": 6,
"description": "Nobis sed ipsam vero quod cupiditate veritatis hic.",
"name": "Flight",
"name_with_namespace": "Twitter / Flight",
"path": "flight",
"path_with_namespace": "twitter/flight",
"created_at": "2017-09-05T07:58:01.621Z",
"default_branch": "main",
"tag_list":[], //deprecated, use `topics` instead
"topics":[],
"ssh_url_to_repo": "ssh://jarka@localhost:2222/twitter/flight.git",
"http_url_to_repo": "http://localhost:3000/twitter/flight.git",
"web_url": "http://localhost:3000/twitter/flight",
"readme_url": "http://localhost:3000/twitter/flight/-/blob/main/README.md",
"avatar_url": null,
"star_count": 0,
"forks_count": 0,
"last_activity_at": "2018-01-31T09:56:30.902Z"
}
]
范围:issues
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=issues&search=file"
示例响应:
[
{
"id": 83,
"iid": 1,
"project_id": 12,
"title": "Add file",
"description": "Add first file",
"state": "opened",
"created_at": "2018-01-24T06:02:15.514Z",
"updated_at": "2018-02-06T12:36:23.263Z",
"closed_at": null,
"labels":[],
"milestone": null,
"assignees": [{
"id": 20,
"name": "Ceola Deckow",
"username": "sammy.collier",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
"web_url": "http://localhost:3000/sammy.collier"
}],
"author": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"assignee": {
"id": 20,
"name": "Ceola Deckow",
"username": "sammy.collier",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
"web_url": "http://localhost:3000/sammy.collier"
},
"user_notes_count": 0,
"upvotes": 0,
"downvotes": 0,
"due_date": null,
"confidential": false,
"discussion_locked": null,
"web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
}
}
]
{{< alert type=”note” >}}
assignee
列已弃用。现在显示为单个大小的数组 assignees
,以符合极狐GitLab EE API。
{{< /alert >}}
范围:merge_requests
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=merge_requests&search=file"
示例响应:
[
{
"id": 56,
"iid": 8,
"project_id": 6,
"title": "Add first file",
"description": "This is a test MR to add file",
"state": "opened",
"created_at": "2018-01-22T14:21:50.830Z",
"updated_at": "2018-02-06T12:40:33.295Z",
"target_branch": "main",
"source_branch": "jaja-test",
"upvotes": 0,
"downvotes": 0,
"author": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"assignee": {
"id": 5,
"name": "Jacquelyn Kutch",
"username": "abigail",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
"web_url": "http://localhost:3000/abigail"
},
"source_project_id": 6,
"target_project_id": 6,
"labels": [
"ruby",
"tests"
],
"draft": false,
"work_in_progress": false,
"milestone": {
"id": 13,
"iid": 3,
"project_id": 6,
"title": "v2.0",
"description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
"state": "active",
"created_at": "2017-09-05T07:58:29.099Z",
"updated_at": "2017-09-05T07:58:29.099Z",
"due_date": null,
"start_date": null
},
"merge_when_pipeline_succeeds": false,
"merge_status": "can_be_merged",
"sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
"merge_commit_sha": null,
"squash_commit_sha": null,
"user_notes_count": 0,
"discussion_locked": null,
"should_remove_source_branch": null,
"force_remove_source_branch": true,
"web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
}
}
]
范围:milestones
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=milestones&search=release"
示例响应:
[
{
"id": 44,
"iid": 1,
"project_id": 12,
"title": "next release",
"description": "Next release milestone",
"state": "active",
"created_at": "2018-02-06T12:43:39.271Z",
"updated_at": "2018-02-06T12:44:01.298Z",
"due_date": "2018-04-18",
"start_date": "2018-02-04"
}
]
范围:snippet_titles
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=snippet_titles&search=sample"
示例响应:
[
{
"id": 50,
"title": "Sample file",
"file_name": "file.rb",
"description": "Simple ruby file",
"author": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"updated_at": "2018-02-06T12:49:29.104Z",
"created_at": "2017-11-28T08:20:18.071Z",
"project_id": 9,
"web_url": "http://localhost:3000/root/jira-test/snippets/50"
}
]
范围:users
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=users&search=doe"
示例响应:
[
{
"id": 1,
"name": "John Doe1",
"username": "user1",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
"web_url": "http://localhost/user1"
}
]
范围:wiki_blobs
{{< details >}}
- Tier: 专业版, 旗舰版
{{< /details >}}
此范围仅在高级搜索启用时可用。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=wiki_blobs&search=bye"
示例响应:
[
{
"basename": "home",
"data": "hello\n\nand bye\n\nend",
"path": "home.md",
"filename": "home.md",
"id": null,
"ref": "main",
"startline": 5,
"project_id": 6,
"group_id": null
}
]
{{< alert type=”note” >}}
filename
已弃用,建议使用 path
。两者都返回文件在存储库中的完整路径,但未来 filename
仅用于表示文件名而非完整路径。详情请参阅议题 34521。
{{< /alert >}}
范围:commits
{{< details >}}
- Tier: 专业版, 旗舰版
{{< /details >}}
此范围仅在高级搜索启用时可用。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=commits&search=bye"
示例响应:
[
{
"id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
"short_id": "4109c2d8",
"title": "goodbye $.browser",
"created_at": "2013-02-18T22:02:54.000Z",
"parent_ids": [
"59d05353ab575bcc2aa958fe1782e93297de64c9"
],
"message": "goodbye $.browser\n",
"author_name": "angus croll",
"author_email": "anguscroll@gmail.com",
"authored_date": "2013-02-18T22:02:54.000Z",
"committer_name": "angus croll",
"committer_email": "anguscroll@gmail.com",
"committed_date": "2013-02-18T22:02:54.000Z",
"project_id": 6
}
]
范围:blobs
{{< details >}}
- Tier: 专业版, 旗舰版
{{< /details >}}
此范围仅在高级搜索启用时可用。
以下过滤器可用于此范围:
filename
path
extension
要使用过滤器,请在查询中包含它。例如:a query filename:some_name*
。
您可以使用通配符(*
)进行全局匹配。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=blobs&search=installation"
示例响应:
[
{
"basename": "README",
"data": "```\n\n## Installation\n\nQuick start using the [pre-built",
"path": "README.md",
"filename": "README.md",
"id": null,
"ref": "main",
"startline": 46,
"project_id": 6
}
]
{{< alert type=”note” >}}
filename
已弃用,建议使用 path
。两者都返回文件在存储库中的完整路径,但未来 filename
仅用于表示文件名而非完整路径。详情请参阅议题 34521。
{{< /alert >}}
范围:notes
{{< details >}}
- Tier: 专业版, 旗舰版
{{< /details >}}
此范围仅在高级搜索启用时可用。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/search?scope=notes&search=maxime"
示例响应:
[
{
"id": 191,
"body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
"attachment": null,
"author": {
"id": 23,
"name": "User 1",
"username": "user1",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
"web_url": "http://localhost:3000/user1"
},
"created_at": "2017-09-05T08:01:32.068Z",
"updated_at": "2017-09-05T08:01:32.068Z",
"system": false,
"noteable_id": 22,
"noteable_type": "Issue",
"project_id": 6,
"noteable_iid": 2
}
]
群组搜索 API
在指定的群组中搜索一个术语。
如果用户不是群组的成员且群组是私有的,则对该群组的 GET
请求会导致 404 Not Found
状态码。
GET /groups/:id/search
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer or string | 是 | 群组的 ID 或URL 编码路径。 |
scope |
string | 是 | 要搜索的范围。值包括 projects 、issues 、merge_requests 、milestones 和 users 。附加的范围包括 wiki_blobs 、commits 、blobs 和 notes 。 |
search |
string | 是 | 搜索术语。 |
confidential |
boolean | 否 | 按保密性筛选。仅支持 issues 范围;其他范围被忽略。 |
order_by |
string | 否 | 允许的值仅为 created_at 。如果未设置,结果将按基本搜索中的 created_at 降序排列,或按高级搜索中最相关的文档排列。 |
sort |
string | 否 | 允许的值仅为 asc 或 desc 。如果未设置,结果将按基本搜索中的 created_at 降序排列,或按高级搜索中最相关的文档排列。 |
state |
string | 否 | 按状态筛选。仅支持 issues 和 merge_requests ;其他范围被忽略。 |
响应取决于请求的范围。
范围:projects
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/3/search?scope=projects&search=flight"
示例响应:
[
{
"id": 6,
"description": "Nobis sed ipsam vero quod cupiditate veritatis hic.",
"name": "Flight",
"name_with_namespace": "Twitter / Flight",
"path": "flight",
"path_with_namespace": "twitter/flight",
"created_at": "2017-09-05T07:58:01.621Z",
"default_branch": "main",
"tag_list":[], //deprecated, use `topics` instead
"topics":[],
"ssh_url_to_repo": "ssh://jarka@localhost:2222/twitter/flight.git",
"http_url_to_repo": "http://localhost:3000/twitter/flight.git",
"web_url": "http://localhost:3000/twitter/flight",
"readme_url": "http://localhost:3000/twitter/flight/-/blob/main/README.md",
"avatar_url": null,
"star_count": 0,
"forks_count": 0,
"last_activity_at": "2018-01-31T09:56:30.902Z"
}
]
范围:issues
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/3/search?scope=issues&search=file"
示例响应:
[
{
"id": 83,
"iid": 1,
"project_id": 12,
"title": "Add file",
"description": "Add first file",
"state": "opened",
"created_at": "2018-01-24T06:02:15.514Z",
"updated_at": "2018-02-06T12:36:23.263Z",
"closed_at": null,
"labels":[],
"milestone": null,
"assignees": [{
"id": 20,
"name": "Ceola Deckow",
"username": "sammy.collier",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
"web_url": "http://localhost:3000/sammy.collier"
}],
"author": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"assignee": {
"id": 20,
"name": "Ceola Deckow",
"username": "sammy.collier",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
"web_url": "http://localhost:3000/sammy.collier"
},
"user_notes_count": 0,
"upvotes": 0,
"downvotes": 0,
"due_date": null,
"confidential": false,
"discussion_locked": null,
"web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
}
}
]
{{< alert type=”note” >}}
assignee
列已弃用,现显示为单个大小的数组 assignees
,以符合极狐GitLab EE API。
{{< /alert >}}
范围:merge_requests
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/3/search?scope=merge_requests&search=file"
示例响应:
[
{
"id": 56,
"iid": 8,
"project_id": 6,
"title": "Add first file",
"description": "This is a test MR to add file",
"state": "opened",
"created_at": "2018-01-22T14:21:50.830Z",
"updated_at": "2018-02-06T12:40:33.295Z",
"target_branch": "main",
"source_branch": "jaja-test",
"upvotes": 0,
"downvotes": 0,
"author": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"assignee": {
"id": 5,
"name": "Jacquelyn Kutch",
"username": "abigail",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
"web_url": "http://localhost:3000/abigail"
},
"source_project_id": 6,
"target_project_id": 6,
"labels": [
"ruby",
"tests"
],
"draft": false,
"work_in_progress": false,
"milestone": {
"id": 13,
"iid": 3,
"project_id": 6,
"title": "v2.0",
"description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
"state": "active",
"created_at": "2017-09-05T07:58:29.099Z",
"updated_at": "2017-09-05T07:58:29.099Z",
"due_date": null,
"start_date": null
},
"merge_when_pipeline_succeeds": false,
"merge_status": "can_be_merged",
"sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
"merge_commit_sha": null,
"squash_commit_sha": null,
"user_notes_count": 0,
"discussion_locked": null,
"should_remove_source_branch": null,
"force_remove_source_branch": true,
"web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
}
}
]
范围:milestones
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/3/search?scope=milestones&search=release"
示例响应:
[
{
"id": 44,
"iid": 1,
"project_id": 12,
"title": "next release",
"description": "Next release milestone",
"state": "active",
"created_at": "2018-02-06T12:43:39.271Z",
"updated_at": "2018-02-06T12:44:01.298Z",
"due_date": "2018-04-18",
"start_date": "2018-02-04"
}
]
范围:users
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/3/search?scope=users&search=doe"
示例响应:
[
{
"id": 1,
"name": "John Doe1",
"username": "user1",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
"web_url": "http://localhost/user1"
}
]
范围:wiki_blobs
{{< details >}}
- Tier: 专业版, 旗舰版
{{< /details >}}
此范围仅在高级搜索启用时可用。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/6/search?scope=wiki_blobs&search=bye"
示例响应:
[
{
"basename": "home",
"data": "hello\n\nand bye\n\nend",
"path": "home.md",
"filename": "home.md",
"id": null,
"ref": "main",
"startline": 5,
"project_id": 6,
"group_id": 1
}
]
{{< alert type=”note” >}}
filename
已弃用,建议使用 path
。两者都返回文件在存储库中的完整路径,但未来 filename
仅用于表示文件名而非完整路径。详情请参阅议题 34521。
{{< /alert >}}
范围:commits
{{< details >}}
- Tier: 专业版, 旗舰版
{{< /details >}}
此范围仅在高级搜索启用时可用。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/6/search?scope=commits&search=bye"
示例响应:
[
{
"id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
"short_id": "4109c2d8",
"title": "goodbye $.browser",
"created_at": "2013-02-18T22:02:54.000Z",
"parent_ids": [
"59d05353ab575bcc2aa958fe1782e93297de64c9"
],
"message": "goodbye $.browser\n",
"author_name": "angus croll",
"author_email": "anguscroll@gmail.com",
"authored_date": "2013-02-18T22:02:54.000Z",
"committer_name": "angus croll",
"committer_email": "anguscroll@gmail.com",
"committed_date": "2013-02-18T22:02:54.000Z",
"project_id": 6
}
]
范围:blobs
{{< details >}}
- Tier: 专业版, 旗舰版
{{< /details >}}
此范围仅在高级搜索启用时可用。
以下过滤器可用于此范围:
filename
path
extension
要使用过滤器,请在查询中包含它。例如:a query filename:some_name*
。
您可以使用通配符(*
)进行全局匹配。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/6/search?scope=blobs&search=installation"
示例响应:
[
{
"basename": "README",
"data": "```\n\n## Installation\n\nQuick start using the [pre-built",
"path": "README.md",
"filename": "README.md",
"id": null,
"ref": "main",
"startline": 46,
"project_id": 6
}
]
{{< alert type=”note” >}}
filename
已弃用,建议使用 path
。两者都返回文件在存储库中的完整路径,但未来 filename
仅用于表示文件名而非完整路径。详情请参阅议题 34521。
{{< /alert >}}
范围:notes
{{< details >}}
- Tier: 专业版, 旗舰版
{{< /details >}}
此范围仅在高级搜索启用时可用。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/6/search?scope=notes&search=maxime"
示例响应:
[
{
"id": 191,
"body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
"attachment": null,
"author": {
"id": 23,
"name": "User 1",
"username": "user1",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
"web_url": "http://localhost:3000/user1"
},
"created_at": "2017-09-05T08:01:32.068Z",
"updated_at": "2017-09-05T08:01:32.068Z",
"system": false,
"noteable_id": 22,
"noteable_type": "Issue",
"project_id": 6,
"noteable_iid": 2
}
]
项目搜索 API
在指定的项目中搜索一个术语。
如果用户不是项目的成员且项目是私有的,则对该项目的 GET
请求会导致 404
状态码。
GET /projects/:id/search
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer or string | 是 | 项目的 ID 或URL 编码路径。 |
scope |
string | 是 | 要搜索的范围。值包括 issues 、merge_requests 、milestones 和 users 。附加的范围包括 wiki_blobs 、commits 、blobs 和 notes 。 |
search |
string | 是 | 搜索术语。 |
confidential |
boolean | 否 | 按保密性筛选。支持 issues 范围;其他范围被忽略。 |
ref |
string | 否 | 要搜索的存储库分支或标签的名称。默认使用项目的默认分支。仅适用于 blobs 、commits 和 wiki_blobs 范围。 |
order_by |
string | 否 | 允许的值仅为 created_at 。如果未设置,结果将按基本搜索中的 created_at 降序排列,或按高级搜索中最相关的文档排列。 |
sort |
string | 否 | 允许的值仅为 asc 或 desc 。如果未设置,结果将按基本搜索中的 created_at 降序排列,或按高级搜索中最相关的文档排列。 |
state |
string | 否 | 按状态筛选。支持 issues 和 merge_requests 范围;其他范围被忽略。 |
响应取决于请求的范围。
范围:issues
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/12/search?scope=issues&search=file"
示例响应:
[
{
"id": 83,
"iid": 1,
"project_id": 12,
"title": "Add file",
"description": "Add first file",
"state": "opened",
"created_at": "2018-01-24T06:02:15.514Z",
"updated_at": "2018-02-06T12:36:23.263Z",
"closed_at": null,
"labels":[],
"milestone": null,
"assignees": [{
"id": 20,
"name": "Ceola Deckow",
"username": "sammy.collier",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
"web_url": "http://localhost:3000/sammy.collier"
}],
"author": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"assignee": {
"id": 20,
"name": "Ceola Deckow",
"username": "sammy.collier",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
"web_url": "http://localhost:3000/sammy.collier"
},
"user_notes_count": 0,
"upvotes": 0,
"downvotes": 0,
"due_date": null,
"confidential": false,
"discussion_locked": null,
"web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
}
}
]
{{< alert type=”note” >}}
assignee
列已弃用,现显示为单个大小的数组 assignees
,以符合极狐GitLab EE API。
{{< /alert >}}
范围:merge_requests
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/6/search?scope=merge_requests&search=file"
示例响应:
[
{
"id": 56,
"iid": 8,
"project_id": 6,
"title": "Add first file",
"description": "This is a test MR to add file",
"state": "opened",
"created_at": "2018-01-22T14:21:50.830Z",
"updated_at": "2018-02-06T12:40:33.295Z",
"target_branch": "main",
"source_branch": "jaja-test",
"upvotes": 0,
"downvotes": 0,
"author": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://localhost:3000/root"
},
"assignee": {
"id": 5,
"name": "Jacquelyn Kutch",
"username": "abigail",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
"web_url": "http://localhost:3000/abigail"
},
"source_project_id": 6,
"target_project_id": 6,
"labels": [
"ruby",
"tests"
],
"draft": false,
"work_in_progress": false,
"milestone": {
"id": 13,
"iid": 3,
"project_id": 6,
"title": "v2.0",
"description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
"state": "active",
"created_at": "2017-09-05T07:58:29.099Z",
"updated_at": "2017-09-05T07:58:29.099Z",
"due_date": null,
"start_date": null
},
"merge_when_pipeline_succeeds": false,
"merge_status": "can_be_merged",
"sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
"merge_commit_sha": null,
"squash_commit_sha": null,
"user_notes_count": 0,
"discussion_locked": null,
"should_remove_source_branch": null,
"force_remove_source_branch": true,
"web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
}
}
]
范围:milestones
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/12/search?scope=milestones&search=release"
示例响应:
[
{
"id": 44,
"iid": 1,
"project_id": 12,
"title": "next release",
"description": "Next release milestone",
"state": "active",
"created_at": "2018-02-06T12:43:39.271Z",
"updated_at": "2018-02-06T12:44:01.298Z",
"due_date": "2018-04-18",
"start_date": "2018-02-04"
}
]
范围:users
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/6/search?scope=users&search=doe"
示例响应:
[
{
"id": 1,
"name": "John Doe1",
"username": "user1",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
"web_url": "http://localhost/user1"
}
]
范围:wiki_blobs
{{< details >}}
- Tier: Professional, Ultimate
{{< /details >}}
此范围仅在启用高级搜索时可用。
此范围可用的过滤器如下:
filename
path
extension
要使用过滤器,请将其包含在查询中。例如:a query filename:some_name*
。您可以使用通配符 (*
) 进行全局匹配。Wiki blobs 搜索是在文件名和内容上进行的。搜索结果:
- 在文件名中找到的结果显示在内容中找到的结果之前。
- 可能包含同一 blob 的多个匹配项,因为搜索字符串可能在文件名和内容中都找到,或者可能在内容中多次出现。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/6/search?scope=wiki_blobs&search=bye"
示例响应:
[
{
"basename": "home",
"data": "hello\n\nand bye\n\nend",
"path": "home.md",
"filename": "home.md",
"id": null,
"ref": "main",
"startline": 5,
"project_id": 6,
"group_id": 1
}
]
{{< alert type=”note” >}}
filename
已被弃用,建议使用 path
。两者都返回文件在存储库内的完整路径,但将来 filename
仅打算是文件名而不是完整路径。
{{< /alert >}}
范围:commits
{{< details >}}
- Tier: Professional, Ultimate
{{< /details >}}
此范围仅在启用高级搜索时可用。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/6/search?scope=commits&search=bye"
示例响应:
[
{
"id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
"short_id": "4109c2d8",
"title": "goodbye $.browser",
"created_at": "2013-02-18T22:02:54.000Z",
"parent_ids": [
"59d05353ab575bcc2aa958fe1782e93297de64c9"
],
"message": "goodbye $.browser\n",
"author_name": "angus croll",
"author_email": "anguscroll@gmail.com",
"authored_date": "2013-02-18T22:02:54.000Z",
"committer_name": "angus croll",
"committer_email": "anguscroll@gmail.com",
"committed_date": "2013-02-18T22:02:54.000Z",
"project_id": 6
}
]
范围:blobs
{{< details >}}
- Tier: Professional, Ultimate
{{< /details >}}
此范围仅在启用高级搜索时可用。
此范围可用的过滤器如下:
filename
path
extension
要使用过滤器,请将其包含在查询中。例如:a query filename:some_name*
。您可以使用通配符 (*
) 进行全局匹配。Blobs 搜索是在文件名和内容上进行的。搜索结果:
- 在文件名中找到的结果显示在内容中找到的结果之前。
- 可能包含同一 blob 的多个匹配项,因为搜索字符串可能在文件名和内容中都找到,或者可能在内容中多次出现。
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/6/search?scope=blobs&search=keyword%20filename:*.py
示例响应:
[
{
"basename": "README",
"data": "```\n\n## Installation\n\nQuick start using the [pre-built",
"path": "README.md",
"filename": "README.md",
"id": null,
"ref": "main",
"startline": 46,
"project_id": 6
}
]
{{< alert type=”note” >}}
filename
已被弃用,建议使用 path
。两者都返回文件在存储库内的完整路径,但将来 filename
仅打算是文件名而不是完整路径。
{{< /alert >}}
范围:notes
{{< details >}}
- Tier: Professional, Ultimate
{{< /details >}}
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/6/search?scope=notes&search=maxime"
示例响应:
[
{
"id": 191,
"body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
"attachment": null,
"author": {
"id": 23,
"name": "User 1",
"username": "user1",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
"web_url": "http://localhost:3000/user1"
},
"created_at": "2017-09-05T08:01:32.068Z",
"updated_at": "2017-09-05T08:01:32.068Z",
"system": false,
"noteable_id": 22,
"noteable_type": "Issue",
"project_id": 6,
"noteable_iid": 2
}
]