R SDK
The tomba package is the official R client for the Tomba API. Every function takes a Tomba client object and sends one request. This page describes version 1.1.0, which is available from GitHub.
Requirements
- R 3.5.0 or later, as declared in
DESCRIPTION. - The
httrandjsonlitepackages, installed as dependencies.
Install
Code
CRAN has version 1.0.1. It has only account, autocomplete, count, domain_search, email_finder, email_sources, email_verifier, logs, status, and usage, and those return the response body directly, without the data and rate_limit wrapper described below.
Authenticate
Create an API key and copy your secret on the API keys page, then export both, or set them in ~/.Renviron:
Code
The package doesn't read environment variables itself. Pass the values as Tomba(key = ..., secret = ...), and the client sends them as the X-Tomba-Key and X-Tomba-Secret headers. Key expiry and rotation are covered in Authentication.
First request
Find the email address of a person at a company:
Code
Every function returns a list with two elements: data, the response body parsed with jsonlite::fromJSON, and rate_limit. The API wraps its payload in its own data object (Response format), so the address is at result$data$data$email.
Errors
When the API responds with status 400 or higher, the function signals an R error whose message is Tomba API error <status>: <response body>. Catch it with tryCatch:
Code
The response body in the message is the JSON error, {"errors":{"type":…,"message":…,"code":…}}. Each errors.type is described in Errors. person_find, company_find, and combined_find don't signal an error when nothing is found: those endpoints answer with status 200 and an errors body, so check result$data$errors.
Rate limits and retries
The package doesn't retry. result$rate_limit is a named list of the response's rate limit headers that are present, with character values: 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, and ratelimit.
A 429 signals an error without the response headers. Wait before retrying as described in Handle 429 responses.
Requests time out after 120 seconds; the timeout isn't configurable.
Method reference
Every function takes the client as obj, its first argument.
| Function | 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 is the {type} segment listed in Bulk types; the order of calls is described in Lifecycle. create_bulk sends a JSON body, so it can't create jobs that need a CSV upload, such as email finder jobs.
Source
github.com/tomba-io/r (Apache-2.0).