Skip to content
secondsky avatar

Api Rate Limiting

Practical rate limiting that compares token bucket, sliding window, and fixed window approaches for protecting public APIs.

CCM score
54 of 100
skills.sh installs
517
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers three algorithms in a comparison table, plus Node.js token bucket and Express middleware examples
  • Includes standard X-RateLimit-* and Retry-After response headers, and tiered limits for Free, Pro, and Enterprise plans
  • Enforces 429 responses with a Retry-After value and recommends Redis for distributed limits across instances
  • Designed for teams securing public APIs, implementing tiered access, or defending against denial-of-service abuse

Install

$ npx -y skills add secondsky/claude-skills --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

Protect APIs from abuse using rate limiting algorithms with per-user and per-endpoint strategies.

Algorithms

AlgorithmProsCons
Token BucketHandles bursts, smoothMemory per user
Sliding WindowAccurateMemory intensive
Fixed WindowSimpleBoundary spikes

Token Bucket (Node.js)

class TokenBucket {
  constructor(capacity, refillRate) {
    this.capacity = capacity;
    this.tokens = capacity;
    this.refillRate = refillRate; // tokens per second
    this.lastRefill = Date.now();
  }

  consume() {
    this.refill();
    if (this.tokens >= 1) {
      this.tokens--;
      return true;
    }
    return false;
  }

  refill() {
    const now = Date.now();
    const elapsed = (now - this.lastRefill) / 1000;
    this.tokens = Math.min(this.capacity, this.tokens + elapsed * this.refillRate);
    this.lastRefill = now;
  }
}

Express Middleware

const rateLimit = require('express-rate-limit');

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 100,
  standardHeaders: true,
  message: { error: 'Too many requests, try again later' }
});

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, DevOps & Cloud, Security
First seen
Jun 3, 2026

Questions

What does the api-rate-limiting skill do?

The api-rate-limiting skill implements API rate limiting with token bucket, sliding window and Redis-based algorithms to protect against abuse. It supports per-user and per-endpoint strategies, tiered access limits and proper 429 responses with Retry-After headers.

How do I install the api-rate-limiting skill?

Run npx -y skills add secondsky/claude-skills --skill api-rate-limiting -y in your project to install it. Once installed, the api-rate-limiting skill lets your agent add rate limiting to public APIs and prevent denial-of-service attacks.

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

The api-rate-limiting skill covers token bucket, sliding window and fixed window approaches, and compares their trade-offs for bursts, accuracy and memory use. It includes a Node.js token bucket class and an Express middleware example built on express-rate-limit.

Who should use the api-rate-limiting skill?

The api-rate-limiting skill suits developers securing public APIs or offering tiered access to different plans. It also helps teams who want to monitor rate limit metrics and test their APIs under load.

More from secondsky/claude-skills

All 116

Similar to Api Rate Limiting

More Backend & APIs