# GitHub 仓库的 Issue 与 PR API (github.repository_issues)

- Canonical page: https://everyinfra.com/github-api/repository_issues
- Endpoint: POST /api/v1/social with {"platform": "github", "action": "repository_issues", "params": {...}}
- Price: $0.000958 per call ($0.96 per 1,000 requests); failed and empty results are not charged
- Returns: list, default 30, max 100 per call
- Mode: sync; add "mode": "async" for slow tasks

GitHub 仓库 Issue 与 PR 按 `url` 列出一个仓库里的 Issue 和 PR，可以用 `state` 只看未关闭、已关闭或全部，用 `sort` 按创建时间、最近更新或评论数排序。它回答「这个项目现在积压了哪些问题、最近合并了什么」，适合技术选型前评估一个开源库是否活跃、维护者响应快不快，也适合给自己的仓库做周报和发版前的盘点。

`url` 填仓库链接或 owner/repo 写法；Issue 与 PR 混在同一个列表里返回。`state` 不传时只返回 `open` 的条目，`sort` 不传时按创建时间排，三种排序都是从多到少或从新到旧。想跨仓库按关键词找，用 Issue 搜索；那一页不收 `state`，也不限定在一个仓库里。

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=github&action=repository_issues

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | GitHub 仓库链接或 owner/repo；返回这个仓库的 Issue 和 PR（is_pull_request 区分）。 |
| sort | enum: comments / created / updated | no | not declared | created（默认，按创建时间）、updated（按最近更新）、comments（按评论数），都是从多到少 / 从新到旧。 |
| state | enum: all / closed / open | no | not declared | open（默认）、closed、all。 |
| limit | integer (1–100) | no | 30 | 这次调用最多返回的条数，整数，1–100；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | GitHub 内部数字 ID（字符串）。 |
| number | Issue 或 PR 在仓库里的编号。 |
| url | 该记录在原平台上的可访问链接。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| state | open 或 closed。 |
| is_pull_request | 这一条是 PR（true）还是 Issue（false）。 |
| is_draft | PR 是否草稿；Issue 为 false。 |
| labels | 标签名列表；没有标签时没有这个字段。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| reaction_count | 表情回应总数。 |
| repository | 所在仓库 owner/repo。 |
| author_username | 作者用户名（@handle），通常可用于拼 URL。 |
| author_id | 作者在原平台的唯一 ID。 |
| author_avatar_url | 作者头像图片链接（多数平台带签名、会过期）。 |
| author_type | 作者账号类型：User、Bot 或 Organization。 |
| author_association | 作者和仓库的关系，GitHub 原值：OWNER、MEMBER、COLLABORATOR、CONTRIBUTOR、FIRST_TIME_CONTRIBUTOR、NONE 等。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| updated_at | 最近更新时间，ISO 8601 UTC。 |
| closed_at | 关闭时间，ISO 8601 UTC；没关闭时没有。 |
| merged_at | PR 合并时间，ISO 8601 UTC；Issue 或没合并的 PR 没有。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## Example

```bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "github",
  "action": "repository_issues",
  "params": {
    "url": "https://github.com/facebook/react"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "github",
        "action": "repository_issues",
        "params": {
            "url": "https://github.com/facebook/react",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "github",
  "action": "repository_issues",
  "results": [
    {
      "id": …,
      "number": …,
      "url": …,
      "title": …,
      "text": …,
      "state": …,
      "is_pull_request": …,
      "is_draft": …,
      "labels": …,
      "comment_count": …,
      "reaction_count": …,
      "repository": …,
      "author_username": …,
      "author_id": …,
      "author_avatar_url": …,
      "author_type": …,
      "author_association": …,
      "posted_at": …,
      "updated_at": …,
      "closed_at": …,
      "merged_at": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 怎么分开统计 Issue 和 PR？

看 `is_pull_request`：为真的是 PR，为假的是 Issue。PR 还可以用 `is_draft` 判断是不是草稿，`merged_at` 有值说明已经合并；只有 `closed_at`、没有 `merged_at` 的 PR，是被关掉而没有合并的。想算 PR 的合并比例，把 `state` 设为 `closed`，用有 `merged_at` 的 PR 数除以已关闭的 PR 总数。

### 怎么判断一个项目维护得是否积极？

把 `state` 设为 `all`、`sort` 设为 `updated`，看最近一批条目的 `updated_at` 和 `closed_at` 离现在有多远；再对比未关闭与已关闭条目的比例和 `comment_count` 的分布，大致就能看出问题积压程度和处理速度。处理时长可以用 `closed_at` 减 `posted_at` 来算，两个时间都是 ISO 8601 的 UTC 时间；`closed_at` 没有值，说明这条还没关闭。`reaction_count` 能看出哪些问题被用户关注得多。

### `labels` 能拿来做什么？

`labels` 是这条 Issue 或 PR 上打的标签，比如缺陷、功能请求、新手友好。按标签分组统计，就能看出一个项目的问题主要集中在哪一类；想找能上手贡献的任务时，筛选带新手类标签的条目最快。没有标签的条目没有 `labels` 这个字段，读取时按缺省处理。`state` 保持默认的 `open` 时按标签分组，看到的是还没关闭的问题里哪类最多；换成 `closed`，看的是已经处理掉的那些。`labels` 是一个列表，一条可能同时带几个标签，分组时会被算进几组。

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=github
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
