EmailCheckerEmailChecker

Documentação · Python

Validar email em Python

Python tem várias bibliotecas HTTP boas. Recomendamos httpx (suporta async + sync com mesma API) ou requests (padrão, mais conhecido). Os exemplos abaixo usam httpx — adapte trivialmente pra requests.

Instalação (pip / poetry / uv)

bash
pip install httpx
# ou:
poetry add httpx
uv add httpx

Single · POST /validate/single

Validar 1 email

Endpoint síncrono. Retorna em 1–3 segundos com result, score, reason e atributos. Custa 1 crédito por chamada bem-sucedida.

py
# validate_single.py
import os
import httpx

API_KEY = os.environ['EMAILCHECKER_API_KEY']
BASE_URL = 'https://app.emailchecker.email/api/v1'

def validate_email(email: str) -> dict:
    headers = {
        'Authorization': f'Bearer {API_KEY}',
        'Content-Type': 'application/json',
    }
    r = httpx.post(
        f'{BASE_URL}/validate/single',
        headers=headers,
        json={'email': email},
        timeout=15.0,
    )
    r.raise_for_status()
    return r.json()

# uso
result = validate_email('joao@empresa.com.br')
print(result['result'])  # "deliverable" | ...
print(result['score'])   # 0-100

Batch · POST /validate/batch

Validar em lote

Endpoint async. Submete array de emails, retorna job_id. Use webhook (recomendado) ou polling pra pegar resultado. Suporta até 100k emails por job.

py
# validate_batch.py
def submit_batch(emails: list[str], webhook_url: str | None = None) -> str:
    payload = {'emails': emails}
    if webhook_url:
        payload['webhook_url'] = webhook_url
    r = httpx.post(
        f'{BASE_URL}/validate/batch',
        headers={'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'},
        json=payload,
        timeout=30.0,
    )
    r.raise_for_status()
    return r.json()['job_id']

def get_batch_result(job_id: str) -> dict:
    r = httpx.get(
        f'{BASE_URL}/validate/batch/{job_id}',
        headers={'Authorization': f'Bearer {API_KEY}'},
        timeout=15.0,
    )
    return r.json()

# uso
job_id = submit_batch(['a@x.com', 'b@y.com'], webhook_url='https://seu-app.com/webhook/ec')

Webhook handler

Receber notificação do job

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.

py
# webhook_handler.py (FastAPI)
from fastapi import FastAPI, Request

app = FastAPI()

@app.post('/webhook/ec')
async def handle_webhook(req: Request):
    body = await req.json()
    if body['status'] != 'completed':
        return {'ok': True}
    for r in body['results']:
        if r['result'] == 'deliverable':
            # salva no CRM, manda pra fila, etc.
            pass
    return {'ok': True}

Boas práticas

Mais linguagens

Exemplos em outras linguagens

Comece agora

Pronto pra parar de mandar email pra endereço morto?

Comece grátis com 500 créditos. Sem cartão, sem compromisso.