ListFiles - Query a file tree

Updated at:

Queries the file tree of a repository via OpenAPI.

Applicable editions

Central edition, Region edition

Endpoints and authorization information

  • Obtain an endpoint. The endpoint is used to replace the {domain} parameter in the API request syntax.
  • Obtain a personal access token.
  • Obtain the organization ID from the Basic Information page in the Tenant Management console. This parameter is required only for the Central edition.

Product

Resource

Required permission

Code Management

File

Read-only

Request syntax

Central edition

GET https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/files/tree

Region edition

GET https://{domain}/oapi/v1/codeup/repositories/{repositoryId}/files/tree

Request headers

Parameter

Type

Required

Description

Example

x-yunxiao-token

string

Yes

Personal access token.

pt-0fh3****0fbG_35af****0484

Request parameters

Parameter

Type

Location

Required

Description

Example

organizationId

string

path

  • Yes: Central

  • No: Region

The organization ID.

60d54f3daccf2bbd6659f3ad

repositoryId

string

path

Yes

The repository ID or the URL-encoded full path of the repository.

2813489 or 60de7a6852743a5162b5f957%2FDemoRepo

path

string

query

No

The path to query, such as src/main.

src/main/test

ref

string

query

No

The reference name, typically a branch name but also a tag or commit SHA. Defaults to the repository's default branch if not specified.

master

type

string

query

No

The retrieval method for the file tree. DIRECT (default) returns only the contents of the specified folder. RECURSIVE returns all files under the specified path. FLATTEN searches recursively until a subdirectory contains files or multiple folders.

DIRECT

Request examples

Central edition

curl -X 'GET' \
  'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/repositories/2813489/files/tree?path=src/main/test&ref=master&type=DIRECT' \
  -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/files/tree?path=src/main/test&ref=master&type=DIRECT' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

Response parameters

Parameter

Type

Description

Example

-

object

id

string

The Git object ID that uniquely identifies the file.

b573bb50d56e8c19282593cbf5b081e211923a83

isLFS

boolean

Whether the file is stored in Git Large File Storage (LFS).

false

mode

string

The file type and permission information, such as 100644.

100644

name

string

The file name.

main.java

path

string

The file path.

src/test/main.java

type

string

The object type. Valid values: tree (folder), blob (file), or commit (submodule).

tree

Response example

{
    "id": "b573bb50d56e8c19282593cbf5b081e211923a83",
    "isLFS": false,
    "mode": "100644",
    "name": "main.java",
    "path": "src/test/main.java",
    "type": "tree"
}

Error codes

For API error codes, see Error Code Center.