Skip to content

Reusable API rate limiting guide covering token bucket, sliding window, and fixed window algorithms with tiered limits.

CCM score
41 of 100
skills.sh installs
649
GitHub stars
396
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers per-user, per-IP, and per-endpoint limiting strategies for protecting APIs from brute force attacks and traffic spikes
  • Includes reference guides for token bucket, sliding window, Redis-based, tiered, and Flask implementations, plus response headers
  • Recommends rate limit headers and a Retry-After value on every throttled response, with Redis for distributed deployments
  • Warns against in-memory storage in production, simple counters across distributed systems, and exposing limit configuration publicly

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill api-rate-limiting -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

API Rate Limiting

Table of Contents

Overview

Protect APIs from abuse and manage traffic using various rate limiting algorithms with per-user, per-IP, and per-endpoint strategies.

When to Use

  • Protecting APIs from brute force attacks
  • Managing traffic spikes
  • Implementing tiered service plans
  • Preventing DoS attacks
  • Fairness in resource allocation
  • Enforcing quotas and usage limits

Quick Start

Minimal working example:

// Token Bucket Rate Limiter
class TokenBucket {
  constructor(capacity, refillRate) {
    this.capacity = capacity;
    this.tokens = capacity;
    this.refillRate = refillRate; // tokens per second
    this.lastRefillTime = Date.now();
  }

  refill() {
    const now = Date.now();
    const timePassed = (now - this.lastRefillTime) / 1000;
    const tokensToAdd = timePassed * this.refillRate;

    this.tokens = Math.min(this.capacity, this.tokens + tokensToAdd);
    this.lastRefillTime = now;
  }

  consume(tokens = 1) {
    this.refill();

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Backend & APIs, Security
First seen
Jun 3, 2026

More from aj-geddes/useful-ai-prompts

All 258

Similar to Api Rate Limiting

More Backend & APIs