T

TechIdea

Ecosystem

← Back to Node.js Challenges
Node.jsAdvanced

Build an API Rate Limiter

Frequently asked in system design and senior backend interviews.

Problem Statement

Implement a sliding window rate limiter middleware in Express.js. It should allow a maximum of 5 requests per minute per IP address.

Real World Scenario:

Public APIs are constantly targeted by scrapers and malicious bots. Without a rate limiter, a single user can overwhelm your database and crash your servers.

Input / Output

Input: Incoming HTTP requests with an IP address.

Output: 429 Too Many Requests response if limit is exceeded, or next() if allowed.

Constraints

  • Use an in-memory store (like a Map or Redis).
  • Must implement the sliding window log algorithm.
  • Include appropriate rate limit headers.

Interactive Playground

Loading...
Console Output
Click "Run Code" to see the output here.

Need a hint?

Growth Newsletter

Get practical AI tools, SEO tips, and growth guides weekly.

Join creators, students, and businesses scaling with TechIdea.