Go SDK
github.com/tomba-io/go is the official Go client for the Tomba API. All methods hang off one client value, and each method sends one request.
Requirements
Go 1.18 or later, as declared in go.mod. The module has no third-party dependencies.
Install
Code
Import the github.com/tomba-io/go/tomba package.
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.New(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
Most methods decode the response body into a type from the github.com/tomba-io/go/tomba/models package; the keys, leads, lists, attributes, and flag methods return the raw body as json.RawMessage. models.Finder.Data is an interface{}, so assert it to a map before reading fields.
tomba.Params is a map[string]interface{}. On GET requests only string, int, and bool values are sent, and empty strings and zero integers are skipped.
Errors
Every method returns an error when the request fails or the API responds with a status other than 200 or 201. The error text holds only the HTTP status, for example error: 400 Bad Request, status code: 400. The SDK discards the response body, so the API's errors.type and errors.message aren't available; the causes behind each status are listed in Errors.
Code
PersonFind, CompanyFind, and CombinedFind don't return an error when nothing is found: those endpoints answer with status 200 and an errors body, which doesn't fit the result model, so the model comes back empty.
Rate limits and retries
The SDK doesn't retry. After every response, including failed ones, the client stores the rate limit headers in client.LastRateLimit, a tomba.RateLimit with the fields SecondLimit, MinuteLimit, DailyLimit, MinuteRemaining, DailyRemaining, MinuteReset, DailyReset, RetryAfter, Policy, and RateLimit. A header that is absent reads as 0. Each call overwrites the field, so read it right after the call, and don't rely on it when one client sends requests from several goroutines. tomba.ParseRateLimit(*http.Response) parses the same headers from any response.
RetryAfter is set only on a 429. Wait at least that long, as described in Handle 429 responses.
Requests time out after 120 seconds; the timeout isn't configurable.
Method reference
All methods are on *tomba.Tomba, the value returned by tomba.New. Result types are in the models package.
| Method | Endpoint |
|---|---|
Account() (models.Account, error) | GET /me |
Logs(params ...Params) (models.Logs, error) | GET /logs |
DomainSearch(params Params) (models.Search, error) | GET /domain-search |
EmailFinder(params Params) (models.Finder, error) | GET /email-finder |
AuthorFinder(params Params) (models.Finder, error) | GET /author-finder |
LinkedinFinder(params Params) (models.Finder, error) | GET /linkedin |
Enrichment(params Params) (models.Finder, error) | GET /enrich |
EmailFormat(domain string) (models.Format, error) | GET /email-format |
EmployeesCount(domain string) (models.Employees, error) | GET /location |
Count(domain string) (models.Count, error) | GET /email-count |
EmailVerifier(params Params) (models.Verifier, error) | GET /email-verifier |
Sources(email string) (models.Source, error) | GET /email-sources |
PersonFind(params Params) (models.PersonResponse, error) | GET /people/find |
CompanyFind(params Params) (models.CompanyResponse, error) | GET /companies/find |
CombinedFind(params Params) (models.CombinedResponse, error) | GET /combined/find |
PhoneFinder(params Params) (models.Phone, error) | GET /phone-finder |
PhoneValidator(params Params) (models.PhoneValidator, error) | GET /phone-validator |
Status(domain string) (models.Status, error) | GET /domain-status |
AutoComplete(query string) (models.DomainSuggestions, error) | GET /domain-suggestions |
SimilarDomains(domain string) (models.Similar, error) | GET /similar |
TechnologyCheck(domain string) (models.Technology, error) | GET /technology |
SearchCompanies(request *models.RevealSearchRequest) (models.RevealSearchResponse, error) | POST /reveal/search |
ListFlags(params Params) (json.RawMessage, error) | GET /flag |
CreateFlag(params Params) (json.RawMessage, error) | POST /flag |
ListKeys() (json.RawMessage, error) | GET /keys |
GetKey(id string) (json.RawMessage, error) | GET /keys/{id} |
CreateKey(params Params) (json.RawMessage, error) | POST /keys |
DeleteKey(id string) (json.RawMessage, error) | DELETE /keys/{id} |
ListLeads(params Params) (json.RawMessage, error) | GET /leads |
GetLead(id string) (json.RawMessage, error) | GET /leads/{id} |
CreateLead(params Params) (json.RawMessage, error) | POST /leads |
UpdateLead(id string, params Params) (json.RawMessage, error) | PUT /leads/{id} |
DeleteLead(id string) (json.RawMessage, error) | DELETE /leads/{id} |
ListLeadsLists(params Params) (json.RawMessage, error) | GET /leads_lists |
GetLeadsList(id string) (json.RawMessage, error) | GET /leads_lists/{id} |
CreateLeadsList(params Params) (json.RawMessage, error) | POST /leads_lists |
UpdateLeadsList(id string, params Params) (json.RawMessage, error) | PUT /leads_lists/{id} |
DeleteLeadsList(id string) (json.RawMessage, error) | DELETE /leads_lists/{id} |
ListAttributes(params Params) (json.RawMessage, error) | GET /attributes |
GetAttribute(id string) (json.RawMessage, error) | GET /attributes/{id} |
CreateAttribute(params Params) (json.RawMessage, error) | POST /attributes |
UpdateAttribute(id string, params Params) (json.RawMessage, error) | PUT /attributes/{id} |
DeleteAttribute(id string) (json.RawMessage, error) | DELETE /attributes/{id} |
GetAllBulks(bulkType models.BulkType, params *models.BulkGetParams) (*models.BulkListResponse, error) | GET /bulk/{type} |
CreateBulk(bulkType models.BulkType, params *models.BulkCreateParams) (*models.BulkCreateResponse, error) | POST /bulk/{type} |
CreateSearchBulk(params *models.BulkSearchCreateParams) (*models.BulkCreateResponse, error) | POST /bulk/search |
GetBulk(bulkType models.BulkType, id int64) (*models.BulkDetailResponse, error) | GET /bulk/{type}/{id} |
LaunchBulk(bulkType models.BulkType, id int64) (*models.BulkSuccessResponse, error) | PUT /bulk/{type}/{id} |
GetBulkProgress(bulkType models.BulkType, id int64) (*models.BulkProgress, error) | GET /bulk/{type}/{id}/progress |
DownloadBulk(bulkType models.BulkType, id int64, params *models.BulkDownloadParams) ([]byte, error) | GET /bulk/{type}/{id}/download |
SaveBulkResults(bulkType models.BulkType, id int64, filePath string, downloadType string) error | GET /bulk/{type}/{id}/download |
RenameBulk(bulkType models.BulkType, id int64, params *models.BulkRenameParams) (*models.BulkSuccessResponse, error) | PUT /bulk/{type}/{id}/rename |
ArchiveBulk(bulkType models.BulkType, id int64) (*models.BulkSuccessResponse, error) | DELETE /bulk/{type}/{id}/archive |
DeleteBulk(bulkType models.BulkType, id int64) (*models.BulkSuccessResponse, error) | DELETE /bulk/{type}/{id}/delete |
models.BulkType has one constant per bulk type, from models.BulkTypeSearch to models.BulkTypePhoneValidator; the order of calls is described in Lifecycle. GetAllSearchBulks, GetAllFinderBulks, and the other GetAll…Bulks(params) methods call GetAllBulks for one type. SaveBulkResults downloads the results and writes them to filePath.
Source
github.com/tomba-io/go (Apache-2.0). Release notes are in CHANGELOG.md.