# GitHub 用户的仓库 API (github.user_repositories)

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

GitHub 用户的仓库按 `username` 列出这个账号自己名下的公开仓库，每个带全名、描述、语言、许可证、主题标签、星标数、分叉数、是否为分叉 `is_fork`、是否归档，以及创建、更新和推送时间。它回答「这个开发者或组织在做哪些项目」，适合招聘时了解候选人的技术方向，或盘点一家公司开源了什么。

用 `sort` 按创建时间、更新时间、推送时间或仓库名排序，不传就按 GitHub 默认顺序；`username` 可以填用户名，也可以填主页链接。单次默认 30 条，上限也是 30 条，比分叉列表那一页低。`license` 在这里照常返回，分叉列表那一页不给许可证。要读某个仓库的完整概况，把 `full_name` 交给仓库详情。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| username | not declared | yes | not declared | GitHub 用户名或主页链接；返回这个账号自己名下的公开仓库。 |
| sort | enum: created / full_name / pushed / updated | no | not declared | created、updated、pushed、full_name；不传按 GitHub 默认顺序。 |
| limit | integer (1–30) | no | 30 | 这次调用最多返回的条数，整数，1–30；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | GitHub 内部数字 ID（字符串）。 |
| full_name | 仓库全名 owner/repo；仓库改过名或转过主人时是新名字。 |
| name | 仓库名（不含 owner）。 |
| owner_username | 仓库主人（用户或组织）的用户名。 |
| owner_url | 仓库主人的 GitHub 主页链接。 |
| owner_avatar_url | 仓库主人的头像链接。 |
| url | 该记录在原平台上的可访问链接。 |
| description | 简介或描述，通常比 text 短。 |
| homepage | 仓库填写的项目主页；没填时没有这个字段。 |
| language | 内容语言代码（如 zh、en），由平台判定，可能不准。 |
| license | 开源许可证名称（如 MIT License）；没声明时没有；分叉列表不给。 |
| topics | 仓库主题标签列表；没有时没有这个字段。 |
| star_count | 星标数。 |
| fork_count | 分叉数。 |
| open_issue_count | 未关闭的 Issue 加 PR 数（GitHub 口径）。 |
| default_branch | 默认分支名。 |
| is_fork | 这个仓库本身是不是分叉（repository / user_repositories）。 |
| is_archived | 仓库是否已归档（只读）。 |
| size_kb | 仓库大小，单位 KB（GitHub 口径）。 |
| created_at | 创建时间，格式同 posted_at。 |
| updated_at | 最近更新时间，ISO 8601 UTC。 |
| pushed_at | 最近一次推送代码的时间，ISO 8601 UTC（repository / user_repositories / forks）。 |
| 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": "user_repositories",
  "params": {
    "username": "torvalds"
  }
}'
```

```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": "user_repositories",
        "params": {
            "username": "torvalds",
        },
    },
    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": "user_repositories",
  "results": [
    {
      "id": …,
      "full_name": …,
      "name": …,
      "owner_username": …,
      "owner_url": …,
      "owner_avatar_url": …,
      "url": …,
      "description": …,
      "homepage": …,
      "language": …,
      "license": …,
      "topics": …,
      "star_count": …,
      "fork_count": …,
      "open_issue_count": …,
      "default_branch": …,
      "is_fork": …,
      "is_archived": …,
      "size_kb": …,
      "created_at": …,
      "updated_at": …,
      "pushed_at": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 怎么只看他自己写的项目、排除分叉来的？

按 `is_fork` 过滤，为 true 的是从别人那里分叉过来的仓库。去掉这些，再按 `star_count` 排序，剩下的就是这个账号原创、并且受关注的项目。已归档的仓库 `is_archived` 为 true，是只读的，只想看还在维护的原创项目，就把它们一起去掉。`fork_count` 是这个仓库被分叉的次数，可以和 `star_count` 对照着看。

### 怎么找出最近还在动的仓库？

`sort` 传 `pushed`，最近推送过代码的仓库排在前面；对照每个仓库的 `pushed_at`，就能看出这个人最近把精力放在哪个项目上。`sort` 还能取 `created`、`updated` 和 `full_name`，不传就按 GitHub 默认顺序。`pushed_at` 和 `updated_at` 是两个时间，前者专指推送代码，判断有没有人在写代码时看前者。

### 能看出一个人主要用什么语言吗？

能粗略看出。统计这一批仓库的 `language`，出现次数最多的语言就是他写得最多的。单次最多返回 30 个仓库，样本有限，只能当参考。`language` 由平台判定，可能不准；`topics` 是仓库自己的主题标签，没有时没有这个字段，可以当作语言之外的另一条线索。想看受关注的方向，可以把每个仓库的 `star_count` 当权重，再统计 `language`。

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