Help Center/ CodeArts Repo/ API Reference/ APIs/ Repository/ Obtaining the Content of a Specified File in a Specified Branch of a Repository
Updated on 2025-03-28 GMT+08:00

Obtaining the Content of a Specified File in a Specified Branch of a Repository

Function

This API is used to obtain the content of a specified file in a specified branch of a repository.

URI

GET /v1/repositories/{repository_uuid}/branch/{branch_name}/file

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repository_uuid

Yes

String

Repository ID.

branch_name

Yes

String

Branch name.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

path

Yes

String

File path.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

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:

Mandatory

Range:

1–100,000 characters.

Default value:

None

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Response error.

result

FilesResponseInfo object

Response result.

status

String

Response status.

Table 5 Error

Parameter

Type

Description

code

String

Error code.

message

String

Error message.

Table 6 FilesResponseInfo

Parameter

Type

Description

file_name

String

File name

file_path

String

File path.

size

String

File size.

encoding

String

Coding type.

ref

String

Branch name.

blob_id

String

File block ID.

file_type

String

File type.

content

String

File content.

Example Requests

GET https://{endpoint}/v1/repositories/{repository_uuid}/branch/{branch_name}/file

Example Responses

Status code: 200

OK

{
  "result" : [ {
    "file_name" : "README.md",
    "file_path" : "README.md",
    "size" : 666,
    "encoding" : "base64",
    "ref" : "master",
    "blob_id" : "75c19b5b1904a72c8a9959c98ae6884d0ace0279",
    "file_type" : "text/plain; charset=utf-8",
    "content" : "RUVFRUVFRUU="
  } ],
  "status" : "success"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.