0

List Issue Comments

Published Oct 12, 2026

List the comments on an issue or pull request, oldest first. Paginate with page.

Script github Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 40 days ago
1
//native
2

3
/**
4
 * List Issue Comments
5
 * List the comments on an issue or pull request, oldest first. Paginate with page.
6
 */
7
export async function main(
8
  auth: RT.Github,
9
  owner: string,
10
  repo: string,
11
  issue_number: number,
12
  since: string | undefined,
13
  per_page: number = 30,
14
  page: number = 1
15
) {
16
  const url = new URL(
17
    `https://api.github.com/repos/${owner}/${repo}/issues/${issue_number}/comments`
18
  )
19
  for (const [k, v] of Object.entries({ since, per_page, page })) {
20
    if (v != null && v !== "") url.searchParams.append(k, String(v))
21
  }
22

23
  const response = await fetch(url, {
24
    headers: {
25
      Authorization: `Bearer ${auth.token}`,
26
      Accept: "application/vnd.github+json",
27
      "X-GitHub-Api-Version": "2022-11-28",
28
    },
29
  })
30

31
  if (!response.ok) {
32
    throw new Error(`${response.status} ${await response.text()}`)
33
  }
34

35
  return await response.json()
36
}
37