size of stash repositories via rest

we've got a large number of repos and I would like to get an overview of the sizes of each of these repos. Is there a way to get the repository size available under settings/repository details via REST API call?

2 answers

1 accepted

0 votes
Accepted answer

Hi Robbin,

Unfortunately that information isn't directly accessible via any Stash REST API:

It would be trivial to add this to a plugin - you just need to expose this method:

Let me know if you're interesting, I'm happy to show you how this could be done.



hi, I tried last time to write plugins, and currently I simply don't have the time right now to learn java, eclipse, maven etc all things that are needed to write plugins. If you can show me to to get the repository size count from stash that would be appreciated.

that was exactly what I needed! Could be nice if the rawSize and size were parameters for /rest/reposize/latest/projects/$proj/repos/$repo, but this absolutely works! thank you, it's very much appreciated.

Hi Robbin, what do you mean parameters sorrry?

what I mean was that it would be nice it sizeRaw and size were part of the json parameters returned by /rest/api/1.0/projects/$prj/repos/$repo, but your solution works excellent. And I do appreciate the example source code, I'll have a look at it when time allows and see if I can pick up writing plugins.

might be my vault, my brain hurts from trying to juggle to many tasks at the same time.

My first thought was to look for repository sizes when doing for example: "curl". I was hoping that sizeRaw and size would have been part of the json string returned.

My apologies Robbin, I'm a little slow this morning, I'm still not sure what you mean (and would like to). Could you show me an example of the JSON output you were thinking of?

Ohhh. Now I see.

Yeah that's not really possible in a plugin - I would have to update core Stash (and then you would have to wait for the next release). Given that getting the size of the repository is not cheap/free I suspect that's not likely to happen. Sorry. :(

ok, perhaps it might become available as /rest/api/1.0/projects/{}/repos/{}/size or /rest/api/1.0/projects/{}/repos/{}/settings one day. Until then I'm good with this plugin.

Does this plugin still work with the newer 5.x versions of Bitbucket?

Looks like bit bucket makes following simple AJAX call (http get) when it tries to get the aprox size on it's UI:

https://<Git URL>/projects/<project name>/repos/<repo name>/sizes

It can easily be converted to a curl and can work as an API...

Yes this is do-able gives back the following json

{u'attachments': 0, u'repository': 642}


Thanks for the answer, i guess this can change at any time but it's better than nothing.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,909 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you