Get pull requests associated with an enterprise issue¶
GET /api/v5/enterprises/{enterprise}/issues/{number}/pull_requests
This endpoint gets all pull requests associated with a given issue in a specified enterprise. It queries by enterprise path and global issue id and returns an array of pull requests with detailed fields such as PR number, title, state, and branch information.
Access token support¶
- AtomGit user access tokens
Anonymous access¶
This endpoint allows anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
enterprise |
path | string | Yes | Enterprise path (path/login), i.e. the address path of the namespace the enterprise belongs to (the address path of the enterprise, organization, or individual) |
number |
path | integer | Yes | Global issue id (unique id) |
Response parameters¶
The response is an array of pull request objects (array<object>); each element is an associated pull request.
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
number |
integer | No | Yes | PR number |
html_url |
string | No | Yes | Pull page URL |
url |
string | No | Yes | API URL of the pull request |
close_related_issue |
integer | No | Yes | Close the associated issue after merge |
prune_branch |
boolean | No | Yes | Whether to force-delete the source branch |
draft |
boolean | No | Yes | Whether in draft state |
labels |
array | No | Yes | Label list |
user |
object | No | Yes | Author (PR author) information |
assignees |
array | No | Yes | Reviewer list |
testers |
array | No | Yes | Tester list |
head |
object | No | Yes | Source branch information |
base |
object | No | Yes | Target branch information |
id |
integer | No | Yes | PR global id |
iid |
integer | No | Yes | PR number within the project |
project_id |
integer | No | Yes | Project id |
title |
string | No | Yes | PR title |
body |
string | No | Yes | PR description |
state |
string | No | Yes | PR state (such as merged, open) |
assignees_number |
integer | No | Yes | Number of reviewers |
testers_number |
integer | No | Yes | Number of testers |
created_at |
string | No | Yes | Creation time |
updated_at |
string | No | Yes | Update time |
merged_at |
string | No | Yes | Merge time |
closed_at |
string | No | Yes | Close time |
target_branch |
string | No | Yes | Target branch |
source_branch |
string | No | Yes | Source branch |
source_project_id |
integer | No | Yes | Source project id |
force_remove_source_branch |
boolean | No | Yes | Whether to force-delete the source branch |
web_url |
string | No | Yes | Pull request page URL |
merge_request_type |
string | No | Yes | Merge request type |
review_mode |
string | No | Yes | Review mode |
added_lines |
integer | No | Yes | Number of added lines |
removed_lines |
integer | No | Yes | Number of removed lines |
diff_refs |
object | No | Yes | Diff refs |
notes |
integer | No | Yes | Number of comments/notes |
pipeline_status |
string | No | Yes | Pipeline status |
pipeline_status_with_code_quality |
string | No | Yes | Pipeline status including code quality checks |
source_git_url |
string | No | Yes | Source repository git URL |
can_merge_check |
boolean | No | Yes | Whether merge checks are allowed |
mergeable |
boolean | No | Yes | Whether it can be merged |
locked |
boolean | No | Yes | Whether locked |
diff_url |
string | No | Yes | Diff URL |
patch_url |
string | No | Yes | Patch URL |
commits_url |
string | No | Yes | Commit list URL |
comments_url |
string | No | Yes | Comment list URL |
issue_url |
string | No | Yes | Associated issue list URL |
user object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
user.id |
string | No | Yes | User id |
user.login |
string | No | Yes | Login name |
user.name |
string | No | Yes | User name |
user.state |
string | No | Yes | User state (such as active) |
user.email |
string | No | Yes | |
user.name_cn |
string | No | Yes | Chinese name |
user.html_url |
string | No | Yes | User profile page URL |
head object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
head.label |
string | No | Yes | Source branch ref label |
head.ref |
string | No | Yes | Source branch name |
head.sha |
string | No | Yes | Source branch commit sha |
head.user |
object | No | Yes | Source branch user information |
head.repo |
object | No | Yes | Source repository information |
base object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
base.label |
string | No | Yes | Target branch ref label |
base.ref |
string | No | Yes | Target branch name |
base.sha |
string | No | Yes | Target branch commit sha |
base.user |
object | No | Yes | Target branch user information |
base.repo |
object | No | Yes | Target repository information |
diff_refs object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
diff_refs.base_sha |
string | No | Yes | Target branch commit sha |
diff_refs.head_sha |
string | No | Yes | Source branch commit sha |
diff_refs.start_sha |
string | No | Yes | Start commit sha |
head.repo object (base.repo has the same structure)
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
*.repo.id |
integer | No | Yes | Repository id |
*.repo.full_path |
string | No | Yes | Repository full path |
*.repo.full_name |
string | No | Yes | Repository full name |
*.repo.human_name |
string | No | Yes | Repository display name |
*.repo.name |
string | No | Yes | Repository name |
*.repo.path |
string | No | Yes | Repository path |
*.repo.description |
string | No | Yes | Repository description |
*.repo.owner |
object | No | Yes | Repository owner information |
*.repo.assigner |
object | No | Yes | Repository assigner information |
*.repo.internal |
boolean | No | Yes | Whether this is an internal repository |
*.repo.html_url |
string | No | Yes | Repository URL |
*.repo.owner object (*.repo.assigner has the same structure)
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
*.repo.owner.id |
string | No | Yes | User id |
*.repo.owner.login |
string | No | Yes | Login name |
*.repo.owner.name |
string | No | Yes | User name |
*.repo.owner.state |
string | No | Yes | User state |
*.repo.owner.email |
string | No | Yes | |
*.repo.owner.name_cn |
string | No | Yes | Chinese name |
*.repo.owner.html_url |
string | No | Yes | User profile page URL |
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
401 |
Requires authentication |
403 |
Forbidden |
404 |
Request path does not exist |
429 |
Too many requests; rate limit triggered |
500 |
Internal system error |
Request example¶
Parameter description¶
Replace
<enterprise>with the enterprise path (the address path of the enterprise, organization, or individual); replace<number>with the global issue id.
This endpoint allows anonymous access. You can also pass an AtomGit user access token (append it to the query parameters as ?access_token=<token>).
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/pull_requests' \
-H 'Accept: application/json'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/pull_requests", {
headers: {
"Accept": "application/json",
},
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/enterprises/<enterprise>/issues/<number>/pull_requests",
headers={
"Accept": "application/json",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
[
{
"number": 1,
"html_url": "https://api.atomgit.com/owner-test/wonderful1/merge_requests/1",
"url": "https://api.atomgit.com/api/v5/repos/owner-test/wonderful1/pulls/1",
"close_related_issue": 0,
"prune_branch": false,
"draft": false,
"labels": [],
"user": {
"id": "654c61e5560ed95fd216cf31",
"login": "csdn_fenglh",
"name": "fenglh",
"state": "active",
"email": "",
"name_cn": "",
"html_url": "https://api.atomgit.com/csdn_fenglh"
},
"assignees": [],
"testers": [],
"head": {
"label": "wonderful1-patch-1",
"ref": "wonderful1-patch-1",
"sha": "9931ba43e2c485741192d8e9a0b698fed79100f9",
"user": {
"id": "6638af02bbeee41d0fe74c35",
"login": "malongge5",
"name": "malongge5",
"state": "active",
"email": "malongge5@noreply.gitcode.com",
"name_cn": "",
"html_url": "https://api.atomgit.com/malongge5"
},
"repo": {
"id": 686738,
"full_path": "owner-test/wonderful1",
"full_name": "owner-test/wonderful1",
"human_name": "Test / wonderful1",
"name": "wonderful1",
"path": "wonderful1",
"description": "My test code repository",
"owner": {
"id": "6638af02bbeee41d0fe74c35",
"login": "malongge5",
"name": "malongge5",
"state": "active",
"email": "malongge5@noreply.gitcode.com",
"name_cn": "",
"html_url": "https://api.atomgit.com/malongge5"
},
"assigner": {
"id": "6638af02bbeee41d0fe74c35",
"login": "malongge5",
"name": "malongge5",
"state": "active",
"email": "malongge5@noreply.gitcode.com",
"name_cn": "",
"html_url": "https://api.atomgit.com/malongge5"
},
"internal": false,
"html_url": "https://api.atomgit.com/owner-test/wonderful1.git"
}
},
"base": {
"label": "abc",
"ref": "abc",
"sha": "44a8d3e1142468ab2db0fa8c3402a71ccf891572",
"user": {
"id": "6638af02bbeee41d0fe74c35",
"login": "malongge5",
"name": "malongge5",
"state": "active",
"email": "malongge5@noreply.gitcode.com",
"name_cn": "",
"html_url": "https://api.atomgit.com/malongge5"
},
"repo": {
"id": 686738,
"full_path": "owner-test/wonderful1",
"full_name": "owner-test/wonderful1",
"human_name": "Test / wonderful1",
"name": "wonderful1",
"path": "wonderful1",
"description": "My test code repository",
"owner": {
"id": "6638af02bbeee41d0fe74c35",
"login": "malongge5",
"name": "malongge5",
"state": "active",
"email": "malongge5@noreply.gitcode.com",
"name_cn": "",
"html_url": "https://api.atomgit.com/malongge5"
},
"assigner": {
"id": "6638af02bbeee41d0fe74c35",
"login": "malongge5",
"name": "malongge5",
"state": "active",
"email": "malongge5@noreply.gitcode.com",
"name_cn": "",
"html_url": "https://api.atomgit.com/malongge5"
},
"internal": false,
"html_url": "https://api.atomgit.com/owner-test/wonderful1.git"
}
},
"id": 191980,
"iid": 1,
"project_id": 686738,
"title": "hhhh",
"body": "update: Update file README.md ",
"state": "merged",
"assignees_number": 0,
"testers_number": 0,
"created_at": "2024-11-23T20:51:32+08:00",
"updated_at": "2024-12-13T16:16:54+08:00",
"merged_at": "2024-11-25T20:40:19+08:00",
"closed_at": "",
"target_branch": "abc",
"source_branch": "wonderful1-patch-1",
"source_project_id": 686738,
"force_remove_source_branch": false,
"web_url": "https://api.atomgit.com/owner-test/wonderful1/merge_requests/1",
"merge_request_type": "MergeRequest",
"review_mode": "approval",
"added_lines": 2,
"removed_lines": 2,
"diff_refs": {
"base_sha": "91a8edc0db6889fc7309d3306da7b12113e4a73f",
"head_sha": "9931ba43e2c485741192d8e9a0b698fed79100f9",
"start_sha": "91a8edc0db6889fc7309d3306da7b12113e4a73f"
},
"notes": 0,
"pipeline_status": "",
"pipeline_status_with_code_quality": "",
"source_git_url": "ssh://git@atomgit.com:2222/owner-test/wonderful1.git",
"can_merge_check": true,
"mergeable": true,
"locked": false,
"diff_url": "https://api.atomgit.com/owner-test/wonderful1/merge_requests/1.diff",
"patch_url": "https://api.atomgit.com/owner-test/wonderful1/merge_requests/1.patch",
"commits_url": "https://api.atomgit.com/api/v5/repos/owner-test/wonderful1/pulls/1/commits",
"comments_url": "https://api.atomgit.com/api/v5/repos/owner-test/wonderful1/pulls/1/comments",
"issue_url": "https://api.atomgit.com/api/v5/repos/owner-test/wonderful1/pulls/1/issues"
}
]
Error codes¶
| Error code | Description |
|---|---|
401 |
Unauthenticated or invalid credentials (missing or invalid access credentials) |
404 |
Request path does not exist |
405 |
Request method not supported |
429 |
Too many requests; rate limit triggered |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc