Project Description: SpamGuard API (RapidAPI)
SpamGuard is a lightweight, production-ready HTTP API for classifying user-generated content (e.g., comments, messages, reviews) as spam or not-spam. It combines two complementary detectors—Naive Bayes and a rule-based “Snooker” engine—to provide fast, explainable results suitable for moderation pipelines, forms, and community platforms.
- Base RapidAPI URL:
https://spamguard-api1.p.rapidapi.com - Required header
x-rapidapi-host:spamguard-api1.p.rapidapi.com
How It Works
- You send a JSON payload describing the content to check.
- The API runs two analyzers:
- Naive Bayes: A probabilistic classifier trained to estimate the likelihood of spam.
- Snooker: A lightweight rule/heuristic-based checker tuned for short texts like blog comments.
- The API returns:
- An overall
is_spamboolean decision. - Per-engine details:
score(confidence/likelihood) andis_spamfor bothsnookerandbayes.
- An overall
The combined signal lets you build policies such as auto-block, flag-for-review, or allow-with-throttling.
When To Use It
- Moderating blog comments, contact forms, support tickets, and forum posts.
- Pre-screening UGC before publishing.
- Enriching existing moderation systems with a separate, explainable signal.
Authentication (RapidAPI)
Requests must include your RapidAPI key and host headers:
X-RapidAPI-Key: <YOUR_RAPIDAPI_KEY>X-RapidAPI-Host: spamguard-api1.p.rapidapi.com
Endpoint
POST /verify— Classify content as spam or not.
Request URL:
https://spamguard-api1.p.rapidapi.com/verify
Request Model
content(string, required): Text to classify; may include HTML.url(string, optional): A related URL that may help detection.author(string, optional): Author’s display name.
Max request body size: 4 MB.
Example JSON body:
{
"content": "Get our special promotion",
"url": "https://getpromo.xyz?getit=free",
"author": "James Bond"
}
Sample Requests
- cURL:
curl -X POST \
'https://spamguard-api1.p.rapidapi.com/verify' \
-H 'X-RapidAPI-Host: spamguard-api1.p.rapidapi.com' \
-H 'X-RapidAPI-Key: <YOUR_RAPIDAPI_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"content": "Get our special promotion",
"url": "https://getpromo.xyz?getit=free",
"author": "James Bond"
}'
- JavaScript (fetch):
const res = await fetch('https://spamguard-api1.p.rapidapi.com/verify', {
method: 'POST',
headers: {
'X-RapidAPI-Host': 'spamguard-api1.p.rapidapi.com',
'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
content: 'Get our special promotion',
url: 'https://getpromo.xyz?getit=free',
author: 'James Bond'
})
});
const data = await res.json();
console.log(data);
- PowerShell (Invoke-RestMethod):
$response = Invoke-RestMethod \
-Method Post \
-Uri 'https://spamguard-api1.p.rapidapi.com/verify' \
-Headers @{ \
'X-RapidAPI-Host' = 'spamguard-api1.p.rapidapi.com'; \
'X-RapidAPI-Key' = $env:RAPIDAPI_KEY; \
'Content-Type' = 'application/json'; \
'Accept' = 'application/json' \
} \
-Body (@{ \
content = 'Get our special promotion'; \
url = 'https://getpromo.xyz?getit=free'; \
author = 'James Bond' \
} | ConvertTo-Json)
$response
Sample Response
{
"is_spam": true,
"details": {
"snooker": {
"score": -1.0,
"is_spam": true
},
"bayes": {
"score": 0.79583853,
"is_spam": false
}
}
}
is_spam: Overall decision you can act on immediately.details.snookeranddetails.bayesprovide transparency and tunability.
Status Codes
200 OK— Classification succeeded.400 Bad Request— Invalid or oversized payload, or schema issues.401 Unauthorized— Missing/invalid RapidAPI credentials.
Quick Start (What to Do)
- Get access:
- Sign in to RapidAPI and subscribe to the SpamGuard API.
- Copy your
X-RapidAPI-Keyfrom the dashboard.
- Integrate the
/verifyendpoint in your service:- Add headers
X-RapidAPI-KeyandX-RapidAPI-Host. - Send JSON with at least the
contentfield.
- Add headers
- Act on the response:
- If
is_spamistrue, block or flag the content. - Optionally inspect
detailsto build nuanced rules (e.g., flag only if both engines agree, or if a score threshold is met).
- If
- Monitor and iterate:
- Log results and decisions.
- Adjust your thresholds per channel (comments vs. contact forms, etc.).
Implementation Notes (How It Works Internally)
- Naive Bayes: Uses token frequencies to compute posterior probabilities of spam vs. ham; robust to noisy text and efficient for short messages.
- Snooker: Applies curated heuristics (keyword patterns, link density, suspicious TLDs, etc.) to generate a quick, interpretable signal.
- Ensemble Decision: The API returns both signals and a consolidated
is_spamdecision designed for safe defaults while leaving room for custom policies.
Best Practices
- Always send
Accept: application/jsonandContent-Type: application/json. - Sanitize user input (strip dangerous HTML) on your side regardless of classification.
- Rate-limit inbound form submissions to reduce abuse and cost.
- Use
detailsto create channel-specific policies. - Log the request context (never raw secrets) and the full response to aid audits.
Troubleshooting
401 Unauthorized: Verify your RapidAPI subscription and ensure headersX-RapidAPI-KeyandX-RapidAPI-Hostare set.400 Bad Request: Check JSON schema, ensurecontentis present, and the body is < 4 MB.- Network/CORS: For browsers, use a backend proxy if your environment blocks custom headers.
FAQ
- Can I rely solely on
is_spam? Yes—is_spamis a sensible default. Usedetailsfor more nuanced workflows. - Does the API support HTML? Yes,
contentmay contain HTML; still sanitize on your side. - What’s the max payload? 4 MB.
Changelog Highlights
- Dual-engine classification (Naive Bayes + Snooker)
- Per-engine scores and booleans for transparency
- OpenAPI schema and interactive Scalar UI (local feature)
Contact and Support
Use your RapidAPI subscription dashboard for quota and billing. For technical issues or feature requests, open an issue on the project repository or contact the API provider via RapidAPI support.