SDK Python — whatsapp-data-sdk
Client Python ufficiale per l'API dati di WhatsApp. Risposte tipizzate, una sola dipendenza (richieste), ricerche con priorità alla cache e una gerarchia di eccezioni pulita.
Installare
pip install whatsapp-data-sdk
Compatibile con Python 3.8-3.13. Include un marcatore py.typed per il supporto completo del type-checker (mypy, pyright).
Avvio 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"))Autenticazione e trasporto
La tua chiave viene sempre inviata in x-rapidapi-key. Scegli dove vengono indirizzate le richieste tramite il trasporto.
| transport | Conduttore dal vivo | Host solo cache/DB |
|---|---|---|
"proxy" (predefinito) | whatsapp-proxy.checkleaked.cc | /number_cache sullo stesso host |
"rapidapi" | wp-data.p.rapidapi.com | wp-data-db-only.p.rapidapi.com |
client = WhatsAppDataClient(api_key="RAPIDAPI_KEY", transport="rapidapi")
Sovrascrivi URL/host tramite base_url, cache_base_url, rapidapi_host, rapidapi_cache_host.
Ricerche con priorità alla cache (risparmio di denaro)
La funzione check_cached() legge prima l'endpoint economico della cache/solo database e solo in caso di errore effettivo ricorre a un controllo live a pagamento.
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 freshUn record autorevole memorizzato nella cache ma non presente su WhatsApp viene conteggiato come un successo (nessun inutile controllo in tempo reale); solo un vero e proprio errore NOT_IN_DATABASE viene rilevato in tempo reale.
Riferimento API
Ogni metodo corrisponde 1:1 a un endpoint del marketplace, con la stessa copertura dell'SDK npm e la stessa nomenclatura 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"Non trovato" si risolve — non genera
Un numero non presente su WhatsApp è un risultato normale, quindi questi problemi si risolvono (non si presentano mai):
p = client.get_profile("14155552671")
if not p.get("exists"):
print("not on WhatsApp")Cosa genera: numero non valido (400), autenticazione (401/403), limite di frequenza (429), timeout, rete, 5xx.
Opzioni per richiesta
Ogni metodo accetta un timeout (in secondi) e dei tentativi:
client.get_profile("59898297150", timeout=5, retries=0)Errori
Tutti gli errori generano una sottoclasse di WhatsAppDataError.
| Classe | Quando |
|---|---|
ValidationError | Argomentazioni infondate (sollevate prima di qualsiasi richiesta; senza stato). |
AuthError | 401 / 403 — chiave mancante/non valida/non iscritta. |
RateLimitError | 429 — contiene .retry_after_ms quando il server ha inviato Retry-After. |
HttpError | Qualsiasi altro numero diverso da 2xx (ad esempio 400, 5xx); ha .status, .body. |
TimeoutError | La richiesta ha superato il tempo limite. |
NetworkError | Guasto durante il trasporto. |
WhatsAppDataError | Classe 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)Le richieste POST (bulk_check, bulk_check_db_*) non vengono ritentate automaticamente per evitare il doppio utilizzo della quota.
Formati dei numeri di telefono
Qualsiasi formato funziona: l'SDK normalizza i dati; le funzioni di supporto vengono esportate.
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)Imparentato
Cosa Dicono i Nostri Utenti
Recensioni reali dai nostri clienti soddisfatti