I'm working on a task with Bitbucket API 1.0 and I need to get a list of files in a repo. While I can retrieve the entire list with the following API:
https://<url>/rest/api/1.0/projects/<project>/repos/<repo>/files?limit=1000
This brings me back all the files in the repo and I know there are thousands of files. For my task, I only need to do a shallow GET and only return all the files/folders that are one level deep. I don't see anything in the REST Call that makes this possible. Is there a way to do this with this api?
Hi @Vince Pastorella ,
Are you using bitbucket cloud? If so, this API would help - https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get
Copying from the description
The response by default is not recursive, meaning that only the direct contents of a path are returned. The response does not recurse down into subdirectories. In order to "walk" the entire directory tree, the client can either parse each response and follow the
self
links of eachcommit_directory
object, or can specify amax_depth
to recurse to.The max_depth parameter will do a breadth-first search to return the contents of the subdirectories up to the depth specified. Breadth-first search was chosen as it leads to the least amount of file system operations for git. If the
max_depth
parameter is specified to be too large, the call will time out and return a 555.
Hope that helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.