GET
GET /repos/{owner}/{repo}/branches — GitHub API
GitHub token (required); https://api.github.com
GitHub APIList branches
- Base URL
- https://api.github.com
- Auth
- Authorization: Bearer <GITHUB_API_KEY>
- Last verified
- 2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 286 tokens · Vary: Accept
→ 286 tokens · Vary: Accept
Critical gotchas
GitHub recommends an Accept: application/vnd.github+json header and an explicit X-GitHub-Api-Version header.
Fine-grained tokens only authorize repositories and permissions selected when the token is created.
cURL
curl -X GET 'https://api.github.com/repos/example-owner/example-repo/branches?protected=true&per_page=30&page=1' \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -H 'Accept: application/vnd.github+json' \ -H 'X-GitHub-Api-Version: 2026-03-10'
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| owner | path | string | Yes | The account owner of the repository. The name is not case sensitive. |
| repo | path | string | Yes | The name of the repository without the `.git` extension. The name is not case sensitive. |
| protected | query | boolean | No | Setting to `true` returns only branches protected by branch protections or rulesets. When set to `false`, only unprotected branches are returned. Omitting this parameter returns all branches. |
| per_page | query | integer | No | The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)." |
| page | query | integer | No | The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)." |
Response 200 OK
[
{
"name": "string",
"commit": {
"sha": "string",
"url": "https://example.com"
},
"protected": true,
"protection": {
"url": "string",
"enabled": true,
"required_status_checks": {
"url": "string",
"enforcement_level": "string",
"contexts": [
"string"
],
"checks": [
{
"context": "[recursive or deeply nested schema]",
"app_id": "[recursive or deeply nested schema]"
}
],
"contexts_url": "string",
"strict": true
},
"enforce_admins": {
"url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/enforce_admins",
"enabled": true
},
"required_pull_request_reviews": {
"url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/dismissal_restrictions",
"dismissal_restrictions": {
"users": [
"[recursive or deeply nested schema]"
],
"teams": [
"[recursive or deeply nested schema]"
],
"apps": [
"[recursive or deeply nested schema]"
],
"url": "\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions\"",
"users_url": "\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions/users\"",
"teams_url": "\"https://api.github.com/repos/the-org/an-org-repo/branches/master/protection/dismissal_restrictions/teams\""
},
"bypass_pull_request_allowances": {
"users": [
"[recursive or deeply nested schema]"
],
"teams": [
"[recursive or deeply nested schema]"
],
"apps": [
"[recursive or deeply nested schema]"
]
},
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true,
"required_approving_review_count": 2,
"require_last_push_approval": true
},
"restrictions": {
"url": "https://example.com",
"users_url": "https://example.com",
"teams_url": "https://example.com",
"apps_url": "https://example.com",
"users": [
{
"login": "[recursive or deeply nested schema]",
"id": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"avatar_url": "[recursive or deeply nested schema]",
"gravatar_id": "[recursive or deeply nested schema]",
"url": "[recursive or deeply nested schema]",
"html_url": "[recursive or deeply nested schema]",
"followers_url": "[recursive or deeply nested schema]",
"following_url": "[recursive or deeply nested schema]",
"gists_url": "[recursive or deeply nested schema]",
"starred_url": "[recursive or deeply nested schema]",
"subscriptions_url": "[recursive or deeply nested schema]",
"organizations_url": "[recursive or deeply nested schema]",
"repos_url": "[recursive or deeply nested schema]",
"events_url": "[recursive or deeply nested schema]",
"received_events_url": "[recursive or deeply nested schema]",
"type": "[recursive or deeply nested schema]",
"site_admin": "[recursive or deeply nested schema]",
"user_view_type": "[recursive or deeply nested schema]"
}
],
"teams": [
{
"id": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"name": "[recursive or deeply nested schema]",
"slug": "[recursive or deeply nested schema]",
"description": "[recursive or deeply nested schema]",
"privacy": "[recursive or deeply nested schema]",
"notification_setting": "[recursive or deeply nested schema]",
"permission": "[recursive or deeply nested schema]",
"permissions": "[recursive or deeply nested schema]",
"url": "[recursive or deeply nested schema]",
"html_url": "[recursive or deeply nested schema]",
"members_url": "[recursive or deeply nested schema]",
"repositories_url": "[recursive or deeply nested schema]",
"type": "[recursive or deeply nested schema]",
"access_source": "[recursive or deeply nested schema]",
"organization_id": "[recursive or deeply nested schema]",
"enterprise_id": "[recursive or deeply nested schema]",
"parent": "[recursive or deeply nested schema]"
}
],
"apps": [
{
"id": "[recursive or deeply nested schema]",
"slug": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"owner": "[recursive or deeply nested schema]",
"name": "[recursive or deeply nested schema]",
"client_id": "[recursive or deeply nested schema]",
"description": "[recursive or deeply nested schema]",
"external_url": "[recursive or deeply nested schema]",
"html_url": "[recursive or deeply nested schema]",
"created_at": "[recursive or deeply nested schema]",
"updated_at": "[recursive or deeply nested schema]",
"permissions": "[recursive or deeply nested schema]",
"events": "[recursive or deeply nested schema]"
}
]
},
"required_linear_history": {
"enabled": true
},
"allow_force_pushes": {
"enabled": true
},
"allow_deletions": {
"enabled": true
},
"block_creations": {
"enabled": true
},
"required_conversation_resolution": {
"enabled": true
},
"name": "\"branch/with/protection\"",
"protection_url": "\"https://api.github.com/repos/owner-79e94e2d36b3fd06a32bb213/AAA_Public_Repo/branches/branch/with/protection/protection\"",
"required_signatures": {
"url": "https://api.github.com/repos/octocat/Hello-World/branches/master/protection/required_signatures",
"enabled": true
},
"lock_branch": {
"enabled": false
},
"allow_fork_syncing": {
"enabled": false
}
},
"protection_url": "https://example.com"
}
] Get a free GitHub API key → sponsored Affiliate link - we may earn a commission, at no extra cost to you.