Search API

You can search for resources at the top level, in a project or in a group. Searches are based on a scope (issues, merge requests, and so on) and a search string. The following constants are provided to represent the possible scopes:

  • Shared scopes (global, group and project):

    • gitlab.SEARCH_SCOPE_PROJECTS: projects

    • gitlab.SEARCH_SCOPE_ISSUES: issues

    • gitlab.SEARCH_SCOPE_MERGE_REQUESTS: merge_requests

    • gitlab.SEARCH_SCOPE_MILESTONES: milestones

    • gitlab.SEARCH_SCOPE_WIKI_BLOBS: wiki_blobs

    • gitlab.SEARCH_SCOPE_COMMITS: commits

    • gitlab.SEARCH_SCOPE_BLOBS: blobs

    • gitlab.SEARCH_SCOPE_USERS: users

  • specific global scope:

    • gitlab.SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES: snippet_titles

  • specific project scope:

    • gitlab.SEARCH_SCOPE_PROJECT_NOTES: notes



Search for issues matching a specific string:

# global search, 'regression')

# group search
group = gl.groups.get('mygroup'), 'regression')

# project search
project = gl.projects.get('myproject'), 'regression')

The search() methods implement the pagination support:

# get lists of 10 items, and start at page 2, search_str, page=2, per_page=10)

# get a generator that will automatically make required API calls for
# pagination
for item in, search_str, as_list=False):

The search API doesn’t return objects, but dicts. If you need to act on objects, you need to create them explicitly:

for item in, search_str, as_list=False):
    issue_project = gl.projects.get(item['project_id'], lazy=True)
    issue = issue_project.issues.get(item['iid'])
    issue.state = 'closed'