Social card titled Check Your GitHub API Rate Limits, a DevOps tip on reading your limits from the rate_limit endpoint

Github Rate limits

—

by

in

Read Time

1–2 minutes

Rate limits are sometimes scary. Sometimes its temporary, some time it goes away soon…some time it takes like foreverrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

I got rate limited by github by using its gh cli inside github actions. Well i didnt spam it but i was using more of it in a very less amount of time. Ran the action almost 200 times a day and the amount of action it did inside that 200 run each time is huge considering what i was doing (Was testing and developing a tool to run with github a actions)

Would have been nice for a test environment if github was providing one but sadly they dont…..

Also i was using my own (The company’s self hosted github actions server)

And finally i got blocked and rate limited heavily.

I was curious to find out what my limits are for these actions and i found this out

Flow: heavy gh CLI use in GitHub Actions triggers a rate limit, then a curl call to the rate_limit endpoint shows your current limits
Some limits reset per minute, some per hour and some per day.

curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-GITHUB-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/rate_limit

More info here https://docs.github.com/en/rest/rate-limit/rate-limit?apiVersion=2022-11-28

And when you run the above code you shall be able to see and know you rate limits.

Some limits are for per minute and per hour and per day basis so be careful when exhausting them

You should get something like this as out for that code

Sample JSON output from the GitHub rate_limit API showing each limit, requests used and requests remaining