How to get the size of all repositories in a workspace
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
You want to get the size of all repositories in your workspace.
Solution
Bitbucket UI
A column Size exists in the Repositories page of a workspace that displays each repo's size:

Curl
This information can be obtained through the Bitbucket Cloud API.
As an example, you can use the API call below to return all the repositories in a workspace filtered by project name, repository name(workspace/repository name), description, and size:
curl -u <atlassian_account_email>:<api_token> “https://api.bitbucket.org/2.0/repositories/<workspace-id>?fields=values.full_name,values.description,values.size,values.project.name&pagelen=100&page=1"
Replace the following values:
<atlassian_account_email> with your Atlassian account email address
<api_token> with an API token that has at least the scope read:repository:bitbucket
<workspace-id> with the ID of the workspace
If you are using an API interfacing tool such as Postman or Insomnia, you can use a normal URL (with encoding):
https://api.bitbucket.org/2.0/repositories/<workspace-id>?fields=values.full_name,values.description,values.size,values.project.name&pagelen=100&page=1
The size is displayed in Bytes.
If you want to save these results in CSV format, run the following commands from a terminal that supports Linux.
# From the terminal, please make sure to install jq if not installed
# Command to save the results in json file in the current directory
curl -X GET -u <atlassian_account_email>:<api_token> “https://api.bitbucket.org/2.0/repositories/<workspace>?fields=values.full_name,values.description,values.size,values.project.name&pagelen=100&page=1" | jq '.' > result.json
# Command to convert the result in csv format
jq -r '.values[] | [.project.name, .full_name, .description, .size] | @csv' result.json > result.csv
Was this helpful?