api-rate-limiting

Implement API rate limiting with token bucket, sliding window, and Redis-based algorithms.

Updated Jul 9, 2026
One-click install
npx skills add https://github.com/octanutri-clin/octaclin --skill api-rate-limiting-octanutri-clin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-rate-limiting
Source: https://github.com/octanutri-clin/octaclin/tree/main/.agents/skills/api-rate-limiting
Command: npx skills add https://github.com/octanutri-clin/octaclin --skill api-rate-limiting-octanutri-clin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires redis, express, flask, flask-limiter, and includes references (resource) components.

What problem does it solve? APIs without rate limiting are vulnerable to brute force attacks, traffic spikes, and resource abuse. This Skill provides ready-to-use implementations of proven rate limiting algorithms so you can protect endpoints and enforce usage quotas without designing the logic from scratch. ## Core Features & Use Cases - Multiple Algorithms: Token bucket, sliding window, and fixed window implementations in JavaScript and Python (Flask). - Distributed Rate Limiting: Redis-based sliding window for multi-instance deployments with proper headers and 429 responses. - Tiered Plans: Per-plan limits (free, pro, enterprise) with upgrade prompts when limits are exceeded. - Use Case: Add a Redis sliding window middleware to your Express API so each user gets 100 requests per hour, with X-RateLimit headers and Retry-After responses on 429 errors. ## Quick Start Ask the AI to add token bucket rate limiting middleware to your Express API endpoint with a limit of 100 requests per minute per user.

Frequently Asked Questions about api-rate-limiting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add rate limiting to an Express API?

Use middleware that tracks requests per user or IP with token bucket or sliding window logic. The Skill provides Express middleware examples that set X-RateLimit-Limit and X-RateLimit-Remaining headers and return 429 when limits are exceeded.

Token bucket vs sliding window rate limiting, which should I use?

Token bucket allows controlled bursts by refilling tokens at a steady rate, while sliding window enforces a strict request count over a moving time window. Choose token bucket for burst tolerance and sliding window for precise quota enforcement.

How do I implement rate limiting with Redis for distributed systems?

Use Redis sorted sets to store request timestamps per key, removing entries outside the window with zremrangebyscore and counting with zcard. This keeps limits consistent across multiple server instances, unlike in-memory storage.

How do I set different rate limits per user plan?

Define a limits map per plan tier, look up the user's plan, and apply the corresponding request count and window. The tiered example returns an upgrade URL in the 429 response when free-tier users exceed their quota.

Why should I avoid in-memory rate limiting in production?

In-memory limiters reset on restart and do not share state across instances, so limits are inconsistent in load-balanced deployments. Use Redis-backed storage for production and include Retry-After headers so clients know when to retry.