Sample - GitHub REST API
GET/repos/{owner}/{repo}/branches

List repository branches

Lists branches for a repository, including each branch's commit, protection status, and protection details. Use protected to filter by branch protection status, and use page and per_page to paginate the results.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

5 parameters
ownerstringrequired
The account owner of the repository; the name is not case sensitive.
repostringrequired
The repository name without the `.git` extension; the name is not case sensitive.
protectedbooleanoptional
Set to `true` to return only protected branches or `false` to return only unprotected branches. Omitting it returns all branches.
per_pageintegeroptional
The number of results per page, up to 100. Defaults to 30 when omitted.
Default:30
pageintegeroptional
The page number of results to fetch. Defaults to 1 when omitted.
Default:1

2 status codes
200Returns an array of branch objects containing each branch's name, latest commit, protection status, and protection details.
namestringrequired
commitobjectrequired
protectedbooleanrequired
protectionobjectoptional
Branch Protection
protection_urlstringoptional
404Returned when the specified repository cannot be found.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional

Error handling

A 404 is returned when the repository cannot be found. per_page must not exceed 100, and owner and repo must identify the repository whose branches you want to list.