Contoh cURL / SDK
Semua contoh menggunakan base URL publik:
https://api.zelnum.com/api/v1Ganti YOUR_KEY_HERE dengan key dari Autentikasi, dan ambil slug produk dari Produk bulk.
Kirim array
Section titled “Kirim array”curl -X POST "https://api.zelnum.com/api/v1/detect" \ -H "X-API-Key: YOUR_KEY_HERE" \ -H "Content-Type: application/json" \ -d '{ "product": "YOUR_PRODUCT_SLUG", "country": "CN", "phones": ["+8613800138000", "+8613800138001"] }'Responsnya memberi Anda token tugas dan jumlah yang sudah dipotong di muka:
{ "mode": "async", "task_id": "xKj9aP3qLm7v", "message": "Task queued. Poll GET /api/v1/tasks/xKj9aP3qLm7v for progress.", "summary": { "total": 5000, "cost_deducted": 0.500000 }}Unggah file
Section titled “Unggah file”curl -X POST "https://api.zelnum.com/api/v1/detect/file" \ -H "X-API-Key: YOUR_KEY_HERE" \ -F "product=YOUR_PRODUCT_SLUG" \ -F "country=CN" \ -F "file=@numbers.txt"numbers.txt berisi satu nomor per baris, hingga 50 MB. Perhatikan -F, bukan -d: endpoint ini menerima multipart/form-data.
Polling sampai selesai
Section titled “Polling sampai selesai”TOKEN=xKj9aP3qLm7v
while true; do status=$(curl -s "https://api.zelnum.com/api/v1/tasks/$TOKEN" \ -H "X-API-Key: YOUR_KEY_HERE")
printf '%s\n' "$status" | jq '{status, progress, valid, invalid, unknown}'
case "$(printf '%s' "$status" | jq -r .status)" in completed|failed) break ;; esac
sleep 4doneEmpat detik antar-polling adalah interval yang wajar untuk tugas berukuran apa pun; halaman tugas melaporkan progress sebagai persentase.
Unduh hasilnya
Section titled “Unduh hasilnya”curl -s "https://api.zelnum.com/api/v1/tasks/$TOKEN/result" \ -H "X-API-Key: YOUR_KEY_HERE" | jq -r .download_urldownload_url dibatasi waktu — ambil sebelum expires_at, atau filenya hilang. Lalu:
curl -L -H "X-API-Key: YOUR_KEY_HERE" \ "https://api.zelnum.com/api/v1/tasks/$TOKEN/download" -o results.csvSatu skrip, dari awal sampai akhir
Section titled “Satu skrip, dari awal sampai akhir”#!/usr/bin/env bashset -euo pipefail
API="https://api.zelnum.com/api/v1"KEY="YOUR_KEY_HERE"SLUG="YOUR_PRODUCT_SLUG"
task=$(curl -s -X POST "$API/detect" \ -H "X-API-Key: $KEY" -H "Content-Type: application/json" \ -d "{\"product\":\"$SLUG\",\"country\":\"CN\",\"phones\":[\"+8613800138000\"]}" \ | jq -r .task_id)
echo "task $task submitted"
until [ "$(curl -s "$API/tasks/$task" -H "X-API-Key: $KEY" | jq -r .status)" = "completed" ]; do sleep 4done
url=$(curl -s "$API/tasks/$task/result" -H "X-API-Key: $KEY" | jq -r .download_url)curl -L "$url" -o results.csv
echo "wrote results.csv"Berikutnya
Section titled “Berikutnya”- Status tugas — setiap field yang dikembalikan polling
- Unduh hasil — aturan retensi dan kedaluwarsa
- Format respons — konvensi bersama