Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
aj-geddes avatar

Api Rate Limiting

  • 579 installs
  • 305 repo stars
  • Updated March 4, 2026
  • aj-geddes/useful-ai-prompts

api-rate-limiting is a backend skill that teaches token bucket, sliding window, and fixed window rate limiting patterns for developers who need to protect APIs from abuse and manage traffic spikes.

About

api-rate-limiting is a Claude Code skill from aj-geddes/useful-ai-prompts that walks developers through implementing API rate limiting with three core algorithms: token bucket, sliding window, and fixed window. The skill covers per-user, per-IP, and per-endpoint strategies plus quick-start setup, reference guides, and best practices for tiered limits. Developers reach for api-rate-limiting when hardening REST or GraphQL endpoints against brute-force attacks, smoothing traffic spikes, or enforcing plan-based quotas before launch. The guidance is algorithm-focused rather than framework-specific, so teams can map patterns onto Express, FastAPI, NestJS, or gateway middleware. Use it during backend build when abuse protection is required but a full API gateway product is not yet in place.

  • Implements token bucket, sliding window, and fixed window algorithms
  • Supports per-user, per-IP, and per-endpoint rate limiting strategies
  • Protects against brute force attacks, traffic spikes, and DoS attempts
  • Enables tiered service plans and quota enforcement
  • Includes JavaScript token bucket class with refill and consume methods

Api Rate Limiting by the numbers

  • 579 all-time installs (skills.sh)
  • Ranked #710 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill api-rate-limiting

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs579
repo stars305
Last updatedMarch 4, 2026
Repositoryaj-geddes/useful-ai-prompts

How do you implement API rate limiting algorithms?

Add robust rate limiting to their APIs using token bucket, sliding window, or fixed window algorithms.

Who is it for?

Backend developers adding abuse protection and tiered quotas to HTTP APIs during initial backend build.

Skip if: Teams that already operate a managed API gateway with built-in rate limiting and only need dashboard tuning.

When should I use this skill?

A developer asks to add rate limiting, throttle API traffic, or implement token bucket or sliding window limits.

What you get

Rate-limiting middleware design, algorithm choice notes, and per-scope limit configuration for production APIs.

  • Rate-limit middleware design
  • Per-scope limit configuration

By the numbers

  • Documents 3 rate-limiting algorithms: token bucket, sliding window, and fixed window
  • Covers 3 limit scopes: per-user, per-IP, and per-endpoint

Files

SKILL.mdMarkdownGitHub ↗

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();

    if (this.tokens >= tokens) {
      this.tokens -= tokens;
      return true;
    }
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Token Bucket AlgorithmToken Bucket Algorithm
Sliding Window AlgorithmSliding Window Algorithm
Redis-Based Rate LimitingRedis-Based Rate Limiting
Tiered Rate LimitingTiered Rate Limiting
Python Rate Limiting (Flask)Python Rate Limiting (Flask)
Response HeadersResponse Headers

Best Practices

✅ DO

  • Include rate limit headers in responses
  • Use Redis for distributed rate limiting
  • Implement tiered limits for different user plans
  • Set appropriate window sizes and limits
  • Monitor rate limit metrics
  • Provide clear retry guidance
  • Document rate limits in API docs
  • Test under high load

❌ DON'T

  • Use in-memory storage in production
  • Set limits too restrictively
  • Forget to include Retry-After header
  • Ignore distributed scenarios
  • Make rate limits public (security)
  • Use simple counters for distributed systems
  • Forget cleanup of old data

Related skills

How it compares

Pick api-rate-limiting when you need algorithm-level design guidance inside your own API codebase rather than outsourcing limits to a cloud WAF alone.

FAQ

Which rate limiting algorithms does api-rate-limiting cover?

api-rate-limiting documents three algorithms: token bucket, sliding window, and fixed window. The skill explains when each fits traffic bursts, steady quotas, or simple time windows on HTTP APIs.

What scopes can API rate limits use?

api-rate-limiting describes per-user, per-IP, and per-endpoint rate limit scopes. Developers can combine scopes to block brute-force login attempts while preserving fair usage on public read endpoints.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.