Lua SDK
The tomba rock is the official Lua client for the Tomba API. All methods are on one client object, and each method sends one request.
Requirements
- Lua 5.1, 5.2, or 5.3. The rockspec allows Lua 5.1 or later, but the
xmlrock thatlua-requestsdepends on requires a version earlier than 5.4. - LuaRocks and a C++ compiler, to build the dependencies
lua-requestsandlua-cjson.
Install
Code
The first command builds the xml rock in C++14 mode. Without it, luarocks install tomba fails on compilers that default to C++17, such as GCC 11 and later, because xml doesn't compile as C++17.
Authenticate
Create an API key and copy your secret on the API keys page, then export both:
Code
The SDK doesn't read environment variables. Pass the values to Tomba:init(key, secret), and the client sends them as the X-Tomba-Key and X-Tomba-Secret headers. init raises an error if either value is shorter than 39 characters. Key expiry and rotation are covered in Authentication.
First request
Find the email address of a person at a company:
Code
Every method returns a table with two fields: data, the decoded JSON body, and rate_limit. The API wraps its payload in its own data object (Response format), so the address is at result.data.data.email. JSON null values decode to cjson.null.
Errors
How a failure surfaces depends on the HTTP method:
GETmethods raise a Lua error when the status isn't 200. The error message is the raw response body, prefixed with the SDK's file and line number.POST,PUT, andDELETEmethods don't raise on API errors. They return the result table for any status, so checkresult.data.errors.
Catch GET errors with pcall and decode the body:
Code
errors.code is the HTTP status. Each errors.type is described in Errors.
Rate limits and retries
The SDK doesn't retry. result.rate_limit holds the response's rate limit headers that are present, keyed by header name, with string 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 on a GET method raises 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
Call every method on the client with a colon, for example tomba:email_finder(...). opts is an optional table.
| Method | Endpoint |
|---|---|
account() | GET /me |
usage() | GET /usage |
logs(params) | GET /logs |
domain_search(domain, opts), with opts.enrich_mobile and opts.webhook_url | GET /domain-search |
email_finder(domain, first_name, last_name, opts), with opts.webhook_url | GET /email-finder |
author_finder(url, opts) | GET /author-finder |
linkedin_finder(url, opts) | GET /linkedin |
enrichment(email, opts) | GET /enrich |
email_format(domain) | GET /email-format |
get_location(domain) | GET /location |
count(domain) | GET /email-count |
email_verifier(email, opts) | GET /email-verifier |
email_sources(email) | GET /email-sources |
person_find(email) | GET /people/find |
company_find(domain) | GET /companies/find |
combined_find(email) | GET /combined/find |
phone_finder(params) | GET /phone-finder |
phone_validator(phone, country_code) | GET /phone-validator |
status(domain) | GET /domain-status |
autocomplete(search) | GET /domain-suggestions |
similar(domain) | GET /similar |
technology(domain) | GET /technology |
companies_search(body) | POST /reveal/search |
list_flags(params) | GET /flag |
create_flag(body) | POST /flag |
list_keys() | GET /keys |
get_key(key_id) | GET /keys/{id} |
create_key() | POST /keys |
reset_key(key_id) | PUT /keys/{id} |
delete_key(key_id) | DELETE /keys/{id} |
list_leads(params) | GET /leads |
get_lead(lead_id) | GET /leads/{id} |
create_lead(body) | POST /leads |
update_lead(lead_id, body) | PUT /leads/{id} |
delete_lead(lead_id) | DELETE /leads/{id} |
list_leads_lists() | GET /leads_lists |
get_leads_list(list_id) | GET /leads_lists/{id} |
create_leads_list(body) | POST /leads_lists |
update_leads_list(list_id, body) | PUT /leads_lists/{id} |
delete_leads_list(list_id) | DELETE /leads_lists/{id} |
list_attributes() | GET /attributes |
get_attribute(attribute_id) | GET /attributes/{id} |
create_attribute(body) | POST /attributes |
update_attribute(attribute_id, body) | PUT /attributes/{id} |
delete_attribute(attribute_id) | DELETE /attributes/{id} |
list_bulks(bulk_type, params) | GET /bulk/{type} |
create_bulk(bulk_type, data) | POST /bulk/{type} |
get_bulk(bulk_type, id) | GET /bulk/{type}/{id} |
launch_bulk(bulk_type, id) | PUT /bulk/{type}/{id} |
bulk_progress(bulk_type, id) | GET /bulk/{type}/{id}/progress |
bulk_download(bulk_type, id) | GET /bulk/{type}/{id}/download |
rename_bulk(bulk_type, id, name) | PUT /bulk/{type}/{id}/rename |
archive_bulk(bulk_type, id) | DELETE /bulk/{type}/{id}/archive |
delete_bulk(bulk_type, 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/lua, licensed Apache-2.0 in its rockspec.