SDK npm — whatsapp-data-sdk
Cliente oficial TypeScript/JavaScript para la WhatsApp Data API. Metodos tipados, cero dependencias en tiempo de ejecucion, busquedas cache-first y una jerarquia de errores clara.
Instalacion
npm install whatsapp-data-sdk # or pnpm add whatsapp-data-sdk # or yarn add whatsapp-data-sdk
Usa el fetch nativo — funciona en Node 18+, Bun, Deno y navegadores. Sin axios, sin polyfills.
Inicio rapido
import { WhatsAppDataClient } from 'whatsapp-data-sdk'
const client = new WhatsAppDataClient({
apiKey: process.env.WA_API_KEY!, // sent as x-rapidapi-key
})
const profile = await client.getProfile('59898297150')
console.log(profile.exists, profile.about, profile.profilePic)Autenticacion y transporte
Tu clave API siempre se envia en el header x-rapidapi-key. Elige a donde van las peticiones con transport.
| transport | Host en vivo | Host de cache / solo BD | Notas |
|---|---|---|---|
'proxy' (por defecto) | whatsapp-proxy.checkleaked.cc | /number_cache en el mismo host | Simple — una sola URL base, sin header de host. |
'rapidapi' | wp-data.p.rapidapi.com | wp-data-db-only.p.rapidapi.com | Configura x-rapidapi-host automaticamente. Usa tu clave de RapidAPI. |
// RapidAPI marketplace (live + DB-only hosts)
const client = new WhatsAppDataClient({
apiKey: process.env.RAPIDAPI_KEY!,
transport: 'rapidapi',
})Puedes sobrescribir cualquier URL/host con baseUrl, cacheBaseUrl, rapidApiHost, rapidApiCacheHost.
Busquedas cache-first (ahorra dinero)
checkCached() lee primero el endpoint barato de cache / solo BD y solo recurre a una verificacion en vivo pagada cuando el numero aun no esta en cache.
// cacheFirst (default): DB first → live only on a miss
const r1 = await client.checkCached('59898297150')
console.log(r1._source) // 'cache' | 'live'
// cacheOnly: never spend on a live check
const r2 = await client.checkCached('59898297150', { mode: 'cacheOnly' })
// live: always fresh
const r3 = await client.checkCached('59898297150', { mode: 'live' })En el transporte rapidapi esto enruta la lectura de cache a wp-data-db-only.p.rapidapi.com y el fallback en vivo a wp-data.p.rapidapi.com — el flujo de ahorro de dos hosts.
Referencia de la API
Cada metodo corresponde 1:1 a un endpoint del marketplace.
Perfil y fotos
await client.getProfile(number, options?) // Get Profile Information await client.getProfileNoPicture(number, options?) // Get Profile Information (No profile pic) await client.getLastPicture(number) // Get Last Saved Picture (JPEG bytes) await client.getDeviceCount(number) // Device count await client.getOsintInfo(number) // OSINT Info
Las opciones de getProfile incluyen telegram, google, lookup, includeCarrier, base64, geminiFaceAnalysis, reverseImageSearch, fullAiReport, includeDeviceCount, onlyCheck, useCache, forceBypassCache, y mas.
const pic = await client.getLastPicture('59898297150')
// pic.bytes: Uint8Array, pic.contentType: string
htmlImg.src = pic.toDataUri()Filtraciones de telefono
await client.getPhoneBreaches(number, { limit, offset }) // Get Phone Breaches (no external key)
await client.getPhoneBreachesExternal(number, apiKey) // Get Phone Breaches (your checkleaked.cc key)Busqueda y base de datos
await client.search({ countryCode: 'UY', isBusiness: true, limit: 20 }) // Search
await client.searchGoogleMaps({ latitude: -34.9, longitude: -56.16, radius: 2000 }) // Search in Google Maps
// Bulk downloads return a Google Drive link to the full dataset (MEGA tier only)
const leaks = await client.getLeakedNumbersInfo() // Leaked Numbers (500M database)
console.log(leaks.driveFolder.url)
const backup = await client.downloadEntireDatabase() // Download the Entire DB
console.log(backup.driveFolder.url)Verificaciones masivas
await client.bulkCheck(numbers, { includeBusiness, noBanStatus }) // Bulk Check (live, max 50)
await client.bulkCheckDbBasic(numbers) // Basic Check (DB, max 1000)
await client.bulkCheckDbFull(numbers) // Full Check (DB, max 1000)Telegram y operador
// Telegram (experimental)
await client.getTelegramProfile('59898297150') // single
await client.getTelegramProfile(['num1', 'num2']) // batch
// Carrier
await client.carrierLookup(number) // Carrier Lookup
await client.carrierLookupAlt(number) // Carrier Lookup Alternative (spam-report signals)
await client.carrierLookupAlt(number, { page: 2 }) // page through the reports (response has a `pagination` block)"No encontrado" se resuelve — no lanza error
Un numero que simplemente no esta en WhatsApp es un resultado normal, no un error, asi que estos se resuelven (nunca se rechazan):
const p = await client.getProfile('14155552671')
if (!p.exists) console.log('not on WhatsApp')Lo que si lanza error: un numero invalido (400), fallo de autenticacion (401/403), limite de tasa (429), timeout, fallo de red, y 5xx.
Errores
Todos los rechazos son una subclase de WhatsAppDataError, asi que un solo catch maneja todo.
| Clase | Cuando |
|---|---|
ValidationError | Argumentos invalidos (lanzado sincronicamente, antes de cualquier peticion; sin .status). |
AuthError | 401 / 403 — clave faltante, invalida o sin suscripcion. |
RateLimitError | 429 — incluye retryAfterMs cuando el servidor envio Retry-After. |
HttpError | Cualquier otro no-2xx (p. ej. 400, 5xx); incluye .status y .body. |
TimeoutError | La peticion excedio timeoutMs. |
NetworkError | Fallo de transporte (DNS, conexion reiniciada, aborto a mitad de cuerpo). |
WhatsAppDataError | Clase base para todos los anteriores. |
import { AuthError, RateLimitError, TimeoutError, WhatsAppDataError } from 'whatsapp-data-sdk'
try {
await client.getProfile('59898297150')
} catch (err) {
if (err instanceof AuthError) {/* 401/403 — bad/unsubscribed key */}
else if (err instanceof RateLimitError) {/* 429 — err.retryAfterMs */}
else if (err instanceof TimeoutError) {/* request timed out */}
else if (err instanceof WhatsAppDataError) {
console.error(err.status, err.body)
}
}Configuracion
new WhatsAppDataClient({
apiKey: '...', // required
transport: 'proxy', // 'proxy' | 'rapidapi'
timeoutMs: 60000, // request timeout (bounds headers AND body read)
retries: 2, // retry 5xx / 429 / network / timeout (GET only) with backoff
retryDelayMs: 500, // exponential base; 429 honors Retry-After when longer
baseUrl: '...', // override live base URL
cacheBaseUrl: '...', // override cache/DB-only base URL
rapidApiHost: '...', // override live x-rapidapi-host
rapidApiCacheHost: '...',// override cache x-rapidapi-host
userAgent: '...', // custom User-Agent
fetch: globalThis.fetch, // inject a custom fetch (tests / polyfills)
})Formatos de numero de telefono
Pasa numeros en cualquier formato — el SDK los normaliza, y exporta los helpers para que reutilices la misma normalizacion:
import { toDigits, toE164 } from 'whatsapp-data-sdk'
toDigits('+598 98 297 150') // '59898297150' (path & live endpoints)
toE164('59898297150') // '+59898297150' (bulk-DB endpoints; their validator requires it)
// both throw ValidationError on input with no digitsOpciones por peticion
Cada metodo acepta un objeto de opciones final que tambien admite signal, timeoutMs y retries — para cancelacion y ajuste por llamada:
const controller = new AbortController()
const p = client.getProfile('59898297150', {
telegram: true,
signal: controller.signal, // cancel this specific request
timeoutMs: 5000, // override the client timeout for this call
})
controller.abort() // rejects with WhatsAppDataErrorRelacionado
Lo Que Dicen Nuestros Usuarios
Reseñas reales de nuestros clientes satisfechos