repository

Search the code of a repository

Changed on

The files of the ref are searched with git grep, which returns at most 50 files. The result window is limited to 1000 files (page * limit).

get/repos/{owner}/{repo}/code/search

Request

  • Base URL
    https://demo.gitea.com/api/v1
  • Auth
    • HTTP basic
    • or API key in query parameter token
    • or API key in query parameter access_token
    • or API key in header Authorization
    • or API key in query parameter sudo
    • or API key in header Sudo
    • or API key in header X-GITEA-OTP

Path parameters

ownerstring required

owner of the repo

repostring required

name of the repo

Query parameters

qstring required

Terms must all occur in a file. Supports "exact phrases", /regexp/ and path:DIR. Language and repository qualifiers are not supported.

refstring

The name of the commit/branch/tag. Default to the repository’s default branch

pageinteger

page number of results to return (1-based)

limitinteger

page size of results

Response

CodeSearchResults

incomplete_resultsboolean

Search stopped early

total_countinteger

Example response

{
  "items": [
    {
      "repository": {
        "repo_transfer": {
          "teams": [
            {
              "units": [
                "repo.code",
                "repo.issues",
                "repo.ext_issues",
                "repo.wiki",
                "repo.pulls",
                "repo.releases",
                "repo.projects",
                "repo.ext_wiki"
              ],
              "units_map": {
                "repo.code": "read",
                "repo.ext_issues": "none",
                "repo.ext_wiki": "none",
                "repo.issues": "write",
                "repo.projects": "none",
                "repo.pulls": "owner",
                "repo.releases": "none",
                "repo.wiki": "admin"
              }
            }
          ]
        }
      }
    }
  ]
}

Changes