-
Type:
Suggestion
-
Resolution: Won't Fix
-
Component/s: Repository - Source
-
None
Hey guys,
Background
I'm an engineer in a company that develops an IDE-like web application that has an integration with Bitbucket using your great API, aimed at our customers who use Bitbucket as their Git provider. A main part of the integration includes our customers selecting a specific repository and a commit, seeing this repo's files tree, and selecting a specific file (either by searching by name or toggling folders to find it).
Problem
We're using the src resource (https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/src/%7Bcommit%7D/%7Bpath%7D) in order to retrieve the files tree of a repo, however, this resource is limited to 100 items (files/directories) per HTTP request, and we find ourselves sometimes make above 100 requests, one by one, in order to retrieve a single repo tree, in a process that can sometimes take 1 minute or even more. In addition, the API does not return any indicator for how big is the repo so we have no idea how many more pages are there to fetch, and we can't indicate to the user anything about the fetching progress, or even decide not to fetch because it's too big before already making dozens of requests to find it out.
While trying to find an alternative solution we examined your search resource (https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams/%7Busername%7D/search/code) but the fact that it is limited only to the main/master branch of a repo and we can't search in a specific commit made this option irrelevant for us.
This is not a problem we ran into when integrating our web app with any other Git provider, and the situation is that our customers that use Bitbucket as their Git provider get much worse experience in comparison to others. In addition, we flood your servers with dozens of requests for fetching just one repo.
Suggestions / Requests:
- The best solution for us is you guys creating a resource that returns a repo's tree recursively. The only data we really need is the file/folder name and contents. While we researched the issue we found out you actually already got this exact resource in your internal API (https://bitbucket.org/!api/internal/repositories/[project]/[repo_name]/tree/[commit_sha]/?no_size=1). Creating a similar resource in the public API for us to use would be absolutely awesome. This type of resource is something that exists in every other API of a Git provider we tried to integrate to.
- Adding features to the search resource can also do the trick for us. Searching for matches to a string in a specific commit/branch of a specific repo can enable us to give our customers the best experience using Bitbucket without fetching the whole tree of a huge repository. (Bonus: filter by match type. For example - only path matches, no code matches)
- That's far from being an ideal solution, but as a minimal help, adding to the existing src resource, next to the 'page' attribute a 'total_pages' attribute, will allow us to at least indicate our customers their progress in the fetching or take a decision in our code to handle the fetching differently.
Thanks a lot in Advance ![]()