← API Security learning path
API Security · Module 5 of 8

Rate limiting and abuse protection

Keep one client from harming everyone.

📖 Key ideas

  1. Rate limits cap requests per user, API key or IP address in a time window.
  2. Return HTTP 429 Too Many Requests with a Retry-After header when the limit is hit.
  3. Apply stricter limits to sensitive actions: login, OTP, password reset and payments.
  4. Protect expensive operations, such as reports and exports, with quotas and queues.
  5. Monitor unusual patterns, such as many failed logins or one key calling every record in order.
💡 Real-life example: Rate limiting is like an ATM's daily withdrawal limit: normal customers never notice it, but a thief with a stolen card cannot empty the account in one go.
Rate limitMaximum requests allowed in a time window
HTTP 429Response meaning too many requests
QuotaAllowance of usage over a longer period
Retry-AfterHeader telling the client when to try again