"Busting GitHub's Secondary Rate Limit: Too Many Requests"

Ever found yourself in a situation where GitHub suddenly starts returning "Too Many Requests" errors, and you're left wondering what the "secondary rate limit" is all about? You're not alone. In this article, we'll delve into the world of GitHub's rate limits, focusing on the secondary rate limit that trips up many developers. We'll explain what it is, why it exists, and most importantly, how to avoid hitting it.

Understanding GitHub's Rate Limits

Before we dive into the secondary rate limit, let's first understand GitHub's rate limits in general. GitHub uses rate limits to prevent abuse and ensure fair usage of their API. Every authenticated client (including GitHub Apps, OAuth Apps, and personal access tokens) has a rate limit of 5000 requests per hour.

When you exceed this limit, GitHub responds with a "403 Forbidden" status code and a "Too Many Requests" message. However, this is where things get interesting. GitHub has a secondary rate limit that kicks in when you've made too many requests in a short period, even if you haven't hit the hourly limit.

Reverting Commits in GitHub: Undo Changes the Right Way
Reverting Commits in GitHub: Undo Changes the Right Way

What is the Secondary Rate Limit?

The secondary rate limit is a more aggressive limit that's designed to prevent abuse and ensure fair usage of the API. It's not well-documented, but it's estimated to be around 1000 requests per hour. When you hit this limit, you'll also receive a "403 Forbidden" status code, but the message will be "Too Many Requests - Secondary Rate Limit Exceeded".

Here's a simple way to remember it: The primary rate limit is 5000 requests per hour, and the secondary rate limit is a stricter limit that applies when you're making too many requests too quickly.

Why Does the Secondary Rate Limit Exist?

The secondary rate limit is GitHub's way of preventing abuse and ensuring fair usage of their API. It's designed to stop users from making too many requests too quickly, which can lead to performance issues and resource exhaustion. For example, if a user were to repeatedly fetch the same data every second, they could quickly hit the primary rate limit and potentially overwhelm GitHub's servers.

Learn How to Contribute to Open Source
Learn How to Contribute to Open Source

By implementing a secondary rate limit, GitHub can discourage this kind of behavior and ensure that their API remains performant and available for all users.

How to Avoid Hitting the Secondary Rate Limit

Now that we understand what the secondary rate limit is and why it exists, let's look at some strategies for avoiding it.

  • Cache Data Locally: Instead of making repeated requests for the same data, consider caching the data locally on your machine or in your application. This can significantly reduce the number of requests you make to GitHub's API.
  • Use Pagination: When fetching data, use GitHub's pagination features to retrieve data in smaller chunks. This can help you avoid making too many requests at once.
  • Throttle Your Requests: Implement a delay between your API requests to ensure you're not making too many requests too quickly. This can be as simple as using a `sleep` function in your code.
  • Use GitHub's REST API Documentation: GitHub's REST API documentation provides guidance on rate limits and best practices for using their API. Make sure to read and follow these guidelines.

What to Do When You Hit the Secondary Rate Limit

If you find yourself hitting the secondary rate limit, don't panic. Here are some steps you can take:

Don't Miss a Beat: Why Reliable GitHub Notifications Are Key to Development Analytics
Don't Miss a Beat: Why Reliable GitHub Notifications Are Key to Development Analytics

  • Check your code to ensure you're not making too many requests too quickly.
  • Implement caching, pagination, and throttling as needed.
  • Consider using GitHub's GraphQL API, which has a higher rate limit and can reduce the number of requests you need to make.
  • If you're still having trouble, consider reaching out to GitHub's support team for further assistance.

Conclusion

The secondary rate limit is a crucial part of GitHub's API usage policies. Understanding what it is, why it exists, and how to avoid it can help you make the most of GitHub's API without running into unexpected rate limit errors. By following best practices and being mindful of your API usage, you can ensure that you're using GitHub's API in a fair and responsible way.

an ad for the 5 github reppos that dropped this week
an ad for the 5 github reppos that dropped this week
How to setup rate limit on Nginx
How to setup rate limit on Nginx
an image of a computer screen with the text public apis, a collective list of free apis
an image of a computer screen with the text public apis, a collective list of free apis
GitHub - dec0dOS/amazing-github-template: 🚀 Useful README.md, LICENSE, CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md, GitHub Issues, Pull Requests and Actions templates to jumpstart your projects.
GitHub - dec0dOS/amazing-github-template: 🚀 Useful README.md, LICENSE, CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md, GitHub Issues, Pull Requests and Actions templates to jumpstart your projects.
GitHub API: How to retrieve the combined pull request status from commit statuses, check runs, and GitHub Action results
GitHub API: How to retrieve the combined pull request status from commit statuses, check runs, and GitHub Action results
the github gist logo is shown in white on a black background with sound waves
the github gist logo is shown in white on a black background with sound waves
GitHub rolling out 2FA to millions of users | TechRepublic
GitHub rolling out 2FA to millions of users | TechRepublic
a text message that reads, git commit - m'idk why this works
a text message that reads, git commit - m'idk why this works
GitHub - ArchiveXVault/readme-generator: Generate readme for github repos
GitHub - ArchiveXVault/readme-generator: Generate readme for github repos
Top 10 Most Popular GitHub Repos for Developers in 2025 - GeeksforGeeks
Top 10 Most Popular GitHub Repos for Developers in 2025 - GeeksforGeeks
GitHub keeps breaking but nobody's leaving — this is why
GitHub keeps breaking but nobody's leaving — this is why
GitHub - rhysd/git-background: Execute git commands in background.
GitHub - rhysd/git-background: Execute git commands in background.
Why I deleted all my GitHub repos | ION HowTo
Why I deleted all my GitHub repos | ION HowTo
Turn off these GitHub features to grow your Repo
Turn off these GitHub features to grow your Repo
How to add a README to your GitHub profile
How to add a README to your GitHub profile
I wanted real time GitHub push notifications. So I built a Chrome extension.
I wanted real time GitHub push notifications. So I built a Chrome extension.
Turning GitHub Into A URL Shortening Service
Turning GitHub Into A URL Shortening Service
How to Add Screenshots and Animation to GitHub Pull Requests - Make Tech Easier
How to Add Screenshots and Animation to GitHub Pull Requests - Make Tech Easier
How to Handle GitHub Source and Version Control From Xcode
How to Handle GitHub Source and Version Control From Xcode
Git Push Command
Git Push Command
127.0.0.1
127.0.0.1
GitHub's new Agent HQ gives devs a command center for all their AI tools - why this is a huge deal
GitHub's new Agent HQ gives devs a command center for all their AI tools - why this is a huge deal
HTTP Status Codes Cheat Sheet: 200–503 Meanings + What to Do
HTTP Status Codes Cheat Sheet: 200–503 Meanings + What to Do