Cloudflare Rate Limiting for APIs
Add rate limiting to your API with Cloudflare. No code changes—configure rules at the edge.
What this problem means
Your API needs rate limiting to prevent abuse. Cloudflare can enforce limits at the edge—before requests reach your origin. No code changes. Configure rules in the dashboard.
Why this matters
- Abuse prevention: Rate limiting slows down scrapers and attackers.
- Cost control: Fewer abusive requests = lower bills.
- No code changes: Cloudflare handles it at the edge.
Real-world example
A startup had a public API with no rate limits. A script was written to automate millions of requests. They added Cloudflare rate limiting—100 requests per minute per IP—in 15 minutes. Abuse dropped by 95%. No code deployment required.
How to fix it
1. Create a rate limiting rule: In Cloudflare, go to Security > WAF > Rate limiting rules.
2. Define the match: Match by URI path (e.g., /api/*) or hostname.
3. Set threshold: e.g., 100 requests per minute per IP.
4. Choose action: Block, challenge, or log. Block is most effective.
5. Test: Verify legitimate traffic still works.
Tools and configurations
- Cloudflare WAF: Rate limiting rules.
- Match conditions: URI path, hostname, country, etc.
- Actions: Block, challenge (CAPTCHA), or log.
- Bypass: Add exceptions for known good IPs (e.g., your office).
Common mistakes
- Setting limits too low (blocks legitimate users).
- Only limiting by IP (proxies bypass—but still helps).
- No monitoring—verify the rule is working.
Quick checklist
- [ ] Create rate limiting rule for /api/* or your API path
- [ ] Set threshold (e.g., 100 req/min per IP)
- [ ] Choose block action
- [ ] Add bypass for known good IPs if needed
- [ ] Test with legitimate traffic
Need help with production readiness? Get a free 30-minute audit.
Book Free 30-Min Production AuditCheck if your system has this risk
Take the 60-second production readiness assessment to identify gaps in your infrastructure.
Start AssessmentRelated guides
Frequently asked questions
- How do I add Cloudflare rate limiting to my API?
- Go to Security > WAF > Rate limiting rules. Create a rule that matches your API path. Set a threshold (e.g., 100 req/min per IP). Choose block or challenge action.
- Does Cloudflare rate limiting require code changes?
- No. Cloudflare enforces rate limiting at the edge. Configure rules in the dashboard. No deployment or code changes required.
- What rate limit should I use for an API?
- Start with 100-500 requests per minute per IP. Adjust based on typical usage. Too low blocks legitimate users; too high doesn't stop abuse.