Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Is it possible to use an API to access the contents of a private repo?

I am working on a VUE project where I'd like to be able to create a list of files which are in my private repo and then use that list to copy the matching files from my private repo into a zip folder for the user to download.

I have the create list and download zip folder functionality figured out so far.

However I am totally new to using APIs so I'm looking for advice on whether this is possible or not and what the best way to go about it would be.

1 answer

1 accepted

0 votes
Answer accepted

Hi Christopher,

Do you need help with getting a list of files via API or the contents of these files? Or perhaps both?

Could you also please let us know whether this concerns repositories hosted in Bitbucket Cloud or Bitbucket Server?

Kind regards,

Both for different purposes.

I'm not sure what the difference between cloud and server is. It's a repository on

Hi Christopher,

Thank you for your reply. If the repository is hosted on, then this is Bitbucket Cloud (Bitbucket Server is a product you install on your own servers, so this is self-hosted).

For Bitbucket Cloud, you can use this endpoint to get a list of the root directory on the main branch of the repo (at the latest commit):

An example call could be the following:

curl -sL -X GET --user username:password

username is the username of a Bitbucket account with access to the repo
password is this account's password or an app-password with appropriate permissions
repo-owner is the workspace ID of the workspace that owns the repo
repo-slug is the slug for this repository

If you want to get a list of the files/directories at a specific commit, you can specify the commit as follows:

curl -sL -X GET --user username:password

In order to get the contents of a specific file or a directory, you can use the following endpoint:

An example call would be the following:

curl -sL -u username:password -H "Content-Type: application/x-www-form-urlencoded"

commit-hash replace with the hash of the specific commit you are interested in
file_path is either the path+name of a specific file, OR the path of a directory in the repo

In the call above, if file_path is the path of a directory in the repo, then the call will return the contents of this directory.

If file_path is the path+name for a specific file, you will get the contents of this file. You can then redirect the output to a file named e.g. file1 on your machine as follows:

curl -sL -u username:password -H "Content-Type: application/x-www-form-urlencoded" > file1

I hope this helps, please feel free to let me know if you have any questions.

Kind regards,

Like christopherduffy86 likes this

Thank you for your help.

I am looking forward to testing this myself.

You are very welcome, please feel free to reach out if you have any questions!

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...

291 views 2 10
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