Elixir SDK
The tomba Hex package is the official Elixir client for the Tomba API. Each API area is a module, each function sends one request, and every function returns {:ok, result} or {:error, %Tomba.Error{}}.
Requirements
Install
Add the package to your dependencies in mix.exs:
Code
Then run mix deps.get.
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.client/3, and the client sends them as the X-Tomba-Key and X-Tomba-Secret headers. The optional third argument takes :timeout in milliseconds (default 120_000) and :base_url. Key expiry and rotation are covered in Authentication.
First request
Find the email address of a person at a company:
Code
Run a script like this one in your project with mix run first.exs. Functions take their parameters as a map with string keys, named as in the API reference. result is a map with two keys: :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"].
Errors
Functions return {:error, %Tomba.Error{}}, rather than raising, when the API responds with a status outside 200 to 299 or the request fails.
| Field | Value |
|---|---|
status_code | The HTTP status. 0 when no response was received. |
message | The API's errors.message, or the transport error. |
response | %{data: body, rate_limit: headers}, where body is the decoded error body. nil when no response was received. |
Code
A function called with a map that lacks a required key, such as "domain" for email_finder, raises FunctionClauseError without sending a request. Tomba.Enrichment.person/2, company/2, and combined/2 return {:ok, result} when nothing is found: those endpoints answer with status 200 and an errors body, so check result.data["errors"]. 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 lowercase 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".
On a 429, read the wait time from error.response.rate_limit["retry-after"] and retry as described in Handle 429 responses.
Method reference
Every function takes the client as its first argument. Map arguments list the keys the function requires.
| Function | Endpoint |
|---|---|
Tomba.Account.account(client) | GET /me |
Tomba.Usage.get_usage(client) | GET /usage |
Tomba.Logs.get_logs(client, params \\ %{}) | GET /logs |
Tomba.Domain.domain_search(client, %{"domain" => _}) | GET /domain-search |
Tomba.Finder.email_finder(client, %{"domain" => _, "first_name" => _, "last_name" => _}) | GET /email-finder |
Tomba.Finder.author_finder(client, %{"url" => _}) | GET /author-finder |
Tomba.Finder.linkedin_finder(client, %{"url" => _}) | GET /linkedin |
Tomba.Finder.email_enrichment(client, %{"email" => _}) | GET /enrich |
Tomba.Format.email_format(client, %{"domain" => _}) | GET /email-format |
Tomba.Location.get_location(client, %{"domain" => _}) | GET /location |
Tomba.Count.email_count(client, %{"domain" => _}) | GET /email-count |
Tomba.Verifier.email_verifier(client, %{"email" => _}) | GET /email-verifier |
Tomba.Sources.email_sources(client, %{"email" => _}) | GET /email-sources |
Tomba.Enrichment.person(client, %{"email" => _}) | GET /people/find |
Tomba.Enrichment.company(client, %{"domain" => _}) | GET /companies/find |
Tomba.Enrichment.combined(client, %{"email" => _}) | GET /combined/find |
Tomba.Phone.phone_finder(client, %{"email" => _}) | GET /phone-finder |
Tomba.Phone.phone_validator(client, %{"phone" => _}) | GET /phone-validator |
Tomba.Status.domain_status(client, %{"domain" => _}) | GET /domain-status |
Tomba.Status.domain_suggestions(client, %{"query" => _}) | GET /domain-suggestions |
Tomba.Similar.websites(client, %{"domain" => _}) | GET /similar |
Tomba.Technology.list(client, %{"domain" => _}) | GET /technology |
Tomba.Reveal.companies_search(client, params \\ %{}) | POST /reveal/search |
Tomba.Flag.list_flags(client, params \\ %{}) | GET /flag |
Tomba.Flag.create_flag(client, %{"email" => _}) | POST /flag |
Tomba.Keys.list_keys(client) | GET /keys |
Tomba.Keys.get_key(client, id) | GET /keys/{id} |
Tomba.Keys.create_key(client) | POST /keys |
Tomba.Keys.reset_key(client, id) | PUT /keys/{id} |
Tomba.Keys.delete_key(client, id) | DELETE /keys/{id} |
Tomba.Leads.list_leads(client, params \\ %{}) | GET /leads |
Tomba.Leads.get_lead(client, lead_id) | GET /leads/{id} |
Tomba.Leads.create_lead(client, params) | POST /leads |
Tomba.Leads.update_lead(client, lead_id, params) | PUT /leads/{id} |
Tomba.Leads.delete_lead(client, lead_id) | DELETE /leads/{id} |
Tomba.LeadsLists.list(client) | GET /leads_lists |
Tomba.LeadsLists.get(client, id) | GET /leads_lists/{id} |
Tomba.LeadsLists.create(client, params) | POST /leads_lists |
Tomba.LeadsLists.update(client, id, params) | PUT /leads_lists/{id} |
Tomba.LeadsLists.delete(client, id) | DELETE /leads_lists/{id} |
Tomba.Bulk.list(client, bulk_type, params \\ %{}) | GET /bulk/{type} |
Tomba.Bulk.create(client, bulk_type, params) | POST /bulk/{type} |
Tomba.Bulk.get(client, bulk_type, bulk_id) | GET /bulk/{type}/{id} |
Tomba.Bulk.launch(client, bulk_type, bulk_id) | PUT /bulk/{type}/{id} |
Tomba.Bulk.progress(client, bulk_type, bulk_id) | GET /bulk/{type}/{id}/progress |
Tomba.Bulk.download(client, bulk_type, bulk_id) | GET /bulk/{type}/{id}/download |
Tomba.Bulk.rename(client, bulk_type, bulk_id, name) | PUT /bulk/{type}/{id}/rename |
Tomba.Bulk.archive(client, bulk_type, bulk_id) | DELETE /bulk/{type}/{id}/archive |
Tomba.Bulk.delete(client, bulk_type, bulk_id) | DELETE /bulk/{type}/{id}/delete |
bulk_type is the {type} segment listed in Bulk types (Tomba.Bulk.valid_bulk_types/0 returns them); the order of calls is described in Lifecycle. Tomba.Bulk.create/3 sends a JSON body, so it can't create jobs that need a CSV upload, such as email finder jobs. Tomba.Bulk.download/3 returns the results file, a CSV, as a string in result.data.
Source
github.com/tomba-io/elixir (Apache-2.0).