spampatrol
v1.6.11
Published
JavaScript/TypeScript library for SpamPatrol.io
Maintainers
Readme
SpamPatrol JavaScript/TypeScript Client Package
Add intent-based spam filtering to forms without re-implementing detection logic. SpamPatrol analyzes submissions like a human would—understanding real intent rather than just relying on IP/domain heuristics—so it can flag botnets, rouge humans, or suspect messages quickly. Fast responses keep your workflows moving, you can route low-score content to spam folders for review. Includes privacy-friendly hashing to avoid third-party tracking.
Installation
yarn add spampatrolYou can use it without an API key for low-volume traffic, and when you exceed that threshold you can create a key at https://spampatrol.io to unlock higher quota.
Distribution
The package ships both CommonJS and ESM bundles (dist/index.cjs and dist/index.mjs) plus TypeScript declarations, so you can import it from legacy Node stacks or modern tooling.
Usage (TypeScript)
import SpamPatrol from 'spampatrol';
const client = new SpamPatrol({
apiKey: process.env.SPAMPATROL_API_KEY,
});
const analysis = await client.analyze({
content: 'I would like to buy your services!',
expectedCountries: ['US'],
});
console.log('score', analysis.result.score);
console.log('spam?', analysis.result.solicitation);import { analyze } from 'spampatrol';
const analysis = await analyze({
content: 'Sign me up for your newsletter.',
expectedLanguages: ['en'],
apiKey: process.env.SPAMPATROL_API_KEY,
});
console.log('score', analysis.result.score);