EmailVerify LogoEmailVerify

API Reference

Complete email checker API reference. Endpoints, parameters, response codes for email verification and validation.

EmailVerify API 是一个 RESTful 服务,提供强大的邮箱验证功能。所有 API 请求都应通过 HTTPS 进行。

基础 URL

https://api.emailverify.ai/v1

身份验证

所有 API 请求都需要在 Authorization 头中使用 Bearer token 进行身份验证:

Authorization: Bearer YOUR_API_KEY

EmailVerify 仪表板获取您的 API 密钥。

示例

curl -X POST https://api.emailverify.ai/v1/verify \
  -H "Authorization: Bearer bv_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"email": "test@example.com"}'

速率限制

套餐每小时请求数每天请求数
Free1001,000
Starter1,00010,000
Professional10,000100,000
Enterprise自定义自定义

速率限制信息包含在响应头中:

响应头描述
X-RateLimit-Limit允许的最大请求数
X-RateLimit-Remaining当前窗口剩余请求数
X-RateLimit-Reset限制重置的 Unix 时间戳

当达到速率限制时,您将收到 429 Too Many Requests 响应:

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded. Please try again later.",
    "retry_after": 3600
  }
}

端点

单个邮箱验证

验证单个邮箱地址并返回详细结果。

POST /verify

请求

{
  "email": "user@example.com",
  "smtp_check": true,
  "timeout": 5000
}

参数

参数类型必需默认值描述
emailstring-要验证的邮箱地址
smtp_checkbooleantrue执行 SMTP 邮箱验证
timeoutinteger5000请求超时时间(毫秒)(最大:30000)

响应

{
  "email": "user@example.com",
  "status": "valid",
  "result": {
    "deliverable": true,
    "valid_format": true,
    "valid_domain": true,
    "valid_mx": true,
    "disposable": false,
    "role": false,
    "catchall": false,
    "free": false,
    "smtp_valid": true
  },
  "score": 0.95,
  "reason": null,
  "credits_used": 1
}

响应字段

字段类型描述
emailstring已验证的邮箱地址
statusstring验证状态:validinvalidunknownaccept_all
resultobject详细的验证结果
scorenumber置信度分数(0.0 - 1.0)
reasonstring无效/未知状态的原因(可为空)
credits_usedinteger消耗的积分数

结果对象字段

字段类型描述
deliverableboolean邮箱是否可以接收消息
valid_formatboolean邮箱是否具有有效语法
valid_domainboolean域名是否存在
valid_mxboolean域名是否有 MX 记录
disposableboolean邮箱是否来自一次性服务
roleboolean邮箱是否为角色邮箱(info@、support@)
catchallboolean域名是否接受所有邮件
freeboolean邮箱是否来自免费提供商
smtp_validbooleanSMTP 验证是否通过

批量邮箱验证

提交多个邮箱地址进行验证。返回用于跟踪进度的任务 ID。

POST /verify/bulk

请求

{
  "emails": [
    "user1@example.com",
    "user2@example.com",
    "user3@example.com"
  ],
  "smtp_check": true,
  "webhook_url": "https://your-app.com/webhooks/emailverify"
}

参数

参数类型必需默认值描述
emailsarray-邮箱地址数组(最多:10,000)
smtp_checkbooleantrue执行 SMTP 验证
webhook_urlstring-接收完成通知的 URL

响应

{
  "job_id": "job_abc123xyz",
  "status": "processing",
  "total": 3,
  "processed": 0,
  "valid": 0,
  "invalid": 0,
  "unknown": 0,
  "credits_used": 3,
  "created_at": "2025-01-15T10:30:00Z"
}

获取批量任务状态

检查批量验证任务的状态。

GET /verify/bulk/{job_id}

响应(进行中)

{
  "job_id": "job_abc123xyz",
  "status": "processing",
  "total": 1000,
  "processed": 450,
  "valid": 380,
  "invalid": 50,
  "unknown": 20,
  "progress_percent": 45,
  "created_at": "2025-01-15T10:30:00Z"
}

响应(已完成)

{
  "job_id": "job_abc123xyz",
  "status": "completed",
  "total": 1000,
  "processed": 1000,
  "valid": 850,
  "invalid": 100,
  "unknown": 50,
  "progress_percent": 100,
  "created_at": "2025-01-15T10:30:00Z",
  "completed_at": "2025-01-15T10:35:00Z"
}

