SDK R
Il pacchetto tomba è il client R ufficiale per l'API Tomba. Ogni funzione accetta un oggetto client Tomba e invia una richiesta. Questa pagina descrive la versione 1.1.0, disponibile su GitHub.
Requisiti
- R 3.5.0 o successivo, come dichiarato in
DESCRIPTION. - I pacchetti
httrejsonlite, installati come dipendenze.
Installa
Code
Su CRAN c'è la versione 1.0.1. Contiene solo account, autocomplete, count, domain_search, email_finder, email_sources, email_verifier, logs, status e usage, e queste funzioni restituiscono direttamente il corpo della risposta, senza il wrapper data e rate_limit descritto più avanti.
Autenticati
Crea una chiave API e copia il tuo secret nella pagina API keys, poi esportali entrambi, o impostali in ~/.Renviron:
Code
Il pacchetto non legge da solo le variabili d'ambiente. Passa i valori come Tomba(key = ..., secret = ...), e il client li invia come header X-Tomba-Key e X-Tomba-Secret. La scadenza e la rotazione delle chiavi sono trattate in Autenticazione.
Prima richiesta
Trova l'indirizzo email di una persona in un'azienda:
Code
Ogni funzione restituisce una lista con due elementi: data, il corpo della risposta analizzato con jsonlite::fromJSON, e rate_limit. L'API racchiude il payload in un proprio oggetto data (Formato della risposta), quindi l'indirizzo si trova in result$data$data$email.
Errori
Quando l'API risponde con uno stato 400 o superiore, la funzione segnala un errore R il cui messaggio è Tomba API error <status>: <response body>. Intercettalo con tryCatch:
Code
Il corpo della risposta nel messaggio è l'errore JSON, {"errors":{"type":…,"message":…,"code":…}}. Ogni errors.type è descritto in Errori. person_find, company_find e combined_find non segnalano un errore quando non trovano nulla: questi endpoint rispondono con stato 200 e un corpo errors, quindi controlla result$data$errors.
Limiti di frequenza e nuovi tentativi
Il pacchetto non riprova le richieste. result$rate_limit è una lista con nomi degli header dei limiti di frequenza presenti nella risposta, con valori character: x-second-rate-limit, x-minute-rate-limit, x-daily-rate-limit, x-minute-request-left, x-daily-request-left, x-minute-reset-seconds, x-daily-reset-seconds, retry-after, ratelimit-policy e ratelimit.
Un 429 segnala un errore senza gli header della risposta. Attendi prima di riprovare, come descritto in Gestisci le risposte 429.
Le richieste vanno in timeout dopo 120 secondi; il timeout non è configurabile.
Riferimento dei metodi
Ogni funzione accetta il client come obj, il suo primo argomento.
| Funzione | Endpoint |
|---|---|
account(obj) | GET /me |
usage(obj) | GET /usage |
logs(obj, page = NULL, limit = NULL) | GET /logs |
domain_search(obj, domain, enrich_mobile = NULL, webhook_url = NULL) | GET /domain-search |
email_finder(obj, domain, fname, lname, webhook_url = NULL) | GET /email-finder |
author_finder(obj, url, webhook_url = NULL) | GET /author-finder |
linkedin_finder(obj, url, webhook_url = NULL) | GET /linkedin |
email_format(obj, domain) | GET /email-format |
get_location(obj, domain) | GET /location |
count(obj, domain) | GET /email-count |
email_verifier(obj, email, webhook_url = NULL) | GET /email-verifier |
email_sources(obj, email) | GET /email-sources |
person_find(obj, email) | GET /people/find |
company_find(obj, domain) | GET /companies/find |
combined_find(obj, email) | GET /combined/find |
phone_finder(obj, email, webhook_url = NULL) | GET /phone-finder |
phone_validator(obj, phone, country_code = NULL) | GET /phone-validator |
status(obj, domain) | GET /domain-status |
autocomplete(obj, search) | GET /domain-suggestions |
similar_domains(obj, domain) | GET /similar |
technology_check(obj, domain) | GET /technology |
companies_search(obj, data = list()) | POST /reveal/search |
list_flags(obj, page = NULL, limit = NULL) | GET /flag |
list_keys(obj) | GET /keys |
get_key(obj, id) | GET /keys/{id} |
create_key(obj, data = list()) | POST /keys |
reset_key(obj, id) | PUT /keys/{id} |
delete_key(obj, id) | DELETE /keys/{id} |
list_leads(obj, page = NULL, limit = NULL, domain = NULL) | GET /leads |
get_lead(obj, lead_id) | GET /leads/{id} |
create_lead(obj, data = list()) | POST /leads |
update_lead(obj, lead_id, data = list()) | PUT /leads/{id} |
delete_lead(obj, lead_id) | DELETE /leads/{id} |
list_leads_lists(obj) | GET /leads_lists |
create_leads_list(obj, data = list()) | POST /leads_lists |
update_leads_list(obj, id, data = list()) | PUT /leads_lists/{id} |
delete_leads_list(obj, id) | DELETE /leads_lists/{id} |
list_lead_attributes(obj) | GET /attributes |
create_lead_attribute(obj, data = list()) | POST /attributes |
update_lead_attribute(obj, id, data = list()) | PUT /attributes/{id} |
delete_lead_attribute(obj, id) | DELETE /attributes/{id} |
list_bulks(obj, bulk_type, page = NULL, limit = NULL) | GET /bulk/{type} |
create_bulk(obj, bulk_type, data = list()) | POST /bulk/{type} |
get_bulk(obj, bulk_type, bulk_id) | GET /bulk/{type}/{id} |
launch_bulk(obj, bulk_type, bulk_id) | PUT /bulk/{type}/{id} |
bulk_progress(obj, bulk_type, bulk_id) | GET /bulk/{type}/{id}/progress |
rename_bulk(obj, bulk_type, bulk_id, name) | PUT /bulk/{type}/{id}/rename |
archive_bulk(obj, bulk_type, bulk_id) | DELETE /bulk/{type}/{id}/archive |
delete_bulk(obj, bulk_type, bulk_id) | DELETE /bulk/{type}/{id}/delete |
bulk_type è il segmento {type} elencato in Tipi di job in blocco; l'ordine delle chiamate è descritto in Ciclo di vita. create_bulk invia un corpo JSON, quindi non può creare job che richiedono il caricamento di un file CSV, come i job Email Finder.
Codice sorgente
github.com/tomba-io/r (Apache-2.0).