Code

Search repository code

Search for text patterns in a repository's source code using the underlying provider's code search API (GitHub or GitLab). Returns matching file paths, line numbers, and preview snippets. Supports GitHub and GitLab repositories only (Bitbucket is not supported). Note: the ref parameter is supported only for GitLab -- GitHub always searches the default branch. Use pathPrefix to narrow results to a specific directory.

post/api/v2/code/search

Request

  • Base URL
    https://zeropath.com
  • Auth
    API key in header X-ZeroPath-API-Token-Id and API key in header X-ZeroPath-API-Token-Secret

Request body

organizationIdstring

Organization that owns the repository.

repositoryIdstring required

Repository to search within.

querystring required

Text search query to match against file contents. This is a literal text search (not regex) performed via the repository provider's code search API (GitHub or GitLab).

refstring

Branch, tag, or commit ref to search. Only supported for GitLab repositories; the request will be rejected if provided for a GitHub repository. Omit to search the default branch.

pathPrefixstring

Restrict search results to files under this directory path prefix (e.g. "src/services/"). Useful for narrowing results in large repositories.

limitinteger

Maximum number of search results to return. Defaults to 10.

Response

Search results

provider'github' | 'gitlab' required

Repository provider that served the request. Only providers with native code-inspection APIs are supported.

repositoryIdstring required
querystring required
refstring nullable required

Effective ref searched. Null when provider does not support explicit ref search.

pathPrefixstring nullable required
hasNextPageboolean required

True when the provider indicates an additional search page is available.

totalMatchesinteger nullable required

Changes

No recorded changes to this operation across all 1 revision of this API.