# GitHub 仓库贡献者 API (github.contributors)

- Canonical page: https://everyinfra.com/github-api/contributors
- Endpoint: POST /api/v1/social with {"platform": "github", "action": "contributors", "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 仓库贡献者按 `url` 列出一个仓库的提交者，按提交数从多到少排，`rank` 从 1 开始。每行有用户名 `username`、数字 ID `id`、头像链接 `avatar_url`、这个人在该仓库的提交数 `contribution_count` 和账号类型 `account_type`。它回答「这个项目主要是谁在写」，适合找核心维护者、了解一个开源库的人员构成，或者挑出值得联系的开发者。

`url` 填仓库链接或 owner/repo 写法，默认返回 30 条，单次最多 100 条。热榜那一页列的是仓库，这一页列的是仓库里的人：在热榜挑到感兴趣的项目，再来这里看谁在贡献。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | GitHub 仓库链接或 owner/repo；按提交数从多到少返回贡献者。 |
| limit | integer (1–100) | no | 30 | 这次调用最多返回的条数，整数，1–100；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| rank | 在这次返回里的名次，从 1 开始（contributors 按提交数，trending 按 GitHub Trending 榜单顺序）。 |
| username | 用户名（@handle）。 |
| id | GitHub 内部数字 ID（字符串）。 |
| url | 该记录在原平台上的可访问链接。 |
| avatar_url | 头像图片链接。部分平台给的是带尺寸参数的 CDN 链接，可能有时效。 |
| contribution_count | 在这个仓库的提交数（contributors）。 |
| account_type | 账号类型：User、Bot 或 Organization。 |
| 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": "contributors",
  "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": "contributors",
        "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": "contributors",
  "results": [
    {
      "rank": …,
      "username": …,
      "id": …,
      "url": …,
      "avatar_url": …,
      "contribution_count": …,
      "account_type": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 这里的 `rank` 和热榜那一页的 `rank` 是一回事吗？

不是。这里的 `rank` 按提交数从多到少排，热榜那一页的 `rank` 跟着 GitHub Trending 榜单的顺序走。两边都从 1 开始，别把它们放进同一张表里比较。

### `contribution_count` 是这个人在 GitHub 上的总提交数吗？

不是，它只统计这个人在你传入的这个仓库里的提交数。同一个人在另一个仓库的提交数，要换一个 `url` 再调一次。

### 怎么只统计真人贡献者？

看 `account_type`，取值是 User、Bot 或 Organization。把 Bot 和 Organization 去掉，再按 `contribution_count` 排，剩下的就是个人贡献者的排序。`id` 是字符串形式的 GitHub 内部数字 ID，合并多个仓库的名单时可以拿它去重。

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