The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket REST API can I do a shallow GET of repo files?

Vince Pastorella
April 10, 2024

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?  

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Hariharan Iyer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 10, 2024

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 each commit_directory object, or can specify a max_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!

TAGS
AUG Leaders

Atlassian Community Events