Skip to main content
REST API

Rate Limit Headers

RetryRequestValidateMedium

What you will learn

  • Know the algorithm (token bucket, sliding window, fixed window) โ€” bypasses differ per type
  • Test with distributed clients โ€” per-IP limits are trivial to bypass behind a proxy
  • Verify limits reset at the documented time โ€” clock skew between servers breaks limits

Description

Parse and respect rate limit headers in responses.

Test Scenario

const response = await request.get('/api/v1/rate-limited');
const limit = response.headers()['x-ratelimit-limit'];
const remaining = response.headers()['x-ratelimit-remaining'];
console.log(`${remaining}/${limit} requests remaining`);
Endpoint/api/v1/rate-limited

Testing Tips

  • โ€ขCheck X-RateLimit-Limit header
  • โ€ขCheck X-RateLimit-Remaining
  • โ€ขCheck X-RateLimit-Reset timestamp
// Playwright API Testing - REST
import { test, expect } from '@playwright/test';
test('REST API request', async ({ request }) => {
const response = await request.get('/api/v1/resource');
expect(response.ok()).toBeTruthy();
expect(response.status()).toBe(200);
const data = await response.json();
expect(data).toBeDefined();
});

Challenge ID: rest-rate-limiting

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/v1/rate-limited

Press Enter to send