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-limitedTesting Tips
- โขCheck X-RateLimit-Limit header
- โขCheck X-RateLimit-Remaining
- โขCheck X-RateLimit-Reset timestamp
// Playwright API Testing - RESTimport { 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