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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Download a single file from a repo using python

So I have been struggling with this for a while now.


I need to simply download a file from a private repo using python (I want to use this file later on the same python script). 


Due to the lack of documentation (and all my failed attempts) now I'm simply trying to make it work via curl. I switched to curl as a way of finding the right structure (there's a lot more issues on internet using curl than python) to later be able to translate it into python.

But still no luck. I've tried:

curl -O -u username:password<account>/<repo-name>/raw/<commit-sha-or-HEAD>/<filename
curl --user "


with no luck. 

When it says password in the curl commands I've used an app password that has read access to the repo.



So can anyone point me in the right direction? At this point I dont care if it's Python or curl :)


1 answer

1 accepted

2 votes
Answer accepted

Hello @Martí Bastida Comas 

Thank you reaching out Atlassian Community.

Can you please try the following curl command?



Arda Duman

Hi, thanks for your response.


This command at least doesn't give an error:

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0


But still the file downloaded is blank, There's nothing in it.

R Arda Duman Atlassian Team Jan 13, 2022


Can you send the command with -v flag to see verbose output?

curl -u username:password -o file.txt -v


Arda Duman

Great the problem was mine. I was input the email instead of the username.


Now it works.



One last thing: Could you point me the specific page where this endpoint is documented? It's probably me but if i search the bitbucket 2.0 REST API I can't find this. I ask it because I will need other info (like list the directories in a folder) and I don't want to have to open a question for each endpoint :)

R Arda Duman Atlassian Team Jan 13, 2022


I am glad that your problem resolved. You can refer to for further information about cloud REST APIs.

Arda Duman

That's where I was looking for. But for example, the endpoint you have given me is not listed on the repositories section. The closest one is the Get a repository endpoint. Is this correct or I'm looking somewhere not right?


How could one (for example) list all the directories in a specific folder?

R Arda Duman Atlassian Team Jan 13, 2022

You can refer to the section Get file or directory contents.

Arda Duman

Hi @R Arda Duman 


I have been trying to do the same that you have suggested but instead of the raw file content, I am getting the output in HTML.

Could you please help me out ?

My repository is a private one.

Like # people like this

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events