Swift Profanity Filter

Moderate content from a Swift backend (Vapor/Hummingbird) using async URLSession.

Quick start in Swift

var req = URLRequest(url: URL(string: "https://api.theprofanityapi.com/v1/check")!)
req.httpMethod = "POST"
req.setValue("Bearer \(ProcessInfo.processInfo.environment["PROFANITY_API_KEY"]!)",
             forHTTPHeaderField: "Authorization")
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = try JSONSerialization.data(withJSONObject: [
    "text": text, "context": "chat", "mode": "balanced"
])

let (data, _) = try await URLSession.shared.data(for: req)
let result = try JSONDecoder().decode(ModerationResult.self, from: data)

Note: Run this from your server, not the iOS client — see the Swift backend note below if calling from an app.

Why context-aware matters

A plain word list flags "this game is sick" or medical text full of anatomical terms. The Profanity API runs a five-layer pipeline that scores intent, so "die" in a gaming taunt and "die" in a real threat are handled differently. Pick a context and the engine adjusts strictness automatically.


Other integrations

Ready to ship moderation?

Get an API key and 300 free requests a month. No credit card required.

Get started free →