Use this API to search across GitLab in an instance, a group, or a project, and to retrieve information about advanced search migrations.
Every call to this API requires authentication. Retrieving advanced search migrations requires administrator access.
Some scopes are available for basic search. When advanced search or exact code search is enabled, additional scopes become available. To use basic search instead, see specify a search type.
These endpoints support offset-based pagination.
Search on GitLab within a group
GET /api/v4/groups/{id}/(-/)search
This feature was introduced in GitLab 10.5.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
searchQuery, | String | The expression it should be searched for |
scopeQuery, | String | The scope of the search Allowed values: projects,groups,issues,work_,merge_,milestones,usersMinimum length: 1 |
stateQuery | String | Filter results by state Allowed values: all,opened,closed,merged |
confidentialQuery | Boolean | Filter results by confidentiality |
typeQuery | Array of strings | Filter work items by type. |
include_Query | Boolean | Includes archived projects in the search. Default: false |
fieldsQuery | Array of strings | Array of fields to search. |
languageQuery | Array of strings | Array of languages to filter blobs by language |
label_Query | Array of strings | Array of labels to filter work_ |
source_Query | String | Filter merge requests by source branch Maximum length: 255 |
target_Query | String | Filter merge requests by target branch Maximum length: 255 |
not_Query | String | Exclude merge requests by source branch Maximum length: 255 |
not_Query | String | Exclude merge requests by target branch Maximum length: 255 |
author_Query | String | Filter merge requests by author username Maximum length: 255 |
not_Query | String | Exclude merge requests by author username Maximum length: 255 |
exclude_Query | Boolean | Exclude forked projects from search results. |
num_Query | Integer | Number of context lines around each match. Maximum: 20Minimum: 0 |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | — |
400 | Bad Request | — |
404 | Not Found | — |
Search a project
GET /api/v4/projects/{id}/(-/)search
Searches for content in a specified project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
searchQuery, | String | The expression it should be searched for |
scopeQuery, | String | The scope of the search Allowed values: issues,work_,merge_,milestones,notes,wiki_,commits,blobs,usersMinimum length: 1 |
refQuery | String | The name of a repository branch or tag. |
stateQuery | String | Filter results by state Allowed values: all,opened,closed,merged |
confidentialQuery | Boolean | Filter results by confidentiality |
typeQuery | Array of strings | Filter work items by type. |
fieldsQuery | Array of strings | Array of fields to search. |
languageQuery | Array of strings | Array of languages to filter blobs by language |
label_Query | Array of strings | Array of labels to filter work_ |
source_Query | String | Filter merge requests by source branch Maximum length: 255 |
target_Query | String | Filter merge requests by target branch Maximum length: 255 |
not_Query | String | Exclude merge requests by source branch Maximum length: 255 |
not_Query | String | Exclude merge requests by target branch Maximum length: 255 |
author_Query | String | Filter merge requests by author username Maximum length: 255 |
not_Query | String | Exclude merge requests by author username Maximum length: 255 |
num_Query | Integer | Number of context lines around each match. Maximum: 20Minimum: 0 |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | — |
400 | Bad Request | — |
404 | Not Found | — |
Search an instance
GET /api/v4/search
Searches for a term across the entire GitLab instance. The response depends on the requested scope.
Parameters
| Name | Type | Description |
|---|---|---|
searchQuery, | String | The expression it should be searched for |
scopeQuery, | String | The scope of the search Allowed values: projects,groups,issues,work_,merge_,milestones,snippet_,usersMinimum length: 1 |
stateQuery | String | Filter results by state Allowed values: all,opened,closed,merged |
confidentialQuery | Boolean | Filter results by confidentiality |
typeQuery | Array of strings | Filter work items by type. |
include_Query | Boolean | Includes archived projects in the search. Default: false |
fieldsQuery | Array of strings | Array of fields to search. |
languageQuery | Array of strings | Array of languages to filter blobs by language |
label_Query | Array of strings | Array of labels to filter work_ |
source_Query | String | Filter merge requests by source branch Maximum length: 255 |
target_Query | String | Filter merge requests by target branch Maximum length: 255 |
not_Query | String | Exclude merge requests by source branch Maximum length: 255 |
not_Query | String | Exclude merge requests by target branch Maximum length: 255 |
author_Query | String | Filter merge requests by author username Maximum length: 255 |
not_Query | String | Exclude merge requests by author username Maximum length: 255 |
exclude_Query | Boolean | Exclude forked projects from search results. |
num_Query | Integer | Number of context lines around each match. Maximum: 20Minimum: 0 |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | — |
400 | Bad Request | — |