【问题标题】:Do GitHub CLI commnds use REST APIs of GitHub? Is there any rate limit for using the commands?GitHub CLI 命令是否使用 GitHub 的 REST API?使用命令有没有速率限制?
【发布时间】:2023-01-18 13:37:00
【问题描述】:
我正在使用 GitHub CLI 工具从我的本地存储库获取一些拉取请求信息。主要使用来自-https://cli.github.com/的以下命令
gh pr list
gh pr view
但有时我会得到 - graphql error: 'API rate limit exceeded'。有没有人知道 CLI 速率限制?我无法从他们的 CLI 文档中找到任何内容。
【问题讨论】:
标签:
github
command-line
github-api
rate-limiting
github-cli
【解决方案1】:
CLI 使用 REST 和 GraphQL API。速率限制取决于您使用的帐户类型以及您是否已登录。
经过身份验证后,graphql 速率限制为 5000。
You can check all the rate limits 用于您的帐户/当前 gh 登录,通过查询 https://api.github.com/rate_limit
- 首先检查
~/.config/gh/hosts.yml中的gh令牌
- 通过例如查询 api
curl -H "Authorization: Bearer <your token>" -H "Accept: application/vnd.github.v3+json" https://api.github.com/rate_limit
您将看到所有限制和当前使用情况。