REST 分域端点速查(github-api-reference)
依据 GitHub REST API(X-GitHub-Api-Version: 2026-03-10,当前最新版;不带头默认 2022-11-28)。路径中
{o}=owner、{r}=repo、{n}=number/id。 公开文档:https://docs.github.com/rest 。不确定字段一律回查官方文档。
Issues & Pull Requests
| 端点 | 方法 | 关键点 |
| — | — | — |
| repos/{o}/{r}/issues | GET/POST | 列表查询 state/labels/sort/direction/since/per_page/page;POST body {title, body, labels[], assignees[]} |
| repos/{o}/{r}/issues/{n} | GET/PATCH | PATCH 可改 title/body/state/labels/assignees/milestone |
| repos/{o}/{r}/issues/{n}/comments | GET/POST | issue 评论 |
| repos/{o}/{r}/pulls | GET/POST | 列表 state/base/head;POST 需 head、base,可选 title/body |
| repos/{o}/{r}/pulls/{n} | GET/PATCH | PATCH 合并请求字段 |
| repos/{o}/{r}/pulls/{n}/reviews | GET/POST | POST {event: APPROVE/REQUEST_CHANGES/COMMENT, body} |
| repos/{o}/{r}/pulls/{n}/merge | PUT | 合并参数 commit_title/commit_message/merge_method/sha |
| search/issues?q=... | GET | q=repo:o/r + 条件;sort/order/per_page |
Repos & Contents
| 端点 | 方法 | 关键点 |
| — | — | — |
| repos/{o}/{r} | GET/PATCH | 仓库信息/设置(可改 default_branch/description/visibility…)|
| repos/{o}/{r}/contents/{path} | GET | 默认返回 base64 JSON;Accept: application/vnd.github.raw+json 得原文 |
| repos/{o}/{r}/contents/{path} | PUT | 新建/更新:body {message, content(base64), branch?, sha?(更新必需)} |
| repos/{o}/{r}/contents/{path} | DELETE | 删除文件:body {message, sha, branch?} |
| repos/{o}/{r}/commits | GET | 提交历史 sha/path/since/until/per_page |
| repos/{o}/{r}/compare/{base}...{head} | GET | 比较两 ref 差异 |
| repos/{o}/{r}/branches / /branches/{b} | GET | 分支;分支保护走 /branches/{b}/protection |
| repos/{o}/{r}/collaborators | GET | 协作者列表 |
| repos/{o}/{r}/collaborators/{username} | GET/PUT/DELETE | 单个协作者(PUT 需 permission) |
Releases & Tags
| 端点 | 方法 | 关键点 |
| — | — | — |
| repos/{o}/{r}/releases | GET/POST | POST body {tag_name, target_commitish, name?, body?, draft?, prerelease?} |
| repos/{o}/{r}/releases/{id} | GET/PATCH/DELETE | PATCH 改字段;DELETE 删除 release(不可逆,先确认) |
| repos/{o}/{r}/releases/{id}/assets | GET/POST | POST 上传二进制:Content-Type 按文件类型或 application/octet-stream,query ?name= 必填 |
| repos/{o}/{r}/git/refs | GET/POST | 列/建引用(列可用 ?ref= 过滤,如 refs/heads) |
| repos/{o}/{r}/git/refs/{ref} | GET/PATCH/DELETE | 单个引用({ref} 如 heads/main、tags/v1) |
| repos/{o}/{r}/git/matching-refs/{ref} | GET | 匹配前缀的引用列表 |
Actions / Workflows
| 端点 | 方法 | 关键点 |
| — | — | — |
| repos/{o}/{r}/actions/workflows | GET | 列 workflow |
| repos/{o}/{r}/actions/workflows/{id}/dispatches | POST | 触发 workflow_dispatch:{ref, inputs?}(需 workflow 有 workflow_dispatch 触发) |
| repos/{o}/{r}/actions/runs | GET | 列运行 branch/event/status |
| repos/{o}/{r}/actions/runs/{id} | GET | 单次运行详情 |
| repos/{o}/{r}/actions/runs/{id}/jobs | GET | 该运行的任务 |
| repos/{o}/{r}/actions/runs/{id}/rerun | POST | 重跑;仅重跑失败任务用 /actions/runs/{id}/rerun-failed-jobs |
| repos/{o}/{r}/actions/artifacts | GET | 列构件 |
| repos/{o}/{r}/actions/secrets | GET | 列 secret |
| repos/{o}/{r}/actions/secrets/{name} | GET/PUT/DELETE | 单个 secret(PUT body {encrypted_value, key_id};覆盖会不可逆) |
Users / Orgs / Misc
| 端点 | 方法 | 关键点 |
| — | — | — |
| user | GET | 当前认证用户 |
| users/{u}/repos | GET | 用户仓库列表 |
| orgs/{o}/repos | GET/POST | 组织仓库 |
| orgs/{o}/teams | GET | 组织团队 |
| gists | GET/POST | 当前用户的 gists(列表/创建) |
| users/{u}/gists | GET | 某用户的 gists |
| rate_limit | GET | 查各类配额(resources.*;旧 rate 字段已弃用) |
| meta | GET | 元信息(Git/Web 地址、SSH 指纹、IP 段等) |
通用注意
- 写操作 body 一律 JSON;
updated类字段不必传。 - 文件/路径含特殊字符要 percent-encode。
- 大列表用分页(per_page/page 或 Link)。
- 对未知端点先查官方文档确认参数与返回,别猜。