npm SDK — whatsapp-data-sdk

Official TypeScript/JavaScript client for the WhatsApp Data API. Typed methods, zero runtime dependencies, cache-first lookups, and a clean error taxonomy.

Zero dependencies
Fully typed
ESM + CJS
npmGitHub

Install

npm install whatsapp-data-sdk
# or
pnpm add whatsapp-data-sdk
# or
yarn add whatsapp-data-sdk

Uses the native fetch — works in Node 18+, Bun, Deno, and browsers. No axios, no polyfills required.

Quick start

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)

Authentication & transport

Your API key is always sent in the x-rapidapi-key header. Choose where requests go with transport.

transportLive hostCache / DB-only hostNotes
'proxy' (default)whatsapp-proxy.checkleaked.cc/number_cache on the same hostSimple — one base URL, no host header.
'rapidapi'wp-data.p.rapidapi.comwp-data-db-only.p.rapidapi.comSets x-rapidapi-host automatically. Use your RapidAPI key.
// RapidAPI marketplace (live + DB-only hosts)
const client = new WhatsAppDataClient({
  apiKey: process.env.RAPIDAPI_KEY!,
  transport: 'rapidapi',
})

You can override any URL/host via baseUrl, cacheBaseUrl, rapidApiHost, rapidApiCacheHost.

Cache-first lookups (save money)

checkCached() reads the cheap cache / DB-only endpoint first and only falls back to a paid live check when the number isn't cached yet.

// 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' })

On the rapidapi transport this routes the cache read to wp-data-db-only.p.rapidapi.com and the live fallback to wp-data.p.rapidapi.com — the two-host money-saving flow.

API reference

Every method maps 1:1 to a marketplace endpoint.

Profile & pictures

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

getProfile options include telegram, google, lookup, includeCarrier, base64, geminiFaceAnalysis, reverseImageSearch, fullAiReport, includeDeviceCount, onlyCheck, useCache, forceBypassCache, and more.

const pic = await client.getLastPicture('59898297150')
// pic.bytes: Uint8Array, pic.contentType: string
htmlImg.src = pic.toDataUri()

Phone breaches

await client.getPhoneBreaches(number, { limit, offset }) // Get Phone Breaches (no external key)
await client.getPhoneBreachesExternal(number, apiKey)     // Get Phone Breaches (your checkleaked.cc key)

Search & database

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)

Bulk checks

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 & carrier

// 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)

"Not found" resolves — it does not throw

A number simply not on WhatsApp is a normal result, not an error, so these resolve (they never reject):

getProfile / getProfileNoPicture / checkCached returns an entry with exists:false (and code:'NUMBER_NOT_FOUND').
search with zero matches returns an empty page (success:false, data.docs:[]).
getDeviceCount for a non-WhatsApp number returns success:false (with deviceCount absent).
const p = await client.getProfile('14155552671')
if (!p.exists) console.log('not on WhatsApp')

What does throw: an invalid number (400), auth failure (401/403), rate limit (429), timeout, network failure, and 5xx.

Errors

All rejections are a subclass of WhatsAppDataError, so a single catch handles everything.

ClassWhen
ValidationErrorBad arguments (thrown synchronously, before any request; no .status).
AuthError401 / 403 — missing, invalid, or unsubscribed key.
RateLimitError429 — carries retryAfterMs when the server sent Retry-After.
HttpErrorAny other non-2xx (e.g. 400, 5xx); carries .status and .body.
TimeoutErrorThe request exceeded timeoutMs.
NetworkErrorTransport failure (DNS, connection reset, mid-body abort).
WhatsAppDataErrorBase class for all of the above.
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)
  }
}

Configuration

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)
})

Phone number formats

Pass numbers in any format — the SDK normalizes them, and exports the helpers so you can reuse the same normalization:

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 digits

Per-request options

Every method takes a trailing options object that also accepts signal, timeoutMs, and retries — for per-call cancellation and tuning:

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 WhatsAppDataError

Related

What Our Users Say

Real reviews from our satisfied customers

4.5/5 (176 reviews)