KireiFilter

Node.js integration guide

Add spam detection to Express, Fastify, Next.js, or any Node.js app. Uses native fetch (Node 18+) — no extra dependencies needed.

Authentication: All requests need a Bearer token in the Authorization header. Generate one in Settings → API Tokens.

Helper function (native fetch)

spamCheck.js
const KIREIFILTER_TOKEN = process.env.KIREIFILTER_TOKEN;
async function checkSpam({ type, content, metadata = {} }) {
const res = await fetch('https://kireifilter.net/api/v1/spam-check', {
method: 'POST',
headers: {
'Authorization': `Bearer ${KIREIFILTER_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ type, content, metadata }),
});
if (!res.ok) throw new Error(`KireiFilter error: ${res.status}`);
return res.json();
}
module.exports = { checkSpam };

Express contact form route

routes/contact.js
const { checkSpam } = require('./spamCheck');
router.post('/contact', async (req, res) => {
const { message } = req.body;
const { isSpam, score } = await checkSpam({
type: 'comment',
content: message,
metadata: { ip: req.ip },
});
if (isSpam)
return res.status(422).json({ error: 'Submission rejected' });
// send email notification...
res.json({ status: 'sent' });
});

Response fields

FieldTypeDescription
isSpambooleantrue if score ≥ 0.5
scorenumber0.0 (clean) to 1.0 (spam). Spam threshold is 0.5.
reasonsstring[]Detection signals that contributed to the score

Ready to integrate?

Free plan — 100 checks/month.

Other languages: PHP Python WordPress