Blog
Operations7 min read

Stop Bleeding Money to Bots: A SaaS Founder's Guide to API Cost Control

Bot traffic is silently tanking your API budget and poisoning your metrics. Here's how to filter bots without destroying your user experience or installing surveillance tools.

You're staring at your API bill, coffee growing cold, wondering why it jumped 40% overnight. Then you check the logs. Bots. Everywhere. Half your traffic isn't real users—it's automated crawlers, scrapers, and opportunistic scripts hammering your endpoints. The worst part? Your metrics look great on the surface. Your signup numbers. Your request volumes. All lies.

This isn't just a cost problem. It's a decision-making problem. You're optimizing for fake users. You're shipping features nobody asked for. You're burning cash on infrastructure that serves robots.

The standard solutions feel invasive or broken. Cloudflare works but costs extra. CAPTCHA ruins your conversion rate. IP blacklists are whack-a-mole. You need something that actually stops bots without turning your app into Fort Knox.

Here's the real approach.

Detect Bots By Behavior, Not Identity

Forget trying to catch bots by IP address or device fingerprinting. Real bots often spoof both. Instead, look at what they do.

Bots have patterns humans don't:

  • Request timing: They hit endpoints in perfect intervals—0.1 second gaps, zero variance. Real users are chaotic.
  • User-Agent strings: "Mozilla/5.0" from 500 different IPs in 10 minutes? Bot. Legitimate crawlers (Googlebot, etc.) have identifiable patterns.
  • Route sequences: Real users browse. Bots hit the same endpoint hundreds of times in minutes.
  • Payload patterns: Same request body repeated verbatim? Bot. Real users type, edit, delete, change their minds.

Start logging these signals. You don't need fancy tools yet—just structured JSON logs with timestamps, endpoints, user-agents, request bodies, and IPs. Run them through simple pattern matching.

If a single IP hammers your /api/search endpoint 500 times in 60 seconds with identical queries, that's a bot. Block it.

Implement Graduated Friction, Not Walls

Here's where most solutions fail: they're binary. Either bots get through or real users hit friction.

Instead, use graduated friction. Increase the cost of requests for suspicious behavior—but only enough to slow bots, not break humans.

  • First offense: Rate limit to 10 req/sec (still plenty for humans, painful for bots).
  • Second offense: Require a request signature (a timestamp + HMAC hash in headers). Bots usually don't bother.
  • Third offense: Soft CAPTCHA—a math problem or puzzle that's annoying but not impossible. Most bots give up here.
  • Fourth offense: Hard block or IP ban.

The key: you're making bots work harder, not making legitimate users jump through hoops. A real user won't notice rate limits or request signatures. A bot that only works on unprotected endpoints will move on.

Deploy Pattern Detection at the Edge

You don't need a third-party service (though tools like Cloudflare or Imperva exist if you have budget). You can build basic bot detection with middleware.

If you use Node.js, Express middleware. If Python, a Flask decorator. If you're on a serverless platform, a handler function.

The middleware should:

  • Track request counts per IP per minute
  • Log user-agent, request body, and endpoint
  • Flag requests matching bot patterns
  • Return a 429 (Too Many Requests) or 403 (Forbidden) depending on severity
  • Never return sensitive error messages—bots learn from those

Keep a hot list of flagged IPs in memory (or Redis if you're distributed). Check it before processing requests. Purge old entries hourly.

This takes a day to build. It'll catch 70% of bot traffic immediately.

Correlate Metrics With Bot Filtering

Once you're filtering, measure what changes.

Compare your metrics before and after bot filtering:

  • API costs should drop noticeably
  • Signup quality should improve (fewer fake accounts)
  • Conversion rates might look worse (you're losing fake signups) but actually better (real users are more valuable)
  • Customer LTV should stabilize (less noise)

If your costs drop 40% but signups also drop 35%, that's a win. You were bleeding money serving robots.

Track this religiously. It's your proof that the filtering works and justifies the engineering effort.

Next Steps

Start today: Audit your logs for bot patterns. Spend 2 hours analyzing request timing, user-agents, and request sequences. Document what you find. Then build one middleware function to rate-limit the most obvious offenders.

You'll likely cut bot traffic by half with a single day of work. The rest is iteration.

Your metrics will finally mean something. Your costs will finally match your actual users. And you'll stop shipping for ghosts.

Ready to find your next SaaS idea?

20 pain points free — no credit card required.

Start for free →
Back to all posts
© 2026 findmeidea · Privacy · Terms