Obtaining the Repository Branch List (Deprecated)
Function
This API is used to query the repository branch list of the repository on which you have the permission.
URI
GET /v2/repositories/{repository_id}/branches
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| repository_id | Yes | Integer | Explanation Repository ID. Go to the code page of the repository to view it. Constraints None. Range 0–2147483647 Default value None. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| page | No | String | Explanation: Number of pages, starting from 1. Constraints: None. Range 1–2147483647 Default value 1 |
| per_page | No | String | Explanation: Number of queried repository branches displayed on each page. Constraints: None. Range 1–100 Default value 20 |
| match | No | String | Match condition. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Explanation User token. It can be obtained by calling the corresponding IAM API. The value of X-Subject-Token in the response header is the user token. Constraints None. Range String length: 1–100,000 characters. Default value None. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| error | Error object | Explanation Response error code. |
| result | BranchResponse object | Explanation Response result. |
| status | String | Explanation Response status of the API. Range
|
| Parameter | Type | Description |
|---|---|---|
| code | String | Explanation: Error code. Range See Error Codes. |
| message | String | Explanation: Error message. |
| Parameter | Type | Description |
|---|---|---|
| branches | Array of BranchesItem objects | Explanation: Information about the queried branch. |
| total | Double | Explanation: Total number of queried branches. |
| Parameter | Type | Description |
|---|---|---|
| commit | CommitV2 object | Explanation: Commit message. |
| diverging_commit_counts | DivergingCommitCounts object | Explanation: Commit discrepancy. |
| name | String | Explanation: Branch name. |
| Parameter | Type | Description |
|---|---|---|
| committed_date | String | Explanation: Commit time. The format is YYYY-MM-DDTHH:MM:SSZ. For example, 2025-07-19T12:34:56Z indicates the UTC time of 12:34:56 on July 19, 2025. |
| committer_name | String | Explanation Committer. |
| id | String | Explanation SHA ID corresponding to the commit, that is, a 40-digit hexadecimal string used to uniquely identify each commit in the Git versioning system. |
| message | String | Explanation Commit message, including the purpose and content of the commit. |
| short_id | String | Explanation Short SHA ID of the commit, which is usually the first few characters of the SHA ID. Generally, the value is a string of 7 to 10 characters. |
| title | String | Explanation Title of a Git commit. |
| Parameter | Type | Description |
|---|---|---|
| ahead | Double | Explanation Number of leading commits, which indicates how many more commits one branch has compared to another branch. |
| behind | Double | Explanation Number of behind commits. If a branch does not contain the latest commits of another branch, the branch is in the behind state. The number of missing commits is the number of behind commits. |
Example Requests
GET https://{endpoint}/v2/repositories/{repository_id}/branches Example Responses
Status code: 200
OK
{
"result" : {
"total" : 1,
"branches" : [ {
"name" : "master",
"commit" : {
"id" : "2912b8f2328e798f7d544272ffaebfccccb598ab",
"title" : "Initial commit",
"message" : "Initial commit",
"committed_date" : "2021-12-06T09:24:50.000+08:00",
"short_id" : "2912b8f2",
"committer_name" : "repo"
},
"diverging_commit_counts" : {
"behind" : 0,
"ahead" : 0
}
} ]
},
"status" : "success"
} Status Code
| Status Code | Description |
|---|---|
| 200 | OK |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
