Skip to main content

Node.js Integration

We recommend using axios or the native fetch API.

const axios = require('axios');

const validateEmail = async (email) => {
try {
const response = await axios.get('https://api.checkemail.dev/validate', {
params: { email },
headers: {
'x-api-key': 'ce_d_YOUR_API_KEY'
}
});

const { confidence, validations } = response.data;
const { status, confidence_score, alias_status, canonical_email } = confidence;

// 1. Check for disposable burners
if (status === 'DISPOSABLE' || validations.is_disposable) {
throw new Error('Disposable emails are not allowed.');
}

// 2. Prevent trial abuse using aliases
if (alias_status === 'ALIAS_CONFIRMED') {
console.log(`Detected alias for: ${canonical_email}`);
// Optional: Check if canonical_email already exists in your DB
}

if (status !== 'LIKELY' && confidence_score < 50) {
throw new Error('Email address appears invalid.');
}

return true;
} catch (error) {
console.error('Validation failed:', error.message);
return false;
}
};