Help Center/ CodeArts Repo/ API Reference/ APIs/ Repository/ Obtaining the MR List of a Repository
Updated on 2025-03-28 GMT+08:00

Obtaining the MR List of a Repository

Function

This API is used to obtain the MR list of a repository.

URI

GET /v2/repositories/{repository_id}/merge_request

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Explanation:

Repository short ID, which corresponds to Repository ID on the console.

Constraints:

Mandatory

Range:

0–2147483647

Default value:

None

Table 2 Query parameters

Parameter

Mandatory

Type

Description

state

No

String

Explanation:

MR status.

Constraints:

None

Range:

The value can be any one of the following:

opened: The MR is open.

closed: The MR is closed.

merged: The MR has been merged.

locked: The MR is locked.

all: MRs in any status.

Default value:

all: MRs in any status.

page

No

String

Explanation:

Page number.

Constraints:

None

Range:

A positive integer

Default value:

1

per_page

No

Integer

Explanation:

Number of records displayed on each page.

Constraints:

None

Range:

0–2147483647

Default value:

20

search

No

String

Explanation:

Character string contained in MR titles or descriptions.

Constraints:

None

Range:

Max. 100 characters.

Default value:

None

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

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

Explanation:

Response error code.

result

MergeResult object

Explanation:

Response result.

status

String

Explanation:

Response status of the API.

Range:

  • success: The API call is successful.
  • failed: The API call failed.
Table 5 Error

Parameter

Type

Description

code

String

Explanation:

Error code.

Range:

Max. 100 characters in the error code format.

message

String

Explanation:

Error message.

Range:

None

Table 6 MergeResult

Parameter

Type

Description

closed

Double

Explanation:

Number of closed MRs.

Range:

0–2147483647

merge_requests

Array of MergeRequestsItem objects

Explanation:

MR list.

merged

Double

Explanation:

Number of merged MRs.

Range:

0–2147483647

opened

Double

Explanation:

Number of open MRs.

Range:

0–2147483647

total

Double

Explanation:

Total number of MRs.

Range:

0–2147483647

Table 7 MergeRequestsItem

Parameter

Type

Description

author

Author object

Explanation:

MR author.

closed_at

String

Explanation:

Time when an MR was closed.

created_at

String

Explanation:

Time when an MR was created.

description

String

Explanation:

MR description.

devcloud_source_branch

String

Explanation:

MR source branch.

id

Double

Explanation:

MR ID.

Range:

0–2147483647

iid

Double

Explanation:

Sequence number of an MR in the current repository.

Range:

0–2147483647

merge_request_assignee_list

Array of Author objects

Explanation:

MR reviewer information.

merge_status

String

Explanation:

Whether an MR can be merged.

Range:

can_be_merged: Yes

cannot_be_merged: No

unchecked: Not yet checked

cannot_be_merged_recheck: No, and currently being checked

source_branch

String

Explanation:

MR source branch name.

state

String

Explanation:

MR status.

Range:

The value can be any one of the following:

opened: The MR is open.

closed: The MR is closed.

merged: The MR has been merged.

locked: The MR is locked.

target_branch

String

Explanation:

MR target branch name.

title

String

Explanation:

MR title.

updated_at

String

Explanation:

Last update time of an MR.

Table 8 Author

Parameter

Type

Description

id

Double

Explanation:

User ID.

name

String

Explanation:

Username.

state

String

Explanation:

User status.

username

String

Explanation:

IAM user ID.

avatar_url

String

Explanation:

Profile picture URL.

web_url

String

Explanation:

Web URL.

Example Requests

GET https://{endpoint}/v2/repositories/907199/merge_request

Example Responses

Status code: 200

OK

{
  "result" : {
    "total" : 1,
    "merge_requests" : [ {
      "iid" : 1,
      "description" : "merge \"branch123\" into \"master\"\nCreate the dsadsad11 file",
      "created_at" : "2021-12-08T16:34:49.000+08:00",
      "title" : "tesafrds.",
      "source_branch" : "branch123",
      "updated_at" : "2021-12-08T16:39:24.000+08:00",
      "id" : 6670,
      "state" : "opened",
      "closed_at" : "2021-12-08T16:34:50.000+08:00",
      "author" : {
        "name" : "repo",
        "id" : 1234,
        "state" : "active",
        "username" : "e0c068bf68c44bfab87b763ff85da277"
      },
      "target_branch" : "master",
      "merge_status" : "can_be_merged",
      "devcloud_source_branch" : "branch123",
      "merge_request_assignee_list" : [ {
        "name" : "Example account",
        "id" : 3333,
        "state" : "active",
        "username" : "a618e34bd5704be3ae3395dfede06041"
      }, {
        "name" : "Example account",
        "id" : 6747,
        "state" : "active",
        "username" : "42dd0277cfb048dea856e4ee352e937d"
      } ]
    } ],
    "merged" : 0,
    "closed" : 0,
    "opened" : 1
  },
  "status" : "success"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.