cURL / SDK 示例
所有示例都用同一个公开基础地址:
https://api.zelnum.com/api/v1把 YOUR_KEY_HERE 换成认证里创建的 Key;产品 ID 请到实时产品列表取——下面的 ID 只是示例,产品增删后就会变。
一个手机号,一个产品
Section titled “一个手机号,一个产品”curl -X POST "https://api.zelnum.com/api/v1/realtime/check/phone" \ -H "X-API-Key: YOUR_KEY_HERE" \ -H "Idempotency-Key: 8f14e45f-ceea-467a-9f3f-1b2c3d4e5f60" \ -H "Content-Type: application/json" \ -d '{"identifier":"+8613800138000","country":"CN","product_ids":[47]}'号码已经是完整 E.164 时,country 可以省略;传国内格式号码时则要带上。
一个手机号,多个产品
Section titled “一个手机号,多个产品”curl -X POST "https://api.zelnum.com/api/v1/realtime/check/phone" \ -H "X-API-Key: YOUR_KEY_HERE" \ -H "Idempotency-Key: 5c2f1a90-6b7d-4e8f-9a01-2b3c4d5e6f70" \ -H "Content-Type: application/json" \ -d '{"identifier":"+8613800138000","country":"CN","product_ids":[47,50,51]}'三个产品、一个 request_id、results 里三条、三笔计费。10 个的上限见实时产品列表。
curl -X POST "https://api.zelnum.com/api/v1/realtime/check/email" \ -H "X-API-Key: YOUR_KEY_HERE" \ -H "Idempotency-Key: 0d9c8b7a-6543-4321-fedc-ba9876543210" \ -H "Content-Type: application/json" \ -d '{"identifier":"user@example.com","product_ids":[49]}'注意这里没有 country——邮箱产品不接受该字段。
只取你要的字段
Section titled “只取你要的字段”curl -s -X POST "https://api.zelnum.com/api/v1/realtime/check/phone" \ -H "X-API-Key: YOUR_KEY_HERE" \ -H "Idempotency-Key: 3a1b2c3d-4e5f-6071-8293-a4b5c6d7e8f9" \ -H "Content-Type: application/json" \ -d '{"identifier":"+8613800138000","product_ids":[47,50]}' \ | jq '{status, charged: .total_charged, items: [.results[] | {product: .product, result: .result, billed: .billing_status}]}'要逐条看 billing_status,不能只看 HTTP 状态——200 里完全可能夹着被退款的条目。见计费与退款。
一个不会重复扣费的重试脚本
Section titled “一个不会重复扣费的重试脚本”Idempotency-Key 的价值就在于:这个脚本跑两遍也是安全的。
KEY=$(uuidgen)BODY='{"identifier":"+8613800138000","country":"CN","product_ids":[47]}'
for attempt in 1 2 3; do response=$(curl -s -w '\n%{http_code}' -X POST \ "https://api.zelnum.com/api/v1/realtime/check/phone" \ -H "X-API-Key: YOUR_KEY_HERE" \ -H "Idempotency-Key: $KEY" \ -H "Content-Type: application/json" \ -d "$BODY")
code=$(printf '%s' "$response" | tail -n1) printf '%s' "$response" | sed '$d'
case "$code" in 200) exit 0 ;; # 结果不确定,这正是 Key 的用武之地:原样重发。 500|000) sleep 2 ;; # 仍在执行,或被限流:遵守 Retry-After,继续用同一个 Key。 409|429) sleep "$(printf '%s' "$response" | sed '$d' | jq -r '.retry_after // 2')" ;; *) exit 1 ;; esacdone对于没有观测到结果的那次请求,千万不要换一个新 Key 重试——那正是「一次检测付两次钱」的成因。见幂等与重试。
{ "request_id": "8c1e4f91-7bd8-4d7e-a3ae-3d7e5b0c6c11", "identifier": "+8613800138000", "status": "succeeded", "request_status": "completed", "replayed": false, "total_reserved": 0.004000, "total_charged": 0.004000, "total_refunded": 0.000000, "results": [ { "product_id": 47, "product": "wavalid-realtime", "result": "valid", "cached": false, "billing_status": "charged", "charged_amount": 0.002000, "refunded_amount": 0.000000, "checked_at": "2026-09-13T10:00:00Z", "error_code": null } ]}完整字段说明见响应字段。