Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How Download Repository as ZIP file via API 2.0

I have read through all the relevant questions but did not see an answer to this specific question:

I need to download the repository (as an archive file) via the API v2.0 via node app.  There will not be any user context for the request so I need to authenticate the request. I have been using Basic auth (using an app password) for the other api requests I have been using.

This url was suggested in one posting and it works from Postman:<workspace>/<repoSlug>/get/

but I need to make the request via axios, and am having a hard time passing the proper authentication. 

This is the current attempt that returns a 401:

  method: 'get',
  responseType: 'stream',
  headers: { auth: { username: secret.username, password: secret.password }}

I would rather make the request to the API, but have not found this functionality in the version 2 API.

2 answers

1 accepted

0 votes
Answer accepted

I was finally able to get this to work in a Node.js app passing Basic auth parameters.  I thought i would post this for people with the same question.

See code below:


 // This will download the repository as zip file returning data as stream.

async _download (url, username, password) {
// where 'url' is something like:
// /${workspace}/${repoSlug}/get/${whateverNameYouWant}.zip

const auth = new Buffer.from(`${username}:${password}`).toString('base64');
const fileResponse = await axios.request(

method: 'get',
baseURL: '',
url: url,
responseType: 'stream',
headers: {
Authorization: `Basic ${auth}`


0 votes

Hi @Corey Malcom and welcome to the community.

I'm afraid that we don't have any API endpoint that downloads a zip file of the repository.

We have a feature request about this in our issue tracker, that you can vote for and add yourself as a watcher:

The workaround is indeed to use the following:

curl -u username:app-password<workspace-id>/<repo-slug>/get/ --output

I am not familiar with axios, so I'm not sure how to troubleshoot the error you are getting. A 401 response is usually associated with invalid authentication credentials, so I would suggest double checking if you're using an app-password that has appropriate permissions.

If you are able to successfully retrieve the zip via a curl command or Postman using the same app-password as in axios, I would recommend reaching out to the support team of axios. I believe they're better equipped to troubleshoot why the request is failing, when it succeeds with other tools using the same url and credentials.

Kind regards,

@Theodora Boudale  Thank you for the response, but I had already found that curl command, and was looking for an API endpoint for this.  I did however finally get this to work via a node app.  I am going to post the answer below.

Like Theodora Boudale likes this

Good to hear that you managed to get this to work, and thank you for posting the solution!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,706 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you