Hi Team,
I'm trying to get a folder in my repo as zip or download a file in my repo in it's original format.
All I could find is /src API to get meta data of folder or /src API to get content of the file.
I could download entire Repo as zip using /get API in downloads.
However I could not find ways to download individual files and folder from bitbucket remote Repo
Hello @Gokul Rajan and welcome to the community!
While it's not directly possible to download a folder using the Bitbucket Cloud API, you can use the Get a file or directory contents to list the files within a folder and then make additional API calls to download each file individually.
The sequence would be like the following:
curl -u USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/repositories/workspace/repository/src/<branch>/test_folder
curl -u USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/repositories/workspace/repository/src/<branch>/test_folder/my_file.txt -o my_file.txThis API endpoint will return the raw content of the file, so we -o flag in the curl command to save the result into a file.
Another option, as you mentioned, is to download an archive of the entire repository at a given branch/tag, and then extract the archive and get the folder you need :
curl -u USERNAME:APP_PASSWORD https://bitbucket.org/<workspace>/<repository>/get/<branch or tag>.zip -o my_repo.zip
Hope that helps! Let me know in case you have any questions.
Thank you, @Gokul Rajan !
Patrik S
Hi @Patrik S ,
Thank you for your response.
We have 1000s of files in each folder then we have to make calls individually for each files. It is a heavy process. Please take it as a feature request to download units of files and folders as zip.
Also for current implementation may I know what is the rate limit for API in bitbucket? What would be the ideal delay between each request?
Thank you,
@Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.