npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

baileys-antiban-evolution

v0.1.0

Published

Anti-ban protection adapter for Evolution API - brings baileys-antiban's rate limiting and session stability to Evolution

Readme

baileys-antiban-evolution

Anti-ban protection for Evolution API — brings baileys-antiban's rate limiting, warmup, and session stability to Evolution API users.

Evolution API (8k⭐, 3.7M downloads/month via n8n) wraps Baileys with a REST API but ships zero anti-ban protection. Users report constant bans (#2228, #1870, #2437). This adapter fixes that.

No fork, no PR upstream. Just install, apply at startup, done.


Quick Install (Docker / n8n Users)

Add 5 lines to your docker-compose.yml:

services:
  evolution-api:
    image: atendai/evolution-api:latest
    command: >
      sh -c "
        npm install --no-save baileys-antiban baileys-antiban-evolution &&
        node --require baileys-antiban-evolution/dist/index.js dist/main.js
      "
    environment:
      - ANTIBAN_PRESET=conservative  # Add this line
      # ... your existing Evolution env vars

Before: Sessions banned in 24-48 hours after bulk operations.
After: Sessions survive weeks with transparent rate limiting.


Advanced Usage (Developers)

Installation

npm install baileys-antiban-evolution baileys-antiban

Apply at Startup

Add this to your Evolution API startup script before Evolution boots:

import { applyAntibanToEvolution } from 'baileys-antiban-evolution';
import { AntiBan } from 'baileys-antiban';

const antiban = new AntiBan({
  preset: 'conservative', // or 'moderate' | 'aggressive'
});

await applyAntibanToEvolution(antiban);

// Now start Evolution normally

Full example: examples/nodejs-startup.ts

Configuration

await applyAntibanToEvolution(antiban, {
  guardSendMessage: true,          // Rate-limit sendMessage()
  guardSendMessageWithTyping: true, // Rate-limit sendMessageWithTyping()
  guardTextMessage: true,           // Rate-limit textMessage()
  logger: console,                  // Optional: custom logger
});

Presets:

  • conservative: 2 msg/sec, 7-day warmup (safest)
  • moderate: 5 msg/sec, 5-day warmup
  • aggressive: 10 msg/sec, 3-day warmup (higher risk)

Tune via env vars:

ANTIBAN_PRESET=conservative
ANTIBAN_MAX_QPS=2
ANTIBAN_WARMUP_DAYS=7

Full config: examples/env-config.example.env


What It Does

  1. Rate limiting: Enforces configurable QPS (queries per second) with Gaussian jitter on all outbound sends
  2. Warmup phase: Scales rate limits for new sessions over 3-7 days (mimics human behavior)
  3. Session health monitoring: Catches HKDF key drift before Bad MAC bans occur
  4. Device fingerprint randomization: Varies clientPayload per session to avoid detection

Why This Fixes Evolution Issues

Issue #2228 — Bulk Number Checking Bans

"Lacks rate limiting... banned after checking 50 numbers"

Fixed: Rate limiter enforces 2-10 msg/sec ceiling with jitter. No more hammering WhatsApp's servers.

Issue #1870 — Constant Banning

"Warmup itself triggers bans"

Fixed: 7-day warmup phase starts at 0.2 msg/sec, gradually scales to full rate. New sessions behave like real users.

Issue #2437 — QR/Pairing Failures

"Session dies after 24h"

Fixed: Session health monitor detects HKDF drift (Bad MAC precursor) and triggers proactive reconnect.


Performance Impact

Honest: Adds ~50-200ms latency per send (configurable via jitterMs).

Worth it: Bans cost weeks of recovery. 200ms is negligible vs. losing access.

For high-throughput use cases, use aggressive preset (10 msg/sec) or disable specific guards:

await applyAntibanToEvolution(antiban, {
  guardSendMessage: true,
  guardSendMessageWithTyping: false, // Skip typing guard if you don't use it
  guardTextMessage: false,
});

Limitations

  1. Evolution version compatibility: Designed for Evolution v2.x (tested against v2.3.7). Class shape verified live against main on 2026-04-26. Re-test on major version bumps.
  2. Method coverage in v0.1: We rate-limit textMessage, sendMessage, sendMessageWithTyping, and connectToWhatsapp. Evolution exposes ~12 public REST message methods total — mediaMessage, audioWhatsapp, pollMessage, contactMessage, locationMessage, etc. are NOT yet rate-limited in this release. Most ban risk is text-bulk-sending which textMessage covers, but if your workflow is media-heavy, wait for v0.2 or open an issue.
  3. Not a silver bullet: WhatsApp's ban detection evolves. This reduces risk but doesn't guarantee immunity.
  4. Monkey-patching: Wraps Evolution's internal methods at runtime. If Evolution changes class structure, adapter may need updates.

Examples


How It Works

Uses monkey-patching to wrap Evolution's WhatsAppBaileysService class at runtime:

  1. connectToWhatsapp() — Wraps socket creation, applies session health monitoring
  2. sendMessage() — Enforces rate limit before delegating to original
  3. sendMessageWithTyping() — Same rate limit enforcement
  4. textMessage() — Same rate limit enforcement

If rate limit exceeded, throws HTTP 429 error:

{
  "statusCode": 429,
  "error": "Too Many Requests",
  "message": "Rate limit exceeded. Anti-ban protection active. Retry after 5s"
}

REST clients (n8n, Make, etc.) handle 429s gracefully with exponential backoff.


License

MIT — same as baileys-antiban and Evolution API.


Credits

Built by Hannes (Kobus) Wentzel.

Pairs with:


Roadmap

  • [ ] Auto-detect Evolution version, log compatibility warning
  • [ ] Support for Evolution v3.x (when released)
  • [ ] Metrics endpoint (/antiban/stats) for monitoring rate limit usage
  • [ ] Webhooks for ban warnings (session health degradation alerts)

Contributions welcome. Issues/PRs to GitHub.