sodcalculator

10 Tech How-To

GitHub Issue Replies: Define & Measure Responses

Guide 10-13841 · Updated · Step by step

GitHub issue replies are the comments and responses posted on an issue thread, and measuring them means tracking their count, frequency, and content to understand project activity and contributor engagement. This article explains how to define these replies in the GitHub API and how to measure them using built-in tools, scripts, and third-party services.

What Counts as a Reply on a GitHub Issue

On GitHub, an issue is a discussion thread. The original post is the issue body, and every subsequent comment is a reply. These replies can come from anyone with read access to the repository, including maintainers, contributors, and sometimes bots. Each reply is stored as an issue comment in the GitHub database, separate from the issue itself. A reply can be a simple acknowledgment, a question, a code snippet, or a lengthy technical discussion. GitHub also allows reactions (like thumbs-up) on comments, but these are not replies—they are lightweight signals. Pull request reviews and review comments are also distinct from issue replies, even though they appear in the same thread.

How the GitHub API Defines Replies

The GitHub REST API exposes issue comments through the GET /repos/{owner}/{repo}/issues/{issue_number}/comments endpoint. Each comment object has an id, user, created_at, updated_at, and body. The API does not have a separate “reply” field—every comment on an issue is a reply. However, the API also includes issue events (like labeled, closed, referenced) which are not replies. To measure replies accurately, you must filter for comments only. The GraphQL API offers a similar structure: the Issue object has a comments connection with totalCount and edges. Both APIs paginate results (default 30 per page for REST, 100 for GraphQL), so measuring all replies requires handling pagination.

Measuring Reply Count with the API

The simplest way to measure replies is to use the totalCount field in GraphQL:

query {
  repository(owner: "octocat", name: "Hello-World") {
    issue(number: 1) {
      comments {
        totalCount
      }
    }
  }
}

This returns the total number of comments on that issue. For REST, you can call the comments endpoint and read the Link header to find the last page, or use a library like PyGithub or Octokit that handles pagination automatically. In Python, using PyGithub:

from github import Github
g = Github("your_token")
repo = g.get_repo("octocat/Hello-World")
issue = repo.get_issue(1)
print(issue.comments)  # total count

Note that issue.comments is a property that returns the count, not the list. To get the actual comments, iterate issue.get_comments().

Measuring Reply Frequency and Timing

Counting replies is just the start. Often you want to measure the time between the issue creation and the first reply, or the average time between replies. The API provides created_at timestamps for each comment, so you can calculate these in Python:

from datetime import datetime
comments = list(issue.get_comments())
first_reply = comments[0].created_at if comments else None
issue_created = issue.created_at
if first_reply:
    delta = first_reply - issue_created
    print("First reply after", delta.total_seconds() / 3600, "hours")

For frequency, you can group comments by day or week and plot the trend. This is useful for understanding whether an issue is getting more or less attention over time.

Tools and Libraries for Measuring Replies

Several tools simplify this process:

  • PyGithub – Python library that wraps the REST API, handles pagination, and provides a simple object model.
  • Octokit – Official GitHub client for JavaScript, Ruby, .NET, and other languages.
  • GitHub CLI – Command-line tool with gh api to make raw API calls.
  • gh issue view –comments – Shows comments in the terminal, but not ideal for measurement.
  • GitHub Actions – You can schedule a workflow that calls the API and stores metrics.
  • Third-party analytics – Tools like GitClear or SonarCloud may provide issue metrics, but they often focus on code, not comments.

For a quick manual check, the GitHub web UI shows the comment count on the issue page, but it does not show timestamps for all comments without scrolling.

Common Problems and Pitfalls

When measuring replies, watch out for these issues:

  • Pagination – The REST API returns 30 comments per page by default. If you don’t loop through pages, you’ll undercount.
  • Bot comments – Automated comments (e.g., from dependabot or stale-bot) may inflate the count. You can filter by user.type (User vs Bot) if needed.
  • Deleted comments – The API does not return deleted comments, so your count may be lower than what actually happened.
  • Rate limits – Unauthenticated requests are limited to 60 per hour. Use a token to get 5000 per hour.
  • Timestamps – All times are in UTC. Convert to your local timezone for display.
  • Issue vs PR – Pull requests also have comments, but they have a separate review comment endpoint. Make sure you’re querying the right type.

Comparing Reply Metrics Across Repositories

To compare reply activity across multiple repos, you need a consistent measurement window. For example, you could measure the median time to first reply for issues created in the last 30 days. This requires querying all issues with created:>2025-01-01 and then fetching comments for each. This can be heavy on API calls, so consider using GraphQL batching or a tool like GitHub’s search API to pre-filter. A common metric is the response time (time to first reply) and resolution time (time to close). These are often used in open-source health dashboards. Remember that a reply does not mean the issue is resolved; it just means someone responded.

Frequently Asked Questions

How do I count all replies on a GitHub issue using Python?

Use PyGithub: issue.get_comments() returns a paginated list, and you can iterate over it. The issue.comments property gives the total count directly, but it may be stale if the issue has many comments. To get an accurate count, use len(list(issue.get_comments())) or rely on the API’s total count.

Does the GitHub API include replies to replies?

No. GitHub issues are flat—there is no nested threading. All comments are at the same level. If someone replies to a specific comment using the “quote reply” feature, it still appears as a new top-level comment. The API does not track parent-child relationships.

Can I measure the sentiment of replies?

Yes, but not directly from the API. You would need to fetch the comment bodies and run sentiment analysis with a library like VADER (for English) or a transformer model. This is beyond the API’s scope, but it’s a common extension.

What is the difference between an issue comment and a review comment?

An issue comment is a reply on an issue or pull request thread. A review comment is a comment made on a specific line of code during a pull request review. They have different API endpoints: /issues/{number}/comments for issue comments and /pulls/{number}/comments for review comments.

How do I export all replies to a CSV file?

Fetch all comments via the API, then write the fields (id, user, created_at, body) to a CSV using Python’s csv module. Be careful with newlines in the body—use proper quoting. Example: writer.writerow([c.id, c.user.login, c.created_at, c.body]).

Why does the comment count on the GitHub website differ from the API?

The website may show a cached count or include inline review comments on pull requests. For issues, the count should match the API, but if the issue has been edited or comments deleted, the counts can diverge. Always use the API for accurate measurement.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →