GET
GET /repos/{owner}/{repo}/branches/{branch} — GitHub API
GitHub token (required); https://api.github.com
GitHub APIGet a branch
- 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
→ 227 tokens · Vary: Accept
→ 227 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/example-branch' \ -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. |
| branch | path | string | Yes | The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use [the GraphQL API](https://docs.github.com/graphql). |
Response 200 OK
{
"name": "string",
"commit": {
"url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"node_id": "MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==",
"html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"comments_url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments",
"commit": {
"url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"author": {
"name": "\"Chris Wanstrath\"",
"email": "\"[email protected]\"",
"date": "\"2007-10-29T02:42:39.000-07:00\""
},
"committer": {
"name": "\"Chris Wanstrath\"",
"email": "\"[email protected]\"",
"date": "\"2007-10-29T02:42:39.000-07:00\""
},
"message": "Fix all the bugs",
"comment_count": 0,
"tree": {
"sha": "827efc6d56897b048c772eb4087f854f46256132",
"url": "https://api.github.com/repos/octocat/Hello-World/tree/827efc6d56897b048c772eb4087f854f46256132"
},
"verification": {
"verified": true,
"reason": "string",
"payload": "string",
"signature": "string",
"verified_at": "string"
}
},
"author": {
"name": "string",
"email": "string",
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "41d064eb2195891e12d0413f63227ea7",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": true,
"starred_at": "\"2020-07-09T00:17:55Z\"",
"user_view_type": "public"
},
"committer": {
"name": "string",
"email": "string",
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "41d064eb2195891e12d0413f63227ea7",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": true,
"starred_at": "\"2020-07-09T00:17:55Z\"",
"user_view_type": "public"
},
"parents": [
{
"sha": "7638417db6d59f3c431d3e1f261cc637155684cd",
"url": "https://api.github.com/repos/octocat/Hello-World/commits/7638417db6d59f3c431d3e1f261cc637155684cd",
"html_url": "https://github.com/octocat/Hello-World/commit/7638417db6d59f3c431d3e1f261cc637155684cd"
}
],
"stats": {
"additions": 0,
"deletions": 0,
"total": 0
},
"files": [
{
"sha": "bbcd538c8e72b8c175046e27cc8f907076331401",
"filename": "file1.txt",
"status": "added",
"additions": 103,
"deletions": 21,
"changes": 124,
"blob_url": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
"raw_url": "https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
"contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e",
"patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test",
"previous_filename": "file.txt"
}
]
},
"_links": {
"html": "string",
"self": "https://example.com"
},
"protected": true,
"protection": {
"url": "string",
"enabled": true,
"required_status_checks": {
"url": "string",
"enforcement_level": "string",
"contexts": [
"string"
],
"checks": [
{
"context": "string",
"app_id": 0
}
],
"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": [
{
"name": "[recursive or deeply nested schema]",
"email": "[recursive or deeply nested schema]",
"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]",
"starred_at": "[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]",
"client_id": "[recursive or deeply nested schema]",
"owner": "[recursive or deeply nested schema]",
"name": "[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]",
"installations_count": "[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": [
{
"name": "[recursive or deeply nested schema]",
"email": "[recursive or deeply nested schema]",
"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]",
"starred_at": "[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]",
"client_id": "[recursive or deeply nested schema]",
"owner": "[recursive or deeply nested schema]",
"name": "[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]",
"installations_count": "[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": "string",
"id": 0,
"node_id": "string",
"avatar_url": "string",
"gravatar_id": "string",
"url": "string",
"html_url": "string",
"followers_url": "string",
"following_url": "string",
"gists_url": "string",
"starred_url": "string",
"subscriptions_url": "string",
"organizations_url": "string",
"repos_url": "string",
"events_url": "string",
"received_events_url": "string",
"type": "string",
"site_admin": true,
"user_view_type": "string"
}
],
"teams": [
{
"id": 0,
"node_id": "string",
"name": "string",
"slug": "string",
"description": "string",
"privacy": "string",
"notification_setting": "string",
"permission": "string",
"permissions": {
"pull": "[recursive or deeply nested schema]",
"triage": "[recursive or deeply nested schema]",
"push": "[recursive or deeply nested schema]",
"maintain": "[recursive or deeply nested schema]",
"admin": "[recursive or deeply nested schema]"
},
"url": "https://example.com",
"html_url": "https://github.com/orgs/rails/teams/core",
"members_url": "string",
"repositories_url": "https://example.com",
"type": "enterprise",
"access_source": "direct",
"organization_id": 37,
"enterprise_id": 42,
"parent": {
"id": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"url": "[recursive or deeply nested schema]",
"members_url": "[recursive or deeply nested schema]",
"name": "[recursive or deeply nested schema]",
"description": "[recursive or deeply nested schema]",
"permission": "[recursive or deeply nested schema]",
"privacy": "[recursive or deeply nested schema]",
"notification_setting": "[recursive or deeply nested schema]",
"html_url": "[recursive or deeply nested schema]",
"repositories_url": "[recursive or deeply nested schema]",
"slug": "[recursive or deeply nested schema]",
"ldap_dn": "[recursive or deeply nested schema]",
"type": "[recursive or deeply nested schema]",
"organization_id": "[recursive or deeply nested schema]",
"enterprise_id": "[recursive or deeply nested schema]"
}
}
],
"apps": [
{
"id": 0,
"slug": "string",
"node_id": "string",
"owner": {
"login": "[recursive or deeply nested schema]",
"id": "[recursive or deeply nested schema]",
"node_id": "[recursive or deeply nested schema]",
"url": "[recursive or deeply nested schema]",
"repos_url": "[recursive or deeply nested schema]",
"events_url": "[recursive or deeply nested schema]",
"hooks_url": "[recursive or deeply nested schema]",
"issues_url": "[recursive or deeply nested schema]",
"members_url": "[recursive or deeply nested schema]",
"public_members_url": "[recursive or deeply nested schema]",
"avatar_url": "[recursive or deeply nested schema]",
"description": "[recursive or deeply nested schema]",
"gravatar_id": "[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]",
"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]"
},
"name": "string",
"client_id": "string",
"description": "string",
"external_url": "string",
"html_url": "string",
"created_at": "string",
"updated_at": "string",
"permissions": {
"metadata": "[recursive or deeply nested schema]",
"contents": "[recursive or deeply nested schema]",
"issues": "[recursive or deeply nested schema]",
"single_file": "[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",
"pattern": "\"mas*\"",
"required_approving_review_count": 1
} Get a free GitHub API key → sponsored Affiliate link - we may earn a commission, at no extra cost to you.