I've been able to successfully authenticate and use other areas of the 2.0 API and now I need to use the API do the equivalent of the "Download repository" link on the "Downloads" section in the UI. I just need a copy of the files, not a clone of the complete repository.
Using the 2.0 API I have the following:
https://api.bitbucket.org/2.0/repositories/{username}/{repository}/downloads
I can successfully use the call above but it returns the data below, implying there aren't any downloads.
{"pagelen": 10, "values": [], "page": 1, "size": 0}
What do I need to do to get a zip of all of the files in the repository? Thanks.
Hi Brian, welcome to the Community!
That string will return a list of download links associated with the repository, that means any other files you have uploaded to that section but not the source of the repo itself. As a picture is worth a thousand words:
- No downloads to show (although the link to download the repo is there)
- Downloads to be shown (I added a few files to the list)
To download the zip with a copy of the files from your repo, you can use the following:
https://bitbucket.org/<username>/<repo-name>/get/master.zip
Hope that helps!
Ana
As a follow-up to the above, here is an example using curl:
curl --request GET \
--url https://bitbucket.org/<workspace>/<repo_slug>/get/<default_branch>.zip \
-u <username>:<app_password> \
--output repo.zip
Please note the following:
- default_branch: the value has to match the default/main branch for the repository. Other branch or tag names can be used as well as a commit hash.
- username: the username is the Bitbucket one as available in the https://bitbucket.org/account/settings/ page. It doesn't contain the email domain, just the username.
- app_password: the example uses an app password for the authentication. Other authentication methods (e.g. Access tokens provided as Bearer tokens or basic authentication are not supported)
This is not an official REST API endpoint and could change without any notice.
Cheers,
Caterina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Inside a zip file with source of branch we have additional top level. How i can get zip file with same stricture as repository? Or probably i can provide a start path as a parameter(--prefix in git archive)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.