Help Center/ KooDrive/ API Reference/ API/ File Management/ Collecting Folder Statistics
Updated on 2026-02-12 GMT+08:00

Collecting Folder Statistics

Function

Collect statistics on the number of directories, number of files, and total file size in a folder.

Authorization Information

No identity policy-based permission required for calling this API.

URI

GET /koodrive/ose/v1/files/statsDir

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

fileId

Yes

String

Directory ID. The root directory is also supported.

containerId

Yes

String

ID of the space to which the directory belongs.

recursive

No

Boolean

Whether to collect statistics files recursively.

If recursion is used, all subdirectories and subfiles are counted.

If no recursion is used, only the direct subdirectories and subfiles in the specified directory are collected.

The default value is true.

includeDirCount

No

Boolean

Whether to count the total number of subdirectories. The default value is true.

includeFileCount

No

Boolean

Whether to count the total number of subfiles. The default value is true.

includeTotalSize

No

Boolean

Whether to collect statistics on the total file size. The default value is true.

type

No

Integer

Type of the file to be filtered. The enumerated value is 1, indicating a common file. 2. Directory file. If this parameter is not transferred or is left empty, all types are collected.

extensions

No

String

List of file name extensions to be filtered. Note that file name extensions are case-insensitive. For example, the search results of JPG and jpg are the same.

This parameter is valid only for subfiles. A maximum of 100 file name extensions are supported. Extensions are separated by commas (,), for example, jpg,png.

For details about all file name extensions supported by KooDrive, see Before You Start.

categorys

No

String

List of file types to be filtered.

A maximum of 100 types are supported. The elements of each type are separated by commas (,), for example, 15,20.

The enumerated values of types are as follows: 10: folder; 15: image; 20: video; 26: word; 27: excel; 28: ppt; 30: audio; 35: compressed file; 40: application; 45: others.

hidden

No

Boolean

Whether to hide files. By default, all files are returned. true: Only hidden files are returned. false: Only non-hidden files are returned.

isRecycled

No

Boolean

Whether to collect statistics on files in the recycle bin. true indicates that only the usage of files deleted with the parent directory is collected. If fileId is root, all files in the recycle bin are collected. false indicates that only normal files are collected. If the value is null or not transferred, when fileId is a recycle bin directory, the usage of files deleted with the parent directory is collected. When fileId is a normal directory, the usage of normal files is collected. When fileId is root, the usage of all files is collected.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Traceid

No

String

Message log trace ID. The value contains 58 bits.

Authorization

Yes

String

Access token. Token authentication is used to call KooDrive APIs. A token indicates the permissions. When an API is called, the token is added to the request header to obtain the operation permissions. For details about how to obtain an access token, see the corresponding developer guide. The format is Bearer+{access_token}.

X-User-Id

Yes

String

User ID, which is used for app authentication.

X-Date

Yes

String

Date, which is used for app authentication.

language

No

String

Language code, which complies with the internationalization specifications. For example, en-US indicates English (United States). English (United States) is used by default.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

code

String

Response code.

msg

String

Response information.

data

StatsData object

Data.

Table 4 StatsData

Parameter

Type

Description

totalSize

String

Total file size.

subDirCount

String

Total number of subdirectories.

subFileCount

String

Total number of subfiles.

extensionStatistics

Map<String,DirStatistics>

Statistics result of the specified file name extension. Note: This parameter is returned only when extensionList is not empty. The value of subDircount in DirStatistics is empty.

categoryStatistics

Map<String,DirStatistics>

Statistical result of a specified file type. This parameter is returned only when categoryList is not empty. In DirStatistics, subDircount is valid only for directory files, and totalSize and subFileCount are valid only for common files.

Table 5 DirStatistics

Parameter

Type

Description

totalSize

String

Total file size.

subDirCount

String

Total number of subdirectories.

subFileCount

String

Total number of subfiles.

Example Requests

Query the number of directories, number of files, and total file size in directory FnNGsBnXUdIW7AycSK4ZCTIlPJ6JO1_sF.

POST /koodrive/ose/v1/files/statsDir?fileId=FnNGsBnXUdIW7AycSK4ZCTIlPJ6JO1_sF&containerId=IAAGvmhWei6Q7A4-A1557836058161393920&recursive=true

Authorization:Bearer+10f88*********4791e9ff

Example Responses

Status code: 200

Search results.

{
  "code" : 0,
  "msg" : "success",
  "data" : {
    "totalSize" : 0,
    "subDirCount" : 1,
    "subFileCount" : 0
  }
}

Status Codes

Status Code

Description

200

Search results.