# GitHub 仓库详情 API (github.repository)

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

GitHub 仓库详情按 `url`（仓库链接或 owner/repo）读取一个公开仓库的概况：描述、主页、主要语言、开源许可证 `license`、主题标签 `topics`、星标数、分叉数、未关闭的 Issue 加 PR 数、默认分支、是否归档、仓库大小，以及创建、更新和最近推送时间。它回答「这个项目是什么、还有没有人在维护」，常用于技术选型、开源依赖审查和竞品项目跟踪。

仓库改过名或转过主人时，`full_name` 返回新名字，旧链接照样能查。判断活跃度看 `pushed_at` 比看 `updated_at` 更直接。`homepage`、`license`、`topics` 没填或没声明时，整个字段不出现。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | GitHub 仓库链接或 owner/repo，例如 https://github.com/facebook/react；仓库改过名时返回新名字。 |

## 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": "repository",
  "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",
        "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",
  "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": …
  },
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 怎么判断一个开源项目还在维护？

先看 `pushed_at`，它是最近一次推送代码的时间；再看 `is_archived`，归档的仓库已经只读。`open_issue_count` 算的是 Issue 加 PR，看它时要把这一点算进去。`created_at` 和 `pushed_at` 的间隔能看出项目是一直在推还是不久就停了；`created_at`、`updated_at`、`pushed_at` 都是 ISO 8601 的 UTC 时间。`default_branch` 是默认分支名，`size_kb` 是仓库大小，单位 KB。

### `open_issue_count` 只算 Issue 吗？

不是。按 GitHub 的口径，它是未关闭的 Issue 和 PR 加在一起的数，直接拿来当 Issue 数会偏大。要拆开数，就去仓库的 Issue 与 PR 那一页，那里每条记录标明是 Issue 还是 PR，分开统计即可。`star_count` 和 `fork_count` 是另外两个现成的热度数字，分别是星标数和分叉数。

### 仓库详情和用户的仓库该用哪个？

已经知道要看哪个仓库，用仓库详情，一次读一个；想看一个用户或组织名下有哪些仓库，用用户的仓库，一次列出一批再挑，挑中的再传 `full_name` 回来读详情。两页返回的字段是同一套，区别只在入口：仓库详情按仓库链接读一个，用户的仓库按用户名读一批，并多一个排序参数。`is_fork` 标出这个仓库自己是不是分叉，`license` 没声明时没有这个字段。

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