Get pull requests associated with an issue¶
GET /api/v5/repos/{owner}/{repo}/issues/{number}/pull_requests
Retrieves the list of all pull requests associated with an issue in the specified repository, returning details such as each PR's number, title, state, source and target branches, assignees, and labels; the mode parameter optionally returns a mergeability check result.
Access token support¶
- AtomGit user access token (AtomGit user access tokens)
Anonymous access¶
This endpoint allows anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | Address path of the namespace that owns the repository (the address path of an enterprise, organization, or individual) |
repo |
path | string | Yes | Repository path (path) |
number |
path | string | Yes | Issue number (case-sensitive; do not add the # sign; must be a positive integer) |
mode |
query | integer | No | Mode, enum: 0 / 1; 0 (default) does not return the mergeable state, 1 (enhanced mode) returns the PR's mergeable state; defaults to 0 |
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
integer | Yes | No | Pull request ID |
html_url |
string | Yes | No | HTML address of the pull request |
diff_url |
string | Yes | No | Diff address of the pull request |
number |
integer | Yes | No | Pull request number |
state |
string | Yes | No | State, such as open / closed / merged |
title |
string | Yes | No | Pull request title |
body |
string | Yes | No | Pull request description |
created_at |
string | Yes | No | Creation time |
updated_at |
string | Yes | No | Update time |
merged_at |
string | Yes | Yes | Merge time; null when not merged |
closed_at |
string | Yes | Yes | Close time; null when not closed |
head |
object | Yes | No | Source branch information |
base |
object | Yes | No | Target branch information |
assignees |
object[] | Yes | Yes | Assignee list |
testers |
object[] | Yes | Yes | Tester list |
labels |
object[] | Yes | Yes | Label list |
can_merge_check |
boolean | No | Yes | Mergeability check result; returned when mode=1 (enhanced mode) |
Note: The endpoint returns an array of pull request objects; the table above describes the fields of each element in the array.
head object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
head.ref |
string | Yes | No | Source branch name |
head.sha |
string | Yes | No | Latest commit SHA of the source branch |
head.repo |
object | Yes | No | Information about the repository of the source branch |
head.assigner |
object | No | Yes | User assigned to the branch; may be null |
head.repo object¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
head.repo.path |
string | Yes | No | Repository path |
head.repo.name |
string | Yes | No | Repository name |
head.repo.full_name |
string | No | Yes | Full repository name |
head.assigner object¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
head.assigner.login |
string | Yes | No | Login name |
head.assigner.name |
string | Yes | No | Nickname |
base object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
base.ref |
string | Yes | No | Target branch name |
base.sha |
string | Yes | No | Latest commit SHA of the target branch |
base.repo |
object | Yes | No | Information about the repository of the target branch |
base.assigner |
object | No | Yes | User assigned to the branch; may be null |
base.repo object¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
base.repo.path |
string | Yes | No | Repository path |
base.repo.name |
string | Yes | No | Repository name |
base.repo.full_name |
string | No | Yes | Full repository name |
base.assigner object¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
base.assigner.login |
string | Yes | No | Login name |
base.assigner.name |
string | Yes | No | Nickname |
assignees / testers array element object
The following fields apply to each element in both the assignees and testers arrays (replace the field prefix with the array it belongs to).
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
assignees.id |
string | Yes | No | User ID |
assignees.login |
string | Yes | No | Login name |
assignees.name |
string | No | Yes | Nickname |
assignees.avatar_url |
string | No | Yes | Avatar address |
assignees.html_url |
string | Yes | No | User homepage address |
labels array element object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
labels.id |
integer | Yes | No | Label ID |
labels.color |
string | Yes | No | Label color |
labels.name |
string | Yes | No | Label name |
labels.repository_id |
integer | No | Yes | ID of the repository the label belongs to |
labels.url |
string | No | Yes | Label URL; currently may be empty |
labels.created_at |
string | Yes | No | Creation time |
labels.updated_at |
string | Yes | No | Update time |
labels.text_color |
string | Yes | No | Text color |
Error responses¶
Besides the
200success response, callers also need to know the shape of a failure response in order to write error handling. The field names in the following examples are subject to the actual response returned by the backend.
400 Parameter error
404 Resource not found
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Parameter error (Bad request) |
404 |
Resource not found (Not found) |
500 |
Internal server error (Internal server error) |
Request example¶
Parameter notes¶
Replace
<owner>with the address path of the namespace that owns the repository (the address path of an enterprise, organization, or individual); replace<repo>with the repository path (path); replace<number>with the issue number (case-sensitive; no need to add the # sign). This endpoint allows anonymous access, so the examples do not carry an access token; to call it while signed in, append?access_token=<token>to the URL, where<token>is replaced with your AtomGit user access token.
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/pull_requests' \
-H 'Accept: application/json'
JavaScript¶
// Native fetch (Node.js 18+ / browsers)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/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/repos/<owner>/<repo>/issues/<number>/pull_requests",
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
[
{
"id": 67585,
"html_url": "https://api.atomgit.com/test/test/merge_requests/1",
"diff_url": "https://api.atomgit.com/test/test/merge_requests/1/diffs",
"number": 1,
"state": "open",
"title": "1",
"body": "new: added file test.txt 1",
"created_at": "2024-04-12T17:50:55.253+08:00",
"updated_at": "2024-04-20T15:58:30.657+08:00",
"merged_at": null,
"closed_at": null,
"head": {
"ref": "develop",
"sha": "061c446d55aae78c7a0f096b2d2dd0d6a1afb170",
"repo": {
"path": "paopao1",
"name": "paopao1"
},
"assigner": {
"login": "test",
"name": "test"
}
},
"base": {
"ref": "main",
"sha": "667d4ac032b2faa13d019753ac218b4f78338273",
"repo": {
"path": "paopao1",
"name": "paopao1"
},
"assigner": null
},
"assignees": [
{
"id": "65803cddcf1e2d1aa3d2e99f",
"login": "test",
"name": null,
"avatar_url": null,
"html_url": "https://api.atomgit.com/test"
}
],
"testers": [
{
"id": "65803cddcf1e2d1aa3d2e99f",
"login": "test",
"name": "test",
"avatar_url": null,
"html_url": "https://api.atomgit.com/test"
}
],
"labels": [
{
"id": 383707,
"color": "#CCCCCC",
"name": "wontfix",
"repository_id": null,
"url": null,
"created_at": "2024-04-19",
"updated_at": "2024-04-19",
"text_color": "#333333"
}
],
"can_merge_check": true
}
]
Error codes¶
| Error code | Description |
|---|---|
400 |
Invalid parameters or unparsable request |
404 |
Request path does not exist |
405 |
Unsupported request method |
429 |
Too many requests; rate limit triggered |
500 |
Internal server error |
OpenAPI¶
{"paths": {"/api/v5/repos/{owner}/{repo}/issues/{number}/pull_requests": {"get": {"tags": ["issues"], "summary": "Get pull requests associated with an issue", "responses": {"200": {"content": {"application/json": {"schema": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "integer"}, "base": {"type": "object", "properties": {"ref": {"type": "string"}, "sha": {"type": "string"}, "repo": {"type": "object", "properties": {"name": {"type": "string"}, "path": {"type": "string"}, "full_name": {"type": "string"}}}, "assigner": {"type": "object", "properties": {"name": {"type": "string"}, "login": {"type": "string"}}}}}, "body": {"type": "string"}, "head": {"type": "object", "properties": {"ref": {"type": "string"}, "sha": {"type": "string"}, "repo": {"type": "object", "properties": {"name": {"type": "string"}, "path": {"type": "string"}, "full_name": {"type": "string"}}}, "assigner": {"type": "object", "properties": {"name": {"type": "string"}, "login": {"type": "string"}}}}}, "state": {"type": "string"}, "title": {"type": "string"}, "labels": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "integer"}, "url": {"type": "string"}, "name": {"type": "string"}, "color": {"type": "string"}, "created_at": {"type": "string"}, "text_color": {"type": "string"}, "updated_at": {"type": "string"}, "repository_id": {"type": "integer"}}}}, "number": {"type": "integer"}, "testers": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string"}, "name": {"type": "string"}, "login": {"type": "string"}, "html_url": {"type": "string"}, "avatar_url": {"type": "string"}}}}, "diff_url": {"type": "string"}, "html_url": {"type": "string"}, "assignees": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string"}, "name": {"type": "string"}, "login": {"type": "string"}, "html_url": {"type": "string"}, "avatar_url": {"type": "string"}}}}, "closed_at": {"type": "string"}, "merged_at": {"type": "string"}, "created_at": {"type": "string"}, "updated_at": {"type": "string"}, "can_merge_check": {"type": "boolean"}}}}, "description": "Success"}}, "parameters": [{"in": "path", "name": "owner", "schema": {"type": "string"}, "required": true, "description": "Address path of the namespace that owns the repository (the address path of an enterprise, organization, or individual)"}, {"in": "path", "name": "repo", "schema": {"type": "string"}, "required": true, "description": "Repository path (path)"}, {"in": "path", "name": "number", "schema": {"type": "string"}, "required": true, "description": "Issue number (case-sensitive; do not add the # sign; must be a positive integer)"}, {"in": "query", "name": "mode", "schema": {"type": "integer"}, "required": false, "description": "Mode, enum: 0 / 1; 0 (default) does not return the mergeable state, 1 (enhanced mode) returns the PR's mergeable state; defaults to 0"}], "description": "Call this endpoint to get the pull requests associated with an issue."}}}}
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc