Clone all bitbucket projects
BBA=MyUserName; curl --user ${BBA} https://api.bitbucket.org/2.0/repositories/${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 git clone
The above curl call will connect to the server using your username and return the list of repositories that are available to your account.
Please note that you need to provide you username NOT your email.
If you make these calls using the email that was used to register the account, then the call will fail.
After the call succeeds, the results will be filtered and each repository will be cloned to the current folder.
In case your ssh key is locked via a password, each time a clone operation will start, you will be asked for the password.
Example:
BBA="bytefreaks"; curl --user ${BBA} https://api.bitbucket.org/2.0/repositories/${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 git clone
Enter host password for user 'bytefreaks':
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3834 100 3834 0 0 4414 0 --:--:-- --:--:-- --:--:-- 4411
Cloning into 'bluetoothclicker'...
Warning: Permanently added the RSA host key for IP address '104.192.143.1' to the list of known hosts.
Enter passphrase for key '/home/bytefreaks/.ssh/BitBucket/id_rsa':
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
Cloning into 'watch'...
Enter passphrase for key '/home/bytefreaks/.ssh/BitBucket/id_rsa':
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
List all bitbucket projects
In case what you want is just to list your repositories, execute the following:
curl --user ${BBA} https://api.bitbucket.org/2.0/repositories/${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 echo
Usage instructions: set your username to the BBA variable and execute.
BBA="bytefreaks"; curl --user ${BBA} https://api.bitbucket.org/2.0/repositories/${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 echo
Enter host password for user 'bytefreaks':
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3834 100 3834 0 0 3543 0 0:00:01 0:00:01 --:--:-- 3546
ssh://[email protected]/bytefreaks/bluetoothclicker.git
ssh://[email protected]/bytefreaks/watch.git
This post is also available in: Greek



bitbucket has pagination on this query (https://confluence.atlassian.com/bitbucket/version-2-423626329.html#Version2-Pagingthroughobjectcollections).
If you want to receive more data per call you have two options:
a) Either make the first call and then follow the links marked in the “next” field
b) or increase the page length size to something bigger (e.g https://api.bitbucket.org/2.0/repositories?pagelen=100) .
In case, you know the expected length of the response, try setting the pagelen value to the length you expect to get and you will get all data in one call.
Caveat: If pagelen is too ‘big’, the server will return an error message instead of the results, so always try to keep pagelen as small as possible.
Looks like the limit is 100.