Ruby SDK
The tomba gem is the official Ruby client for the Tomba API. Each API area is a service class in the Tomba module, and each method sends one request.
Requirements
Ruby 2.5 or later, as declared in the gemspec. The gem uses only the standard library.
Install
Code
Or add gem 'tomba' to your Gemfile.
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 set_key and set_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 method returns a hash with two keys: 'data', the parsed 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'].
Errors
The SDK raises Tomba::Exception when the API responds with status 400 or higher, when the body isn't JSON, when the connection fails, and before sending a request when a required argument is nil.
| Attribute | Value |
|---|---|
code | The status from the error body's errors.code, which matches the HTTP status. nil when no response was received. |
message | The API's errors.message. |
response | The parsed error body, { 'errors' => { 'type' => …, 'message' => …, 'code' => … } }, or nil. |
Code
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, keyed by header name: 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. Numbers are integers, and a header that is absent is nil.
A 429 raises Tomba::Exception with code 429, without the response headers. Wait before retrying as described in Handle 429 responses.
Connections and reads time out after 120 seconds; the timeouts aren't configurable.
Method reference
Create each service with the client, for example Tomba::Finder.new(client). Arguments shown as name: are keyword arguments.
| Method | Endpoint |
|---|---|
Account#get_account | GET /me |
Usage#get_usage | GET /usage |
Logs#get_logs(page: nil, limit: nil) | GET /logs |
Domain#domain_search(domain:, page: nil, limit: nil, department: nil, enrich_mobile: nil, webhook_url: nil) | GET /domain-search |
Finder#email_finder(domain:, first_name:, last_name:, webhook_url: nil) | GET /email-finder |
Finder#author_finder(url:, webhook_url: nil) | GET /author-finder |
Format#email_format(domain) | GET /email-format |
Location#get_location(domain) | GET /location |
Count#email_count(domain:) | GET /email-count |
Verifier#email_verifier(email:, webhook_url: nil) | GET /email-verifier |
Sources#email_sources(email:) | GET /email-sources |
Finder#phone_finder(email:, webhook_url: nil) | GET /phone-finder |
Phone#finder(params, webhook_url: nil) | GET /phone-finder |
Phone#validator(phone, country_code: nil) | GET /phone-validator |
Status#domain_status(domain:) | GET /domain-status |
Status#auto_complete(query:) | GET /domain-suggestions |
Similar#websites(domain) | GET /similar |
Technology#list(domain) | GET /technology |
Keys#get_keys | GET /keys |
Keys#get_key(id:) | GET /keys/{id} |
Keys#create_key | POST /keys |
Keys#reset_key(id:) | PUT /keys/{id} |
Keys#delete_key(id:) | DELETE /keys/{id} |
Leads#list_leads(page: nil, limit: nil, domain: nil) | GET /leads |
Leads#get_lead(id) | GET /leads/{id} |
Leads#create_lead(**data) | POST /leads |
Leads#update_lead(id, **data) | PUT /leads/{id} |
Leads#delete_lead(id) | DELETE /leads/{id} |
LeadsLists#get_lists | GET /leads_lists |
LeadsLists#delete_list_id(id:) | DELETE /leads_lists/{id} |
Bulk#list(type, params: {}) | GET /bulk/{type} |
Bulk#create(type, data) | POST /bulk/{type} |
Bulk#get(type, id) | GET /bulk/{type}/{id} |
Bulk#progress(type, id) | GET /bulk/{type}/{id}/progress |
Bulk#rename(type, id, name) | PUT /bulk/{type}/{id}/rename |
type is the {type} segment listed in Bulk types. Bulk#create 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/ruby (Apache-2.0). Release notes are in CHANGES.