Skip to content

Get a pull request comment

GET /api/v5/repos/{owner}/{repo}/pulls/comments/{id}

This endpoint retrieves the details of a comment on a pull request in a specified repository by comment ID, including the comment content, author information, creation and update times, and the issue and code position information associated with the comment.

Access token support

  • AtomGit user access tokens

Anonymous access 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 individual)
repo path string Yes Repository path (path)
id path string Yes Comment ID

Response parameters

Field Type Always returned Nullable Description
id integer Yes No Comment ID
discussion_id string No Yes Discussion ID
body string Yes Yes Comment content
comment_type string Yes Yes Comment type, for example DiscussionNote
user object Yes Yes User information of the comment author
target object No Yes Comment target information
created_at string Yes Yes Comment creation time
updated_at string Yes Yes Comment update time
position object No Yes Comment position information

user object

Field Type Always returned Nullable Description
user.id string Yes Yes User ID
user.login string Yes Yes User login name
user.name string Yes Yes User nickname
user.type string Yes Yes User type, for example User

target object

Field Type Always returned Nullable Description
target.issue object Yes Yes Associated issue information

target.issue object

Field Type Always returned Nullable Description
target.issue.id integer Yes Yes Issue ID
target.issue.title string Yes Yes Issue title
target.issue.number string Yes Yes Issue number

position object

Field Type Always returned Nullable Description
position.base_sha string Yes Yes Base SHA
position.start_sha string Yes Yes Start SHA
position.head_sha string Yes Yes Head SHA
position.old_path string Yes Yes Old path
position.new_path string Yes Yes New path
position.position_type string Yes Yes Position type: binary for a file-level comment, text for a code line comment
position.old_line integer Yes Yes Old line number
position.new_line integer Yes Yes New line number
position.start_old_line integer Yes Yes Start old line number
position.start_new_line integer Yes Yes Start new line number

Error responses

A 200 success response alone is not enough: callers need to know what a failure looks like in order to write error handling.

400 Invalid parameters

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

401 Unauthenticated

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

404 Comment not found

{
  "error": "not_found",
  "message": "Comment not found"
}

HTTP response status codes

Status code Description
200 Success (OK)
400 Invalid parameters (Bad request)
401 Requires authentication
403 Forbidden
404 Resource not found
500 Internal server error

Request example

Parameter description

Replace <owner> with the namespace address the repository belongs to (the address path of an enterprise, organization, or individual); replace <repo> with the repository path (path); replace <id> with the comment ID.

This endpoint allows anonymous access; if authentication is required, you can pass an AtomGit user access token.

cURL

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

print(resp.json())

Response example

Status code: 200

{
  "id": 1486664,
  "body": "1111112222222",
  "comment_type": "DiscussionNote",
  "user": {
    "id": "303745",
    "login": "yinlin",
    "name": "yinlin-nickname",
    "type": "User"
  },
  "target": {
    "issue": {
      "id": 478892,
      "title": "1111",
      "number": "478892"
    }
  },
  "created_at": "2024-09-27T14:58:51+08:00",
  "updated_at": "2024-09-27T14:58:51+08:00"
}

Error codes

Error code Description
400 Invalid parameters or unparseable request
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
403 Forbidden
404 Request path not found
429 Too many requests, rate limit triggered
500 Internal server error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc