when i sent request-url like “curl -s https://api.bitbucket.org/2.0/repositories/seanfarley/mercurial/refs/branches”, i can only get 10 branches, is there any way to get all existing branches? Thanks!
Based on Bitbucket’s documentation, the default page length is 10 with a maximum of 100. If you have more than 100 branches, then you need to get the next page.
Hope this helps.
Thanks, Expert. I mean 1. how to modify default page length 2. if I have more then 100 branches, how to get next 100 branches? Thanks!
To modify the page length, try passing a
pagelen query parameter. Using your sample (which currently returns 2 branches in 1 page), add
pagelen like this
curl -s https://api.bitbucket.org/2.0/repositories/seanfarley/mercurial/refs/branches?pagelen=1. This will result in a reduced result set of length 1.
To answer your 2nd question, in the previous step you’ll notice that there is now
next which is a link that points to the next page using the same page length; basically, it uses
page query parameter. You’ll use that one to paginate to the next page/s. Here’s the pagination docs, feel free to use the sample repository there. The sample is for commit but same concept applies with a branch.