任务状态值

状态描述
pending任务已排队
processing任务正在处理中
completed任务成功完成
failed任务失败(查看错误字段)

获取批量任务结果

检索已完成批量任务的验证结果。

GET /verify/bulk/{job_id}/results

查询参数

参数类型默认值描述
limitinteger100每页结果数(最大:1000)
offsetinteger0起始位置
statusstring-按状态筛选:validinvalidunknown

响应

{
  "job_id": "job_abc123xyz",
  "total": 1000,
  "limit": 100,
  "offset": 0,
  "results": [
    {
      "email": "user1@example.com",
      "status": "valid",
      "result": {
        "deliverable": true,
        "disposable": false,
        "role": false
      },
      "score": 0.95
    },
    {
      "email": "user2@example.com",
      "status": "invalid",
      "result": {
        "deliverable": false,
        "reason": "mailbox_not_found"
      },
      "score": 0.10
    }
  ]
}

检查积分

获取当前积分余额和使用信息。

GET /credits

响应

{
  "available": 9500,
  "used": 500,
  "total": 10000,
  "plan": "Professional",
  "resets_at": "2025-02-01T00:00:00Z",
  "rate_limit": {
    "requests_per_hour": 10000,
    "remaining": 9850
  }
}

Webhooks

创建 Webhook

POST /webhooks
{
  "url": "https://your-app.com/webhooks/emailverify",
  "events": ["verification.completed", "bulk.completed"],
  "secret": "your-webhook-secret"
}

列出 Webhooks

GET /webhooks

删除 Webhook

DELETE /webhooks/{webhook_id}

Webhook 事件

事件描述
verification.completed单个邮箱验证完成
bulk.completed批量任务完成
bulk.failed批量任务失败
credits.low积分低于阈值

Webhook 载荷

{
  "event": "bulk.completed",
  "timestamp": "2025-01-15T10:35:00Z",
  "data": {
    "job_id": "job_abc123xyz",
    "status": "completed",
    "total": 1000,
    "valid": 850,
    "invalid": 100,
    "unknown": 50
  },
  "signature": "sha256=..."
}

验证状态

状态含义推荐操作
valid邮箱存在且可以接收消息安全发送
invalid邮箱不存在或无法接收从列表中移除
unknown无法确定有效性稍后重试或谨慎使用
accept_all域名接受所有邮件(全接收)监控退信

错误响应

所有错误都遵循一致的格式:

{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message",
    "details": "Additional context (optional)"
  }
}

HTTP 状态码

状态码描述
200成功
400错误请求 - 参数无效
401未授权 - API 密钥无效或缺失
403禁止 - 权限不足
404未找到 - 资源不存在
429请求过多 - 超过速率限制
500内部服务器错误
503服务不可用

错误码

错误码HTTP 状态描述
INVALID_API_KEY401API 密钥无效或缺失
RATE_LIMIT_EXCEEDED429请求过多
INSUFFICIENT_CREDITS403积分不足
INVALID_EMAIL400邮箱格式无效
INVALID_REQUEST400请求体格式错误
JOB_NOT_FOUND404未找到批量任务 ID
TIMEOUT504验证超时

最佳实践

1. 使用环境变量

切勿硬编码 API 密钥:

// 正确
const apiKey = process.env.EMAILVERIFY_API_KEY;

// 错误 - 不要这样做
const apiKey = 'bv_live_xxx';

2. 处理速率限制

实现指数退避:

async function verifyWithRetry(email, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await verify(email);
    } catch (error) {
      if (error.code === 'RATE_LIMIT_EXCEEDED') {
        await sleep(Math.pow(2, i) * 1000);
        continue;
      }
      throw error;
    }
  }
}

3. 多个邮箱使用批量端点

验证超过 10 个邮箱时,使用批量端点:

// 正确 - 单次 API 调用
const job = await client.verifyBulk(emails);

// 错误 - 多次单独调用
for (const email of emails) {
  await client.verify(email);
}

4. 为批量任务实现 Webhooks

不要持续轮询;使用 webhooks:

// 提交时附带 webhook
const job = await client.verifyBulk(emails, {
  webhookUrl: 'https://your-app.com/webhook',
});

SDK

使用我们的官方 SDK 简化集成:

下一步

On this page