# GitHub Issue 搜索 API (github.search_issues)

- Canonical page: https://everyinfra.com/github-api/search_issues
- Endpoint: POST /api/v1/social with {"platform": "github", "action": "search_issues", "params": {...}}
- Price: $0.001917 per call ($1.92 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 搜索用 GitHub 自己的搜索语法，在全站公开仓库里找 Issue 和 PR，每条带标题、正文、状态、标签、评论数、表情反应数 `reaction_count`、所属仓库和作者。它回答「全网有谁在讨论这个报错、这个功能、这个库」：开发者关系团队用它追踪产品被提到的地方，开源维护者用它找散落在别的仓库里的同类问题，研究者用它统计某类缺陷的分布。

`keyword` 里可以叠加 repo:、label:、author: 等限定词缩小范围。已经确定只看一个仓库时，改用仓库的 Issue 与 PR 那一页更省事，它按 `url` 读整个仓库，还能按状态筛；这一页的状态靠 is:open、is:closed 这类限定词。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | GitHub Issue 搜索语句，跨仓库搜 Issue 和 PR，支持 repo:、is:pr、is:issue、label:、author: 等限定词。 |
| sort | enum: comments / created / reactions / updated | no | not declared | 不传按相关度；comments、created、updated、reactions 按对应项从多到少 / 从新到旧。 |
| 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": "search_issues",
  "params": {
    "keyword": "coffee"
  }
}'
```

```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": "search_issues",
        "params": {
            "keyword": "coffee",
        },
    },
    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": "search_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

### 怎么只搜 PR 或只搜 Issue？

在 `keyword` 里加限定词：is:pr 只要 PR，is:issue 只要 Issue，再配合 is:open、is:closed 限定状态。限定词可以叠加，例如把 repo: 和 is:pr 一起写进 `keyword`，就只看某个仓库里的 PR。结果里的 `is_pull_request` 也能区分两者，`merged_at` 只在 PR 被合并之后才有值。`repository` 标出每条属于哪个仓库，跨仓库的结果按它分组，就能看出问题集中在哪些项目。

### `sort` 不传时按什么排？

不传按相关度，最贴合搜索语句的排在前面。`sort` 取 `comments` 或 `reactions` 时按评论数、表情反应数从多到少，适合找讨论最热的问题；取 `created` 或 `updated` 时按创建、最近更新时间从新到旧，适合追踪最新动态。结果里的 `reaction_count` 和 `comment_count` 就是排序的依据，其中 `comment_count` 为 null 表示不公开，不等于 0。`text` 是去掉 HTML 标签的全文，不截断。

### `author_association` 有什么用？

它说明发帖人和这个仓库的关系，比如仓库所有者、组织成员、贡献者，还是第一次参与的新人。把维护者自己开的条目筛掉，剩下的就是外部用户真实遇到的问题，做用户反馈分析时很有用。想只看第一次来提问的新人，筛 FIRST_TIME_CONTRIBUTOR；Bot 开的条目可以用 `author_type` 分出来，它的取值是 User、Bot 或 Organization。

## 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
