Node.js
Check and report with the built-in fetch.
Node 18 and later have fetch built in, so there is nothing to install.
Check an address
async function isipsafeScore(ip) {
const res = await fetch(`https://isipsafe.com/api/v1/check?ip=${encodeURIComponent(ip)}`, { signal: AbortSignal.timeout(3000) });
if (!res.ok) throw new Error(`isipsafe: ${res.status}`);
const { data } = await res.json();
return data.abuseConfidenceScore;
}
Express middleware
app.post("/login", async (req, res, next) => {
try {
if (await isipsafeScore(req.ip) >= 75) return res.status(403).send("Access denied");
} catch { /* fail open if the lookup fails */ }
next();
});
Set app.set("trust proxy", ...) correctly if you are behind a proxy, so req.ip is the visitor.
Report an address
await fetch(`https://isipsafe.com/api/v1/report?key=${process.env.ISIPSAFE_KEY ?? ""}`, {
method: "POST",
body: new URLSearchParams({ ip, categories: "web-app-attack,brute-force", comment: "40 failed logins" }),
});
Need a hand?
If something here does not work with your version of Node.js, or you have improved it, tell us. We update these pages with what people send.
Node.js and its logo are trademarks of their respective owners. isipsafe is not affiliated with or endorsed by them.