Search code examples
githubcommand-linegithub-apirate-limitinggithub-cli

Do GitHub CLI commnds use REST APIs of GitHub? Is there any rate limit for using the commands?


I am using the GitHub CLI tool to get some pull-request information from my local repository. Mainly using the following commands from - https://cli.github.com/

gh pr list
gh pr view

But sometimes I get - graphql error: 'API rate limit exceeded'. Is there anyone who knows about the CLI rate limit? I could not find anything from their CLI documentation.


Solution

  • The CLI uses the REST as well as the GraphQL API. The rate limit depends on the kind of account you're using and whether you're signed in.

    The graphql rate limit is 5000 when authenticated.

    You can check all the rate limits for your account/current gh login, by querying https://api.github.com/rate_limit

    1. First check your gh token in ~/.config/gh/hosts.yml
    2. Query the api by e.g. curl -H "Authorization: Bearer <your token>" -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/rate_limit

    And you will see all the limits and current usage.