SDK de Python — whatsapp-data-sdk

Cliente oficial de Python para la WhatsApp Data API. Respuestas tipadas, una sola dependencia (requests), busquedas cache-first y una jerarquia de excepciones clara.

1 dependencia
Tipado (py.typed)
Port del SDK npm
PyPIGitHub

Instalacion

pip install whatsapp-data-sdk

Compatible con Python 3.8-3.13. Incluye marcador py.typed para soporte completo de verificadores de tipos (mypy, pyright).

Inicio rapido

from whatsapp_data_sdk import WhatsAppDataClient

client = WhatsAppDataClient(api_key="YOUR_KEY")  # sent as x-rapidapi-key

profile = client.get_profile("59898297150")
print(profile.get("exists"), profile.get("about"), profile.get("profilePic"))

Autenticacion y transporte

Tu clave siempre se envia en x-rapidapi-key. Elige a donde van las peticiones con transport.

transportHost en vivoHost de cache / solo BD
"proxy" (por defecto)whatsapp-proxy.checkleaked.cc/number_cache en el mismo host
"rapidapi"wp-data.p.rapidapi.comwp-data-db-only.p.rapidapi.com
client = WhatsAppDataClient(api_key="RAPIDAPI_KEY", transport="rapidapi")

Sobrescribe URLs/hosts con base_url, cache_base_url, rapidapi_host, rapidapi_cache_host.

Busquedas cache-first (ahorra dinero)

check_cached() lee primero el endpoint barato de cache / solo BD y solo recurre a una verificacion en vivo pagada en un fallo real.

r1 = client.check_cached("59898297150")                  # cacheFirst (default)
print(r1["_source"])                                     # "cache" | "live"
r2 = client.check_cached("59898297150", mode="cacheOnly")  # never a live call
r3 = client.check_cached("59898297150", mode="live")       # always fresh

Un registro en cache autoritativo de "no esta en WhatsApp" cuenta como acierto (sin re-verificacion en vivo innecesaria); solo un fallo real NOT_IN_DATABASE pasa a modo en vivo.

Referencia de la API

Cada metodo corresponde 1:1 a un endpoint del marketplace — misma cobertura que el SDK npm, con nombres snake_case.

# Profile & pictures
client.get_profile(number, telegram=True, include_carrier=True)  # Get Profile Information
client.get_profile_no_picture(number)                            # (No profile pic)
pic = client.get_last_picture(number)                            # JPEG bytes -> pic.content, pic.to_data_uri()
client.get_device_count(number)                                  # Device count
client.get_osint_info(number)                                    # OSINT Info

# Breaches
client.get_phone_breaches(number, limit=50)                      # built-in (no external key)
client.get_phone_breaches_external(number, api_key="...")        # your checkleaked.cc key

# Search & database
client.search(country_code="UY", is_business=True, limit=20)     # Search
client.search_google_maps(latitude=-34.9, longitude=-56.16, radius=2000)  # Search in Google Maps
client.get_leaked_numbers_info()                                 # Leaked Numbers (500M) -> Drive link (MEGA tier)
client.download_entire_database()                                # Download the Entire DB -> Drive link (MEGA tier)

# Bulk
client.bulk_check(numbers)                                       # live (max 50)
client.bulk_check_db_basic(numbers)                              # DB basic (max 1000)
client.bulk_check_db_full(numbers)                                # DB full (max 1000)

# Telegram / carrier
client.get_telegram_profile("59898297150")                      # experimental
client.get_telegram_profile(["num1", "num2"])
client.carrier_lookup(number)                                    # Carrier Lookup
client.carrier_lookup_alt(number, page=2)                        # Carrier Lookup Alternative

"No encontrado" se resuelve — no lanza excepcion

Un numero que no esta en WhatsApp es un resultado normal, asi que estos se resuelven (nunca lanzan excepcion):

get_profile / get_profile_no_picture / check_cached devuelven un dict con exists=False (y code="NUMBER_NOT_FOUND").
search sin coincidencias devuelve una pagina vacia (success=False, data['docs'] == []).
get_device_count para un numero sin WhatsApp devuelve success=False.
p = client.get_profile("14155552671")
if not p.get("exists"):
    print("not on WhatsApp")

Lo que si lanza excepcion: numero invalido (400), autenticacion (401/403), limite de tasa (429), timeout, red, 5xx.

Opciones por peticion

Cada metodo acepta timeout (segundos) y retries:

client.get_profile("59898297150", timeout=5, retries=0)

Errores

Todos los fallos lanzan una subclase de WhatsAppDataError.

ClaseCuando
ValidationErrorArgumentos invalidos (lanzado antes de cualquier peticion; sin .status).
AuthError401 / 403 — clave faltante/invalida/sin suscripcion.
RateLimitError429 — incluye .retry_after_ms cuando el servidor envio Retry-After.
HttpErrorCualquier otro no-2xx (p. ej. 400, 5xx); tiene .status, .body.
TimeoutErrorLa peticion excedio el timeout.
NetworkErrorFallo de transporte.
WhatsAppDataErrorClase base.
from whatsapp_data_sdk import AuthError, RateLimitError, WhatsAppDataError

try:
    client.get_profile("59898297150")
except AuthError:
    ...  # 401/403
except RateLimitError as e:
    print(e.retry_after_ms)
except WhatsAppDataError as e:
    print(e.status, e.body)

Los POST (bulk_check, bulk_check_db_*) no se reintentan automaticamente, para evitar gastar cuota doble.

Formatos de numero de telefono

Cualquier formato funciona — el SDK normaliza; los helpers estan exportados:

from whatsapp_data_sdk import to_digits, to_e164
to_digits("+598 98 297 150")  # "59898297150"  (path & live endpoints)
to_e164("59898297150")        # "+59898297150" (bulk-DB endpoints require it)

Relacionado

Lo Que Dicen Nuestros Usuarios

Reseñas reales de nuestros clientes satisfechos

4.5/5 (176 reseñas)