0

recently I found that I can use Rest Api Bitbucket to download repositories. I read the docs, but so far I didn't manage to download any files, but some HTTP headers using curl.

Can someone give me a concrete example on how to use the API?

I understand that the command is curl https://api.bitbucket.org/2.0/repositories/, but my bitbucket links is something like this

http://company repository site/projects/project/repos/repo/

UPDATE 1

**

I managed to download a file using curl using the syntax: curl -u user:pass http://company_repository_site/projects/my_project/repos/my_repo/my_file.ext?raw but I would still like to know how can this be done using the REST Api

**

Thanks, Daniel.

2 Answers 2

1

In the end, I used

curl -u user:pass `bitbucketCompanyServer`/rest/api/1.0/projects/`project`/repos/`repository`/browse/`fullPathToFileOnBitbucket`?at=`commit` > output

Hope this helps

Sign up to request clarification or add additional context in comments.

Comments

0

As of May 2024, the option to use an SSH key to download files from the Bitbucket downloads section is still not implemented. The workaround provided by Daniel does not work as they changed the API. The following example works for me:

curl -LO --request GET --url https://api.bitbucket.org/2.0/repositories/{YOUR_WORKSPACE}/{YOUR_REPO}/downloads/{YOUR_FILE_NAME} --header 'Authorization: Bearer YOUR-REPO-ACCESS-TOKEN'

Note that in this case, the token is generated at the repository level because, for workspace-level access, you would need a premium account. Here is the official BitBucket documentation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.