Skip to content

Get a single pull request

GET /api/v5/repos/{owner}/{repo}/pulls/{number}

This endpoint retrieves detailed information about a single pull request in the specified repository, including the title, state, reviewer and tester information, labels, merge gate state, milestone, and merge result, so that you can understand the complete picture of a specific merge request.

Access token support

  • AtomGit user access tokens (AtomGit user access tokens)

Whether anonymous access is allowed

This endpoint allows anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes The namespace address the repository belongs to (the address path of an organization or personal namespace)
repo path string Yes Repository path (path)
number path integer Yes Which PR, that is, the ordinal number of the PR in this repository
access_token query string No User authorization code (optional)

Response parameters

Field Type Always returned Nullable Description
id integer Yes No ID of the pull request
html_url string Yes No HTML URL of the pull request
number integer Yes No Ordinal number
state string Yes No State, enum: open / closed / merged
title string Yes No Title
url string Yes No api url
issue_url string Yes No API URL of the associated issue
body string Yes No Description
assignees_number integer Yes No Number of reviewers
assignees object[] Yes No Reviewer information
testers object[] Yes No Tester information
approval_reviewers object[] Yes No Approval reviewer information
labels object[] Yes No Label information
created_at string Yes No Creation time
updated_at string Yes No Update time
closed_at string Yes Yes Close time; null if not closed
merged_at string Yes Yes Merge time; null if not merged
draft boolean Yes No Whether it is a draft
can_merge_check boolean Yes No Whether the merge check passes
prune_branch boolean Yes No Delete the source branch after merging
mergeable boolean Yes No Whether there are no conflicts
user object Yes No Creator information
head object Yes No Commit information
base object Yes No Target branch information
mergeable_state object Yes No Gate information
milestone object Yes No Milestone information
visibility_reason string No Yes Visibility: public means publicly visible; other means visible only to project members
merged_by object Yes No Merged by
close_related_issue boolean No Yes Whether to close the associated issue when merging
squash_merge boolean Yes No Squash merge

assignees object array (reviewer information)

Field Type Always returned Nullable Description
assignees[].id string Yes No User ID
assignees[].login string Yes No Login name
assignees[].name string Yes No Name
assignees[].avatar_url string Yes No Avatar URL
assignees[].html_url string Yes No Home page URL
assignees[].assignee boolean Yes No Whether the user is a reviewer
assignees[].code_owner boolean Yes No Whether the user is a code owner
assignees[].accept boolean Yes No Whether accepted

testers object array (tester information)

Field Type Always returned Nullable Description
testers[].id string Yes No User ID
testers[].login string Yes No Login name
testers[].name string Yes No Name
testers[].html_url string Yes No Home page URL
testers[].assignee boolean Yes No Whether the user is a tester
testers[].code_owner boolean Yes No Whether the user is a code owner
testers[].accept boolean Yes No Whether accepted

approval_reviewers object array (approval reviewer information)

Field Type Always returned Nullable Description
approval_reviewers[].id string Yes No User ID
approval_reviewers[].login string Yes No Login name
approval_reviewers[].name string Yes No Name
approval_reviewers[].html_url string Yes No Home page URL
approval_reviewers[].assignee boolean Yes No Whether the user is a reviewer
approval_reviewers[].code_owner boolean Yes No Whether the user is a code owner
approval_reviewers[].accept boolean Yes No Whether accepted
approval_reviewers[].avatar_url string No Yes Avatar URL
approval_reviewers[].accept_status string Yes No Approval state: true (approved), reject (rejected), optional (pending)

labels object array (label information)

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 Yes No ID of the repository the label belongs to
labels[].created_at string Yes No Creation time
labels[].updated_at string Yes No Update time

user object (creator information)

Field Type Always returned Nullable Description
user.id string Yes No User ID
user.login string Yes No Login name
user.name string Yes No Name
user.avatar_url string Yes No Avatar URL
user.html_url string Yes No Home page URL

head object (commit information)

Field Type Always returned Nullable Description
head.ref string Yes No Branch path
head.sha string Yes No commit id
head.label string Yes No label
head.repo object Yes No Repository information
head.user object Yes No User information

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.namespace object Yes No Namespace information
head.repo.full_name string Yes No Full name
head.repo.html_url string Yes No Repository HTML URL

head.repo.namespace object

Field Type Always returned Nullable Description
head.repo.namespace.path string Yes No Namespace path

head.user object

Field Type Always returned Nullable Description
head.user.id string Yes No User ID
head.user.login string Yes No Login name
head.user.name string Yes No Name
head.user.avatar_url string Yes No Avatar URL
head.user.html_url string Yes No Home page URL

base object (target branch information)

Field Type Always returned Nullable Description
base.ref string Yes No Branch path
base.sha string Yes No commit id
base.label string Yes No label
base.repo object Yes No Repository information

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.namespace object Yes No Namespace information
base.repo.full_name string Yes No Full name
base.repo.html_url string Yes No Repository HTML URL

