Skip to content

Pull request commit file list

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

This endpoint queries the list of files changed by a pull request (merge request) in the specified repository and returns the path, status, added and deleted line counts, and diff patch information of each changed file, as well as data on the source and target branches and the repositories they belong to.

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 enterprise, 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 (corresponds to iid)

Response parameters

The endpoint returns an array whose elements contain the change information of each changed file in the pull request.

Field Type Always returned Nullable Description
sha string Yes No Commit SHA corresponding to the file change
filename string Yes No File path
status string Yes Yes Change status; may be null
additions integer Yes Yes Number of added lines
deletions integer Yes Yes Number of deleted lines
blob_url string Yes Yes URL of the blob page of the changed file
raw_url string Yes Yes URL of the raw content of the changed file
patch object Yes Yes Change patch information (diff and so on)
target_branch string Yes Yes Target branch
source_branch string Yes Yes Source branch
target_project object Yes Yes Target repository information
source_project object Yes Yes Source repository information

patch object

Field Type Always returned Nullable Description
patch.diff string Yes Yes Diff content of the change
patch.old_path string Yes Yes File path before the change
patch.new_path string Yes Yes File path after the change
patch.a_mode string Yes Yes File mode before the change (for example, 100644)
patch.b_mode string Yes Yes File mode after the change (for example, 100644)
patch.new_file boolean Yes Yes Whether the file is newly added
patch.renamed_file boolean Yes Yes Whether the file is renamed
patch.deleted_file boolean Yes Yes Whether the file is deleted
patch.too_large boolean Yes Yes Whether the file is too large
patch.added_lines integer Yes Yes Number of added lines in the patch
patch.removed_lines integer Yes Yes Number of deleted lines in the patch

target_project object

Field Type Always returned Nullable Description
target_project.id string Yes No Repository ID
target_project.full_name string Yes No Full repository name
target_project.human_name string Yes No Human-readable name
target_project.path string Yes No Repository path

source_project object

Field Type Always returned Nullable Description
source_project.id string Yes No Repository ID
source_project.full_name string Yes No Full repository name
source_project.human_name string Yes No Human-readable name
source_project.path string Yes No Repository path

Error responses

The reference documentation does not provide a business failure response example for this endpoint. When the repository or pull request does not exist, or the parameters are invalid or permissions are insufficient, the endpoint returns a non-2xx status code; the error body structure is subject to the actual response.

HTTP response status codes

Status code Description
200 Success (OK)
400 Parameter error
401 Authentication required (Requires authentication)
403 Forbidden (Forbidden)
404 The repository or pull request does not exist
429 Too many requests; rate limit triggered
500 Internal system error

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, that is, the ordinal number of the PR in this repository.

This endpoint allows anonymous access, so the examples do not carry an access token; if needed, you can also append ?access_token=<token> to the URL (<token> is replaced with your AtomGit user access token).

cURL

curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/files' \
  -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>/files", {
  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>/files",
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

[
  {
    "sha": "45e1211262a0ed24eeb85ac37f7776259ef0e7e1",
    "filename": "README.md",
    "status": null,
    "additions": 3,
    "deletions": 1,
    "blob_url": "https://api.atomgit.com/<owner>/<repo>/blob/45e1211262a0ed24eeb85ac37f7776259ef0e7e1/README.md",
    "raw_url": "https://api.atomgit.com/<owner>/<repo>/raw/45e1211262a0ed24eeb85ac37f7776259ef0e7e1/README.md",
    "patch": {
      "diff": "@@ -1,3 +1,4 @@\n+# new line added\n demo content",
      "new_path": "README.md",
      "old_path": "README.md",
      "a_mode": "100644",
      "b_mode": "100644",
      "new_file": false,
      "renamed_file": false,
      "deleted_file": false,
      "too_large": false,
      "added_lines": 3,
      "removed_lines": 1
    },
    "target_branch": "master",
    "source_branch": "feature/demo",
    "target_project": {
      "id": "1",
      "full_name": "<owner>/<repo>",
      "human_name": "<owner>/<repo>",
      "path": "<repo>"
    },
    "source_project": {
      "id": "1",
      "full_name": "<owner>/<repo>",
      "human_name": "<owner>/<repo>",
      "path": "<repo>"
    }
  }
]

Error codes

Error code Description
400 Parameter error or the request cannot be parsed
401 Unauthenticated or invalid credentials
403 Forbidden (Forbidden)
404 The repository or pull request does not exist
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