← Back to Projects

SoapBar API

A fast, flexible profanity filter

Hono
Next.js
Redis
Upstash

SoapBar.dev

Source Code

Summary

Soapbar is a flexible and fast profanity filter API designed to keep your applications clean and safe. It leverages Redis and a vector database on Upstash for fast and scalable data processing. Built with Cloudflare Workers and Hono, SoapBar ensures low-latency, globally distributed performance. The accompanying web app is developed using Next.js. With SoapBar, you can seamlessly integrate a robust content moderation tool into your projects, ensuring a professional and family-friendly user experience.

Landing page of soapbar API

Tech Stack

API Details

There are three possible properties for the JSON object response:

isProfanity : Boolean
score : Number
flaggedFor : String

Output without Profanity:

API output without swear word

API response 👇

{
  "isProfanity": false,
  "score": 0.79129016
}

Output with Profanity:

API output with swear word

API response 👇

{
  "isProfanity": true,
  "score": 1,
  "flaggedFor": "fucking"
}

Rate Limits

Currently the rate limits are set to the following:

const RATE_LIMIT_WINDOW = 60; // Time window in seconds
const MAX_REQUESTS = 100; // Max requests per IP within time window

Make an API request:

const res = await fetch("https://soapbar.ryanhattonmain.workers.dev/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ message }),
});

Future Updates

  1. Model optimization - increase chance of catching profanity permutations
  2. Multi-language support - currently API only supports english
  3. Discord integration
  4. Support for other apps - please suggest any! 🙂