base.repo.namespace object

Field Type Always returned Nullable Description
base.repo.namespace.path string Yes No Namespace path

mergeable_state object (gate information)

Field Type Always returned Nullable Description
mergeable_state.merge_request_id integer Yes No Merge request ID
mergeable_state.state boolean Yes No State
mergeable_state.status_without_user_auth boolean Yes No State without user authorization
mergeable_state.conflict_passed boolean Yes No Conflict check passed
mergeable_state.branch_missing_passed boolean Yes No Branch missing check passed
mergeable_state.non_ff_passed boolean Yes No Non-fast-forward check passed
mergeable_state.mr_state_passed boolean Yes No Merge request state check passed
mergeable_state.merged_by_user_passed boolean Yes No Merged-by-user check passed
mergeable_state.work_in_progress_passed boolean Yes No Work in progress check passed
mergeable_state.resolve_discussion_passed boolean Yes No Discussion resolution check passed
mergeable_state.ci_state_passed boolean Yes No CI state check passed
mergeable_state.merge_by_self_passed boolean Yes No Self-merge check passed
mergeable_state.can_force_merge boolean Yes No Force merge allowed
mergeable_state.approval_reviewers_required_passed boolean Yes No Whether the code review passed
mergeable_state.approval_approvers_required_passed boolean Yes No Whether the code inspection passed
mergeable_state.approval_testers_required_passed boolean Yes No Whether the code test passed
mergeable_state.merge_request_switch object Yes No Merge request switch
mergeable_state.reason object Yes No Reason (subject to the actual response)
mergeable_state.check_tasks_num integer Yes No Total number of check items
mergeable_state.all_depend_merge_request_merged_passed boolean Yes No All dependent merge requests merged check passed
mergeable_state.approval_approvers_result integer Yes No Approver result
mergeable_state.approval_testers_result integer Yes No Tester result

mergeable_state.merge_request_switch object

Field Type Always returned Nullable Description
mergeable_state.merge_request_switch.review_mode string Yes No Review mode
mergeable_state.merge_request_switch.merge_method string Yes No Merge method
mergeable_state.merge_request_switch.only_allow_merge_if_all_discussions_are_resolved boolean Yes No Allow merging only after all discussions are resolved
mergeable_state.merge_request_switch.disable_merge_by_self boolean Yes No Disable self-merge
mergeable_state.merge_request_switch.only_allow_merge_if_pipeline_succeeds boolean Yes No Allow merging only after the pipeline succeeds
mergeable_state.merge_request_switch.disable_squash_merge boolean Yes No Disable squash merge
mergeable_state.merge_request_switch.squash_merge_with_no_merge_commit boolean Yes No Squash merge without a merge commit
mergeable_state.merge_request_switch.approval_required_reviewers_count integer Yes No Number of reviewers required for approval
mergeable_state.merge_request_switch.approval_required_reviewers_branch string Yes No Branch of the reviewers required for approval
mergeable_state.merge_request_switch.add_notes_after_merged boolean Yes No Add comments after merging
mergeable_state.merge_request_switch.mark_auto_merged_mr_as_closed boolean Yes No Mark auto-merged MRs as closed
mergeable_state.merge_request_switch.can_force_merge boolean Yes No Force merge allowed
mergeable_state.merge_request_switch.can_reopen boolean Yes No Reopen allowed

milestone object (milestone information)

Field Type Always returned Nullable Description
milestone.created_at string Yes No Creation time
milestone.description string Yes No Description
milestone.number integer Yes No Milestone ordinal number
milestone.state string Yes No State
milestone.title string Yes No Title
milestone.updated_at string Yes No Update time

merged_by object (merged by)

Field Type Always returned Nullable Description
merged_by.id string Yes No User ID
merged_by.login string Yes No Login name
merged_by.name string Yes No Name
merged_by.avatar_url string Yes No Avatar URL
merged_by.html_url string Yes No Home page URL

Error responses

If authentication fails, the parameters are invalid, or the target pull request does not exist, the endpoint returns the corresponding error status code. The error field names below are subject to what the backend actually returns.

400 Bad request

{
  "error": "invalid_request",
  "message": "The number parameter cannot be empty"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

404 Not found

{
  "error": "not_found",
  "message": "Pull request not found"
}

HTTP response status codes

Status code Description
200 Success (OK)
304 Not modified (Not Modified)
401 Authentication required (Requires authentication)
403 Forbidden (Forbidden)
404 Not found (Not Found)

Request example

Parameter descriptions

<owner> is replaced with the namespace address the repository belongs to (the address path of an enterprise, organization, or personal namespace); <repo> is replaced with the repository path (path); <number> is replaced with the number of the PR (the ordinal number of the PR in this repository).

This endpoint allows anonymous access, so the examples do not carry an access token; to access private repository resources, append the access_token query parameter: ?access_token=<token> (<token> is replaced with your AtomGit user access token).

cURL

curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>' \
  -H 'Accept: application/json'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>", {
  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>/pulls/<number>",
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "id": 111,
  "html_url": "https://api.atomgit.com/sytest/paopao/pull/1",
  "number": 1,
  "url": "https://api.atomgit.com/api/v5/repos/sytest/paopao/pulls/1",
  "issue_url": "https://api.atomgit.com/api/v5/repos/sytest/paopao/pulls/1/issues",
  "state": "open",
  "title": "Example pull request",
  "body": "Description",
  "assignees_number": 1,
  "assignees": [
    {
      "id": 2,
      "login": "test",
      "name": "test_web",
      "avatar_url": "https://api.atomgit.com/sytest/paopao/pull/1.png",
      "html_url": "https://api.atomgit.com/sytest/paopao/pull/1",
      "assignee": true,
      "code_owner": false,
      "accept": true
    }
  ],
  "testers": [
    {
      "id": 2,
      "login": "test",
      "name": "test_web",
      "html_url": "https://api.atomgit.com/sytest/paopao/pull/1",
      "assignee": true,
      "code_owner": false,
      "accept": true
    }
  ],
  "approval_reviewers": [
    {
      "id": 2,
      "login": "test",
      "name": "test_web",
      "html_url": "https://api.atomgit.com/sytest/paopao/pull/1",
      "assignee": true,
      "code_owner": false,
      "accept": true,
      "avatar_url": "https://api.atomgit.com/sytest/paopao/pull/1.png",
      "accept_status": "optional"
    }
  ],
  "labels": [
    {
      "id": 222,
      "color": "red",
      "name": "label1",
      "repository_id": 1,
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
  ],
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z",
  "closed_at": null,
  "merged_at": null,
  "draft": false,
  "can_merge_check": false,
  "prune_branch": false,
  "mergeable": true,
  "user": {
    "id": "userId",
    "login": "test",
    "name": "test_web",
    "avatar_url": "https://api.atomgit.com/avatar.png",
    "html_url": "https://api.atomgit.com/sytest/paopao/pull/1"
  },
  "head": {
    "label": "test",
    "ref": "test",
    "sha": "91861a9668041fc1c0ff51d1db66b6297179f5e6",
    "repo": {
      "path": "paopao",
      "name": "paopao",
      "namespace": {
        "path": "sytest"
      },
      "full_name": "sytest/paopao",
      "html_url": "https://api.atomgit.com/sytest/paopao"
    },
    "user": {
      "id": "userId",
      "login": "test",
      "name": "test_web",
      "avatar_url": "https://api.atomgit.com/avatar.png",
      "html_url": "https://api.atomgit.com/sytest/paopao/pull/1"
    }
  },
  "base": {
    "label": "main",
    "ref": "main",
    "sha": "91861a9668041fc1c0ff51d1db66b6297179f5e6",
    "repo": {
      "path": "paopao",
      "name": "paopao",
      "namespace": {
        "path": "sytest"
      },
      "full_name": "sytest/paopao",
      "html_url": "https://api.atomgit.com/sytest/paopao"
    }
  },
  "mergeable_state": {
    "merge_request_id": 111,
    "state": false,
    "status_without_user_auth": false,
    "conflict_passed": false,
    "branch_missing_passed": true,
    "non_ff_passed": true,
    "mr_state_passed": true,
    "merged_by_user_passed": true,
    "work_in_progress_passed": true,
    "resolve_discussion_passed": true,
    "ci_state_passed": true,
    "merge_by_self_passed": true,
    "can_force_merge": false,
    "approval_reviewers_required_passed": true,
    "approval_approvers_required_passed": true,
    "approval_testers_required_passed": true,
    "merge_request_switch": {
      "review_mode": "approval",
      "merge_method": "merge",
      "only_allow_merge_if_all_discussions_are_resolved": false,
      "disable_merge_by_self": false,
      "only_allow_merge_if_pipeline_succeeds": false,
      "disable_squash_merge": false,
      "squash_merge_with_no_merge_commit": false,
      "approval_required_reviewers_count": 0,
      "approval_required_reviewers_branch": "*",
      "add_notes_after_merged": false,
      "mark_auto_merged_mr_as_closed": false,
      "can_force_merge": false,
      "can_reopen": true
    },
    "reason": {},
    "check_tasks_num": 0,
    "all_depend_merge_request_merged_passed": true,
    "approval_approvers_result": 0,
    "approval_testers_result": 0
  },
  "milestone": {
    "created_at": "2024-01-01T00:00:00Z",
    "description": "Milestone description",
    "number": 1,
    "state": "open",
    "title": "Milestone",
    "updated_at": "2024-01-01T00:00:00Z"
  },
  "visibility_reason": "public",
  "merged_by": {
    "id": "userId",
    "login": "test",
    "name": "test_web",
    "avatar_url": "https://api.atomgit.com/avatar.png",
    "html_url": "https://api.atomgit.com/sytest/paopao/pull/1"
  },
  "close_related_issue": false,
  "squash_merge": false
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
400 Parameter error or the request cannot be parsed
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