Help Center/ CodeArts Build/ API Reference/ APIs/ Build Task Management/ Obtaining Branches of a GitCode Repository
Updated on 2025-08-21 GMT+08:00

Obtaining Branches of a GitCode Repository

Function

This API is used to obtain branches of a GitCode repository.

Calling Method

For details, see Calling APIs.

URI

GET /v1/code/git-code/{endpoint_id}/branches

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

endpoint_id

Yes

String

Definition

Endpoint ID.

Constraints

N/A.

Range

Use a mix of digits and lowercase letters.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

page

No

Integer

Definition

The index of the page to start the query from.

Constraints

N/A.

Range

The value of page is at least 1.

page_size

No

Integer

Definition

Number of items displayed on each page.

Constraints

The value is a positive integer.

Range

The value of page_size is no more than 100.

search

No

String

Definition

Filter criteria.

Constraints

N/A.

Range

N/A.

Default Value

N/A.

repo_id

No

String

Definition

Code repository ID. It is mandatory when CodeArts Repo (codehub) is used as the code source.

Constraints

N/A.

Range

N/A.

Default Value

N/A.

limit

No

Integer

Details:

Number of items displayed on each page. The value of limit is no more than 100.

Constraints:

N/A

Value Range:

Only numbers that are 100 or less can be used.

offset

No

Integer

Definition

The index of the page to start the query from.

Constraints

N/A.

Range

Use only numbers that are 0 or greater.

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

result

Array of GitCodeBranch objects

Result.

error

String

Returned error message.

status

String

Returned status information.

Table 4 GitCodeBranch

Parameter

Type

Description

name

String

Definition

Branch name.

Constraints

N/A.

Range

N/A.

commit

commit object

Commit.

Table 5 commit

Parameter

Type

Description

id

String

Definition

Commit ID.

Constraints

N/A.

Range

N/A.

title

String

Definition

Commit title.

Constraints

N/A.

Range

N/A.

message

String

Definition

Commit message.

Constraints

N/A.

Range

N/A.

created_at

String

Definition

Creation time.

Constraints

N/A.

Range

N/A.

author_name

String

Definition

Modifier (who makes a modification).

Constraints

N/A.

Range

N/A.

committer_name

String

Definition

Committer.

Constraints

N/A.

Range

N/A.

committed_date

String

Definition

Commit time.

Constraints

N/A.

Range

N/A.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 404

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

GET https://{endpoint}/v1/code/git-code/{endpoint_id}/branches

Example Responses

Status code: 200

OK

{
  "result" : [ {
    "name" : "main",
    "commit" : {
      "id" : 12,
      "title" : "Modified Issue \"xxx\"",
      "message" : "Modified class \"xxx\".",
      "created_at" : "2024-01-01 12:00:00",
      "author_name" : "test1",
      "committer_name" : "test2",
      "committed_date" : "2024-01-01 12:00:00"
    }
  }, {
    "name" : "master",
    "commit" : null
  } ],
  "error" : null,
  "status" : "success"
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.