GitLab API

GitlabTool

Actions1095

Projects → getApiV4ProjectsIdRepositoryTree

AI-generated

Summary

Retrieve the repository tree of a specific GitLab project by its ID or URL-encoded path, with optional filters and pagination controls.

Inputs

  • id (required) — The ID or URL-encoded path of the target GitLab project.
  • ref — The name of the repository branch or tag to query; defaults to the default branch if omitted.
  • path — Specific path within the repository tree to list.
  • recursive — Boolean flag to get the tree recursively.
  • page — Page number for pagination.
  • per_page — Number of items to return per page.
  • pagination — Pagination method, can be 'legacy', 'keyset', or 'none' (where 'none' is only valid if 'recursive' is true).
  • page_token — Token indicating the start record for keyset pagination.

Output shape

a list of repository tree items, each representing a file or directory within the project at the requested path and ref.

Supports pagination via 'page', 'per_page', 'pagination', and 'page_token' parameters; 'recursive' controls depth of tree retrieval. Returns data according to GitLab API v4 /projects/:id/repository/tree endpoint.

Examples

Example 1: Get root repository tree of project ID 1 on default branch

Set 'id' to '1'; leave other parameters default.

Example 2: Get files recursively under 'src' path on branch 'main'

Set 'id' to project ID, 'ref' to 'main', 'path' to 'src', and 'recursive' to true.

Links

Discussion