v2

latestOpenAPI 3.0.02026-08-013312111.4 MB
Refs

List open branches

Returns a list of all open branches within the specified repository. Results will be in the order the source control manager returns them.

Branches support filtering and sorting that can be used to search for specific branches. For instance, to find all branches that have "stab" in their name:

curl -s https://api.bitbucket.org/2.0/repositories/atlassian/aui/refs/branches -G --data-urlencode 'q=name ~ "stab"'

By default, results will be in the order the underlying source control system returns them and identical to the ordering one sees when running "$ git branch --list". Note that this follows simple lexical ordering of the ref names.

This can be undesirable as it does apply any natural sorting semantics, meaning for instance that tags are sorted ["v10", "v11", "v9"] instead of ["v9", "v10", "v11"].

Sorting can be changed using the ?q= query parameter. When using ?q=name to explicitly sort on ref name, Bitbucket will apply natural sorting and interpret numerical values as numbers instead of strings.

get/repositories/{workspace}/{repo_slug}/refs/branches

Query parameters

qstring

Query string to narrow down the response as per filtering and sorting.

sortstring

Field by which the results should be sorted as per filtering and sorting. The name field is handled specially for branches in that, if specified as the sort field, it uses a natural sort order instead of the default lexicographical sort order. For example, it will return ['branch1', 'branch2', 'branch10'] instead of ['branch1', 'branch10', 'branch2'].

Response

A paginated list of branches matching any filter criteria that were provided.

sizeinteger

Total number of objects in the response. This is an optional element that is not provided in all responses, as it can be expensive to compute.

pageinteger

Page number of the current results. This is an optional element that is not provided in all responses.

pageleninteger

Current number of objects on the existing page. The default value is 10 with 100 being the maximum allowed value. Individual APIs may enforce different values.

nextstring uri

Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.

previousstring uri

Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs.