# GitHub Issue Comment-Limit Headroom and Lockout Forecast (`kingii98/github-issue-comment-limit-headroom-and-lockout-forecast`) Actor

Forecast the date when a GitHub issue reaches the 2,500 comment limit.

- **URL**: https://apify.com/kingii98/github-issue-comment-limit-headroom-and-lockout-forecast.md
- **Developed by:** [kingii98](https://apify.com/kingii98) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.00 / 1,000 issue checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## GitHub Issue Comment-Limit Headroom and Lockout Forecast

GitHub rejects new comments on an issue after 2,500 comments. This Actor shows how many comments remain. It forecasts the date when the issue reaches the limit. Use it to move a long thread before comments fail.

### Input

| Field | Description | Default |
| --- | --- | --- |
| `issueUrls` | Up to 100 public issue URLs. | One example issue |
| `repositoryUrl` | Optional. One public repository. The Actor checks its issues with the most comments. It replaces `issueUrls`. | none |
| `minComments` | Repository mode only. Skip issues with fewer comments. | 1 |
| `maxIssues` | Maximum issues for one run (1 to 100). | 100 |
| `warningThreshold` | Comment count that sets the status `warning`. | 2000 |
| `githubToken` | Optional. Your own token for a higher GitHub API rate limit. The Actor sends it only to `api.github.com`. | none |

An empty input `{}` runs the default example and succeeds.

### Output

The Actor writes one dataset row for each issue.

| Field | Meaning |
| --- | --- |
| `issueUrl`, `number`, `title`, `state` | The issue. |
| `commentCount` | Comments now. |
| `remainingComments` | 2,500 minus `commentCount`. Minimum 0. |
| `commentsPerDay` | Comment count for each of the last 7 UTC days. |
| `commentsLast7Days`, `averagePerDay` | Total and mean rate. Both use the window that starts at 00:00 UTC, 6 days before today, and ends now. `commentsLast7Days` equals the sum of `commentsPerDay`. |
| `rateIsEstimate` | `true` when the Actor did not fetch all comments of the window. The Actor fetches the newest comments, at most 2 pages of 100 comments. The oldest fetched comment is then newer than the window start, and the rate uses the time span of the fetched comments. |
| `forecastLockoutDate` | Date (UTC) when the issue reaches 2,500 comments at the current rate. `null` when there is no rate, or when the date is more than 10 years away. |
| `daysToLockout` | Days to that date. |
| `status` | `ok`, `warning`, `locked`, or `unavailable`. |
| `message` | Reason, for an `unavailable` row. |

Status rules:

- `locked`: 2,500 comments or more.
- `warning`: comment count is at or above `warningThreshold`.
- `ok`: all other issues.
- `unavailable`: the Actor could not check the issue. Reasons: bad URL, issue not public, redirect, or GitHub API rate limit.

A bad target or an unavailable issue is a dataset row and a status message. The run still succeeds.

### Pricing event

The Actor uses pay-per-event pricing with one event.

| Event | Charged when | Count |
| --- | --- | --- |
| `issue-checked` | The Actor writes a headroom row (`ok`, `warning`, or `locked`). | 1 for each issue |

The Actor does not charge for `unavailable` rows. The Actor stops when the maximum charge limit is reached. Each issue costs one issue request and at most two comment-page requests.

This README does not set a price. Pricing is set outside this repository.

### Limits

- Input limit: 100 issues for each run.
- Only `https://github.com/OWNER/REPO/issues/NUMBER` URLs are accepted. All requests go to `api.github.com`.
- The Actor does not follow redirects. Response size limit: 2 MB. Request timeout: 20 seconds. Concurrency: 5.
- The 2,500 comment limit comes from public issue reports. GitHub can change it. Check the constant `COMMENT_LIMIT` in `src/logic.py`.
- The Actor keeps no state. It calculates the rate from comment timestamps. Use an Apify schedule to run it each day.
- Without a token, the GitHub API rate limit is low (60 requests each hour). One issue uses up to 3 requests.

### Development

```
uv run pytest
uv run ruff check .
```

# Actor input Schema

## `issueUrls` (type: `array`):

Public GitHub issue URLs. Maximum 100. Use the form https://github.com/OWNER/REPO/issues/NUMBER. The Actor ignores this field when you set a repository URL.

## `repositoryUrl` (type: `string`):

Optional. A public repository URL, for example https://github.com/OWNER/REPO. The Actor checks the issues with the most comments. Use it instead of issue URLs.

## `minComments` (type: `integer`):

Repository mode only. The Actor skips issues with fewer comments.

## `maxIssues` (type: `integer`):

Maximum number of issues to check in one run.

## `warningThreshold` (type: `integer`):

An issue gets the status warning when its comment count reaches this value.

## `githubToken` (type: `string`):

Optional. A token that you supply gives a higher GitHub API rate limit. The Actor sends it only to api.github.com. A token with no scopes is enough for public issues.

## Actor input object example

```json
{
  "issueUrls": [
    "https://github.com/octocat/Hello-World/issues/1"
  ],
  "minComments": 1,
  "maxIssues": 100,
  "warningThreshold": 2000
}
```

# Actor output Schema

## `headroom` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "issueUrls": [
        "https://github.com/octocat/Hello-World/issues/1"
    ],
    "minComments": 1,
    "maxIssues": 100,
    "warningThreshold": 2000
};

// Run the Actor and wait for it to finish
const run = await client.actor("kingii98/github-issue-comment-limit-headroom-and-lockout-forecast").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "issueUrls": ["https://github.com/octocat/Hello-World/issues/1"],
    "minComments": 1,
    "maxIssues": 100,
    "warningThreshold": 2000,
}

# Run the Actor and wait for it to finish
run = client.actor("kingii98/github-issue-comment-limit-headroom-and-lockout-forecast").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "issueUrls": [
    "https://github.com/octocat/Hello-World/issues/1"
  ],
  "minComments": 1,
  "maxIssues": 100,
  "warningThreshold": 2000
}' |
apify call kingii98/github-issue-comment-limit-headroom-and-lockout-forecast --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kingii98/github-issue-comment-limit-headroom-and-lockout-forecast"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/YVGAfJGJS8HxiTbPS/builds/sZtym0ahOa27AOJsD/openapi.json
