GitHub
以编程方式使用 GitHub 仓库、代码和用户信息
- 认证方式
- OAuth
- HTTPS
- Yes
- CORS
- Yes
- 分类
- 开发
简介
GitHub REST API 开放 GitHub 上几乎所有能力——仓库、Issue、PR、提交、用户、组织、Actions、发布等。公开数据的匿名访问可用(实测:60 次请求/小时);OAuth 或个人访问令牌可提高配额并解锁私有数据。
快速开始
公开仓库——无需认证(实测可用):
curl "https://api.github.com/repos/octocat/Hello-World"
用户资料:
curl "https://api.github.com/users/octocat"
搜索仓库:
curl "https://api.github.com/search/repositories?q=astro+language:javascript&sort=stars"
仓库内容:
curl "https://api.github.com/repos/octocat/Hello-World/contents/"
带令牌(认证后 5,000 次/小时):
curl "https://api.github.com/repos/octocat/Hello-World" \
-H "Authorization: Bearer YOUR_TOKEN"
认证方式
- 匿名:公开数据,60 次请求/小时(实测可用)。
- 个人访问令牌(GitHub → Settings → Developer settings):5,000 次/小时,可访问私有仓库。
- OAuth:代表用户操作(Issue、gist、仓库写入)——列表的 OAuth 标记即指此。
- GraphQL API 也在
https://api.github.com/graphql。
速率限制与注意事项
- 限流头在响应中返回(
X-RateLimit-Remaining、X-RateLimit-Reset)。 - 404 可能意味着“私有或不存在”——API 刻意隐藏存在性。
- 通过
Link头或?page=N&per_page=100(最大 100)分页。 - 设置描述性的
User-Agent——GitHub 强制要求。
常见问题
GitHub API 免费吗? 是的——公开数据免费;匿名 60 次/小时,免费令牌 5,000 次/小时。
需要 OAuth 吗? 只有用户级操作需要——读取匿名或带令牌即可。
如何避免限流? 用令牌认证并缓存响应。
开发 分类更多
| API | Auth | HTTPS | CORS | |
|---|---|---|---|---|
| 24 Pull Requests Project to promote open source collaboration during December | No auth | Yes | Yes | ↗ |
| Agify.io Estimates the age from a first name | No auth | Yes | Yes | ↗ |
| Amazonscraperapi Amazon product, search & batch scraping API with residential proxies (1000 free) | API Key | Yes | No | ↗ |
| AmberOne Turn any website into a build-ready Android, iOS, PWA or Electron app project | API Key | Yes | No | ↗ |
| API Grátis Multiples services and public APIs | No auth | Yes | Unknown | ↗ |