Fidro + Express.js Integration
Middleware-ready fraud detection for Express. Follow this guide to add email validation and IP intelligence in minutes.
Overview
To integrate Fidro with Express.js, use the built-in fetch API (or node-fetch) to send a POST request to the Fidro API as middleware. Fidro returns email validation results, disposable email detection, IP intelligence, and a fraud risk score that you can attach to the request object. The integration works as Express middleware, so you can protect specific routes or your entire application with automatic fraud detection — no SDK required.
Fidro is a fraud detection API that combines email validation, IP intelligence, geolocation analysis, and Stripe chargeback prevention in a single API call. It returns a risk score with a clear recommendation — allow, review, or block — so you can stop fraud without building your own scoring logic.
1. Install Dependencies
# Node 18+ has built-in fetch. For older versions:
npm install node-fetch
You will also need a Fidro API key. Sign up for free to get one.
2. Email Validation
Send a POST request to Fidro's /v1/validate endpoint with the user's email address and optional IP. Fidro validates the email, checks for disposable domains, analyzes the IP for VPN/proxy/Tor usage, and returns a risk score with a clear recommendation — allow, review, or block.
// middleware/fidro.js
const FIDRO_API_KEY = process.env.FIDRO_API_KEY;
async function fidroValidate(req, res, next) {
const email = req.body.email;
if (!email) return next();
const ip = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
try {
const response = await fetch("https://api.fidro.io/v1/validate", {
method: "POST",
headers: {
Authorization: `Bearer ${FIDRO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ email, ip }),
});
if (!response.ok) {
console.error(`Fidro API error: ${response.status}`);
return next(); // Fail open — don't block on API errors
}
const result = await response.json();
req.fidro = result.data;
if (result.data.recommendation === "refund") {
return res.status(403).json({ error: "Request flagged as fraudulent" });
}
next();
} catch (err) {
console.error("Fidro error:", err.message);
next(); // Fail open
}
}
// ----- Express app example -----
// app.js
const express = require("express");
const app = express();
app.use(express.json());
// Apply to specific routes
app.post("/api/signup", fidroValidate, (req, res) => {
console.log("Risk score:", req.fidro?.risk_score);
console.log("Recommendation:", req.fidro?.recommendation);
// Continue with signup logic...
res.json({ success: true, risk_score: req.fidro?.risk_score });
});
app.listen(3000, () => console.log("Server running on port 3000"));
3. IP Lookup
Send a POST request to Fidro's /v1/ip-lookup endpoint with an IP address. Fidro returns geolocation data (country, city, ISP), VPN and proxy detection, Tor exit node identification, and threat intelligence — all in a single API call.
const FIDRO_API_KEY = process.env.FIDRO_API_KEY;
async function fidroIPLookup(req, res, next) {
const ip = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
try {
const response = await fetch("https://api.fidro.io/v1/ip-lookup", {
method: "POST",
headers: {
Authorization: `Bearer ${FIDRO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ ip }),
});
if (!response.ok) {
console.error(`Fidro API error: ${response.status}`);
return next();
}
const result = await response.json();
req.fidroIP = result.data;
next();
} catch (err) {
console.error("Fidro error:", err.message);
next();
}
}
// Usage in Express
app.get("/api/check-ip", fidroIPLookup, (req, res) => {
res.json({
country: req.fidroIP?.country,
is_vpn: req.fidroIP?.is_vpn,
});
});
Next steps
Explore the full API reference, try the free email checker, or see how Fidro compares to other solutions.
Frequently Asked Questions
How do I add fraud detection to Express.js?
Does Fidro have an Express.js SDK?
Is Fidro free to use with Express.js?
Start catching bad signups in the next 5 minutes
Create your account, grab your API key, and send your first request. Free plan with 200 validations/month. No credit card. Cancel anytime.
Get Started Free