Gitlab repo explorer

Using Gitlab's public API, you have to build a file explorer for public repositories (similar to what they already have)

Gitlab file explorer

You will need to get the project id, and then you can access these API URLs to build the explorer:

  • For trees (directories): https://gitlab.com/api/v4/projects/27081175/repository/tree and then append ?path=path/inside/the/tree to list the contents of a subtree. You can also pass the ref query parameter to reference a certain branch.
  • For file contents: https://gitlab.com/api/v4/projects/27081175/repository/blobs/:id where:id is the id of the blob you want to display. Alternatively, you can also use the endpoint https://gitlab.com/api/v4/projects/27081175/repository/files/:path?ref=mainto fetch more information about a certain file (:path is the full path to the file, url encoded). you can also pass the ref parameter to select a certain branch.