Help Center/ CodeArts Repo/ API Reference/ APIs/ V4/ Commit/ Obtaining Commit Differences
Updated on 2026-01-27 GMT+08:00

Obtaining Commit Differences

Function

This API is used to obtain commit differences.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

Authorization Information

Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

codeartsrepo:repository:getRepository

Read

-

-

-

-

URI

GET https://{hostURL}/v4/repositories/{repository_id}/repository/commits/diff

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Definition

You can query the project list to obtain the repository ID by calling the API used to query user's all repositories.

Constraints

N/A

Default Value

N/A

Value range:

1~2147483647

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

sha

Yes

String

Definition

Branch name, tag name, or commit ID.

ignore_whitespace_change

No

Boolean

Definition

Whether to ignore the change of blank quantity.

Range

  • true: ignore the change of blank quantity.

  • false: not to ignore the change of blank quantity.

Default value:

false

not_statistic

No

Boolean

Definition

Whether to return the statistics quantity.

Range

  • true: not to return the statistics quantity.

  • false: return the statistics quantity.

Default value:

false

offset

No

Integer

Definition

Offset, which starts from 0.

Value range:

0~2147483647

Default value:

0

limit

No

Integer

Definition

Number of returned records.

Value range:

1~100

Default value:

20

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. Obtain one by calling the IAM API Obtaining a User Token. The value of X-Subject-Token in the response header is a token.

Constraints

N/A

Range

1–100,000 characters.

Default Value

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

diffs

Array of DiffNoLineDto objects

Definition

Difference information.

Range

N/A.

diff_refs

DiffRefsDto object

Definition

Difference ref information.

Range

N/A.

added_lines

Integer

Definition

Number of added lines.

Range

N/A.

removed_lines

Integer

Definition

Number of deleted lines.

Range

N/A.

change_file_count

Integer

Definition

Number of changed files.

Range

N/A.

change_line_count

Integer

Definition

Number of changed lines.

Range

N/A.

too_large

Boolean

Definition

Large file or not.

Range

  • true: large file.

  • false: not a large file

Table 5 DiffNoLineDto

Parameter

Type

Description

old_path

String

Old file

new_path

String

New file

a_mode

String

Old file type.

b_mode

String

New file type

file_path

String

File path

new_file

Boolean

New or not

file_type

String

File type

renamed_file

Boolean

Rename or not

deleted_file

Boolean

Whether to delete a file

diff

String

Comparison result

binary

Boolean

Binary or not

too_large

Boolean

Whether the file is too large

collapsed

Boolean

Collapsed or not

added_lines

Integer

Number of added lines

Value range:

1~2147483647

removed_lines

Integer

Number of deleted lines

Value range:

1~2147483647

Table 6 DiffRefsDto

Parameter

Type

Description

base_sha

String

Definition

Base commit hash of the target branch.

Range

N/A.

head_sha

String

Definition

Latest commit hash of the source branch.

Range

N/A.

start_sha

String

Definition

Commit hash at the start of an MR, which is usually the same as base_sha.

Range

N/A.

Status code: 401

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

error_msg

String

Definition

Error message.

Example Requests

None

Example Responses

Status code: 200

ok

{
  "added_lines" : 0,
  "removed_lines" : 0,
  "diffs" : null,
  "change_file_count" : 0,
  "change_line_count" : 0,
  "too_large" : false,
  "diff_refs" : {
    "base_sha" : "360fc59f6ed8e90b8fa52dd4d31e65d966dc763d",
    "head_sha" : "d315e5f6dc66cdc7377dc65b14a835f153b6406c",
    "start_sha" : "360fc59f6ed8e90b8fa52dd4d31e65d966dc763d"
  }
}

Status code: 401

Unauthorized

{
  "error_code" : "DEV.00000003",
  "error_msg" : "Authentication information expired."
}

Status Codes

Status Code

Description

200

ok

401

Unauthorized

Error Codes

See Error Codes.