GetBranch - Get branch information
Retrieves information about a single branch.
|
Applicable editions |
Central edition, Region edition |
Endpoint and authorization information
-
Obtain the endpoint: Replace {domain} in the API request syntax.
-
Obtain the organizationId: Required for the Central edition only. Go to the Basic Information page in the Organization Management console to obtain your organization ID.
|
Product |
Resource |
Required permission |
|
Code Management |
Branch |
Read-only |
Request syntax
Central edition
GET https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/branches/{branchName}
Region edition
GET https://{domain}/oapi/v1/codeup/repositories/{repositoryId}/branches/{branchName}
Request headers
|
Parameter |
Type |
Required |
Description |
Example value |
|
x-yunxiao-token |
string |
Yes |
Personal access token. |
pt-0fh3****0fbG_35af****0484 |
Request parameters
|
Parameter |
Type |
Location |
Required |
Description |
Example value |
|
organizationId |
string |
path |
|
Organization ID. |
60d54f3daccf2bbd6659f3ad |
|
repositoryId |
string |
path |
Yes |
Repository ID or URL-encoded full path. |
2813489 or 60de7a6852743a5162b5f957%2FDemoRepo |
|
branchName |
string |
path |
Yes |
Branch name. URL-encode special characters if present. |
demo-branch |
Request examples
Central edition
curl -X 'GET' \
'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/repositories/2813489 or 60de7a6852743a5162b5f957%2FDemoRepo/branches/demo-branch' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'
Region edition
curl -X 'GET' \
'https://{domain}/oapi/v1/codeup/repositories/2813489 or 60de7a6852743a5162b5f957%2FDemoRepo/branches/demo-branch' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'
Response parameters
|
Parameter |
Type |
Description |
Example value |
| - |
object |
||
| commit |
object |
Information about the most recent commit on the branch. |
|
|
authorEmail |
string |
Author email address. |
username@example.com |
|
authorName |
string |
Author name. |
Codeup-Demo |
|
authoredDate |
string |
Timestamp when the author created the commit. |
2024-04-05T15:30:45Z |
|
committedDate |
string |
Timestamp when the committer applied the commit. |
2024-04-05T15:30:45Z |
|
committerEmail |
string |
Committer email address. |
username@example.com |
|
committerName |
string |
Committer name. |
Codeup-Demo |
|
id |
string |
Commit ID. |
45ede4680536406d793e0e629bc771cb9fcaa153 |
|
message |
string |
Commit message. |
commit message |
|
parentIds |
array[string] |
Parent commit IDs. |
["3fdaf119cf76539c1a47de0074ac02927ef4c8e1"] |
|
shortId |
string |
Abbreviated commit ID. |
45ede468 |
| stats |
object |
Line change statistics for the commit. |
|
|
additions |
integer |
Number of lines added. |
10 |
|
deletions |
integer |
Number of lines deleted. |
1 |
|
total |
integer |
Total number of changed lines. |
11 |
|
title |
string |
Commit title, taken from the first line of the commit message. |
commit title |
|
defaultBranch |
boolean |
Whether this is the default branch. |
false |
|
name |
string |
Branch name. |
demo-branch |
|
protected |
boolean |
Whether this is a protected branch. |
false |
|
webUrl |
string |
Web URL of the branch page. |
http://codeup.example.com/org-id/repo/demo-branch |
Response example
{
"commit": {
"authorEmail": "username@example.com",
"authorName": "Codeup-Demo",
"authoredDate": "2024-04-05T15:30:45Z",
"committedDate": "2024-04-05T15:30:45Z",
"committerEmail": "username@example.com",
"committerName": "Codeup-Demo",
"id": "45ede4680536406d793e0e629bc771cb9fcaa153",
"message": "commit message",
"parentIds": ["3fdaf119cf76539c1a47de0074ac02927ef4c8e1"],
"shortId": "45ede468",
"stats": {
"additions": 10,
"deletions": 1,
"total": 11
},
"title": "commit title"
},
"defaultBranch": false,
"name": "demo-branch",
"protected": false,
"webUrl": "http://codeup.example.com/org-id/repo/demo-branch"
}
Error codes
For more information about API-related error codes, see the Error Code Center.