Documentação · Node.js
Node 18+ tem fetch nativo. Não precisa instalar nada — basta chamar a API REST do EmailChecker direto. Compatível com qualquer runtime: Node, Bun, Deno, Edge.
# Nenhum pacote externo necessário com Node 18+.
# Para versões anteriores, use undici ou node-fetch.
npm install undici # opcional, só pra Node <18Single · POST /validate/single
Endpoint síncrono. Retorna em 1–3 segundos com result, score, reason e atributos. Custa 1 crédito por chamada bem-sucedida.
// validate-single.js
const API_KEY = process.env.EMAILCHECKER_API_KEY;
const BASE_URL = 'https://app.emailchecker.email/api/v1';
async function validateEmail(email) {
const r = await fetch(`${BASE_URL}/validate/single`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ email }),
});
if (!r.ok) throw new Error(`HTTP ${r.status}: ${await r.text()}`);
return r.json();
}
// uso
const result = await validateEmail('joao@empresa.com.br');
console.log(result.result); // "deliverable" | "undeliverable" | "risky" | "unknown"
console.log(result.score); // 0-100Batch · POST /validate/batch
Endpoint async. Submete array de emails, retorna job_id. Use webhook (recomendado) ou polling pra pegar resultado. Suporta até 100k emails por job.
// validate-batch.js
async function submitBatch(emails) {
const r = await fetch(`${BASE_URL}/validate/batch`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ emails, webhook_url: 'https://seu-app.com/webhook/ec' }),
});
if (!r.ok) throw new Error(`HTTP ${r.status}`);
const { job_id } = await r.json();
return job_id;
}
async function getBatchResult(jobId) {
const r = await fetch(`${BASE_URL}/validate/batch/${jobId}`, {
headers: { 'Authorization': `Bearer ${API_KEY}` },
});
return r.json();
}
// uso: submete e faz polling (ou usa webhook, ver abaixo)
const jobId = await submitBatch(['a@x.com', 'b@y.com', 'c@z.com']);
console.log('Job submetido:', jobId);Webhook handler
Quando o batch termina, a gente faz POST pra URL que você passou em webhook_url. Retry automático em até 3 tentativas (1s, 5s, 30s) se você responder com erro 5xx.
// webhook-handler.js (Express)
import express from 'express';
const app = express();
app.use(express.json());
app.post('/webhook/ec', (req, res) => {
const { job_id, status, results } = req.body;
if (status !== 'completed') {
return res.json({ ok: true }); // ignore intermediários
}
for (const r of results) {
if (r.result === 'deliverable') {
// salva no CRM, manda pra fila, etc.
}
}
res.json({ ok: true });
});
app.listen(3000);Mais linguagens
Comece grátis com 500 créditos. Sem cartão, sem compromisso.