# GitHub 热榜 API (github.trending)

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

GitHub 热榜不需要任何参数，直接返回 GitHub Trending 榜单上的仓库，`rank` 按榜单顺序从 1 开始，默认 25 条，单次最多也是 25 条。每行有仓库全名 `full_name`、主人 `owner_username`、仓库名 `name`、简介 `description` 和链接 `url`。它回答「GitHub 上哪些项目正在上榜」，适合发现新工具、收集选型灵感和写开源动向周报。

`full_name` 是 owner/repo 写法，仓库改过名或转过主人时是新名字；`name` 不含主人，跨仓库去重时用 `full_name` 更稳。`description` 通常比正文短，只够判断这个仓库做什么，要看许可证、星标这类详情，去仓库详情那一页。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| limit | integer (1–25) | no | 25 | 这次调用最多返回的条数，整数，1–25；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| rank | 在这次返回里的名次，从 1 开始（contributors 按提交数，trending 按 GitHub Trending 榜单顺序）。 |
| full_name | 仓库全名 owner/repo；仓库改过名或转过主人时是新名字。 |
| owner_username | 仓库主人（用户或组织）的用户名。 |
| name | 仓库名（不含 owner）。 |
| url | 该记录在原平台上的可访问链接。 |
| description | 简介或描述，通常比 text 短。 |
| 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": "trending",
  "params": {}
}'
```

```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": "trending",
        "params": {},
    },
    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": "trending",
  "results": [
    {
      "rank": …,
      "full_name": …,
      "owner_username": …,
      "name": …,
      "url": …,
      "description": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 热榜和仓库贡献者那一页有什么不同？

热榜列的是仓库，不需要传参数，名次来自 GitHub Trending 榜单；仓库贡献者列的是一个仓库里的人，要传仓库链接，名次按提交数。把热榜里感兴趣的仓库交给后者，就能看到主要提交者。

### 热榜单次能返回多少条？

默认 25 条，上限也是 25 条，没有更多可取；`limit` 调小，就只取榜单靠前的几条，`rank` 仍然从 1 开始。

### 榜单里的仓库怎么继续查详情？

把 `full_name` 交给仓库详情那一页，它接受 owner/repo 写法，返回星标数、分叉数、开源许可证和最近推送时间。`owner_username` 是仓库主人的用户名，想看这个人名下还有哪些仓库，交给用户的仓库那一页。

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