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

How can I get page 2 with a pagelen=100 when querying a list of repos with bitbucket API 2.0?


I have run into a cumbersome limitation of the bitbucket API 2.0 - I am hoping there is a way to make it more usable.

When one wants to retrieve a list of repositories from the bitbucket API 2.0, this url can be used:{teamname}

This returns the first 10 repos in the list. To access the next 10, one simply needs to add a page parameter:{teamname}?page=2

This returns the next 10. One can also adjust the number of results returned using the pagelen parameter, like so:{teamname}?pagelen=100

The maximum number can vary per account, but 100 is the maximum any team is able to request with each API call. The cumbersome part is that I cannot find a way to get page 2 with a pagelength of 100. I have tried variations on the following:{teamname}?pagelen=100&page=2{teamname}?page=2&pagelen=100

I've also tried using parameters such as limit or size to no avail. Is the behavior I seek even possible? (Apparently, it is - see my replies to Noah's answer below)

6 answers

1 accepted

4 votes
Answer accepted

It appears this is fixed. I was able to use pagelen=100&page=2 in my query and received the extra 15 repositories that were missing from page 1.

That's good news, Noah - however, I am still not able to see a returned list of repos for that combination of parameters (`pagelen=100&page=2`).  (The ones that I listed above as working, still work for me.) Is there any other part of your command that could be helping to make the query work for you?

Here is my whole bash script:


curl -k -s "https://$LOGIN$SERVER/2.0/repositories/xxxxxxxx?role=member&pagelen=100" | jq -r ".values[].slug"

curl -k -s "https://$LOGIN$SERVER/2.0/repositories/xxxxxxxx?role=member&pagelen=100&page=2" | jq -r ".values[].slug"

Like Nick D. likes this

Wouldn't you know it - the only thing I was missing was to put the url in quotes.  All of the other queries work without quotes around the url.

Moral of the story: If you want to use multiple parameters with the 2.0 api, the entire url needs to be in quotes.

Thanks very much for your help.

Like ecm likes this
1 vote
Deleted user Mar 04, 2020

pagelen > 10 does not work. It still only returns the first 10

Guys, you need to fix this. I can't list more than 25 branches in a repository with the v2 API, even on Bitbucket Server? C'mon now. This is a duplicate of:

Hey, Kevin - I don't know if it's too late for you, but I posted my workaround below. And Noah helped me isolate the actual fix above...




#!/usr/bin/env sh

# prerequisites: `httpie`, `jq`, GNU's `parallel`. e.g. brew install <package> # there is max 100 page length n pages where n is 100 length page. Execute one one by one (there is no way you'll get more than 100 times parallelization)

# in `.values[].links.clone[1].href` `1` is for SSH, where `0` would be for HTTPS.

http https://<user>:<pass><account_name> pagelen==100 page==<page_num> | jq -r '.values[].links.clone[1].href' | parallel git clone

# Voila it takes approx 1-2 minutes to clone a 100 repos.

I figured out a workaround:

It would seem this behavior is not possible at this time. I was able to get around this by creating a bash script that looped through each page of 10 results, adding each new 10 repos to a temporary file and then cloning into those 10 repos. The only manual thing that needs to be done is to update the upper limit in the for loop to be the last page expected.

Here is an example script:

for thisPage in {1..[Last Page Expected]}
curl[organization]?page=$thisPage -u [username]:[password] > repoinfo

for repo_name in `cat repoinfo | sed -r 's/("slug": )/\n\1/g' | sed -r 's/"slug": "(.*)"/\1/' | sed -e 's/{//' | cut -f1 -d\" | tr '\n' ' '`
echo "Cloning " $repo_name
git clone https://[username][organization]/$repo_name
echo "---"

Much help was gleaned from:
and Thanks!

You can limit your request to just a single project this way. Max page length is 100.


curl -s[organization]\?pagelen=100\&q="project.key=\"[PROJECTKEY]\""\&page=$thisPage -u [username]:[password]
Like Terrance Teoh likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,209 views 2 9
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you