Documentation
¶
Overview ¶
Package clearbit provides a client for using the Clearbit API.
Usage:
To use one of the Clearbit APIs you'll first need to create a client by calling the NewClient function. By default NewClient will use a new http.Client and will fetch the Clearbit API key from the CLEARBIT_KEY environment variable.
The Clearbit API key can be changed with:
client := clearbit.NewClient(clearbit.WithAPIKey("sk_1234567890123123"))
You can tap another http.Client with:
client := clearbit.NewClient(clearbit.WithHTTPClient(&http.Client{}))
If you use the httpClient just to set the timeout you can instead use WithTimeout:
client := clearbit.NewClient(clearbit.WithTimeout(20 * time.Second))
Both can be combined and the order is not important.
Once the client is created you can use any of the Clearbit APIs
client.Autocomplete client.Company client.Discovery client.Person client.Prospector client.Reveal
Example:
package main
import (
"fmt"
"github.com/clearbit/clearbit-go/clearbit"
)
func main() {
client := clearbit.NewClient(clearbit.WithAPIKey("sk_1234567890123123"))
results, resp, err := client.Reveal.Find(clearbit.RevealFindParams{
IP: "104.193.168.24",
})
if err != nil {
fmt.Println(results, resp)
}
}
See the examples for more details and how to use each API.
Index ¶
- func WithAPIKey(apiKey string) func(*config)
- func WithStream() func(*config)
- func WithTimeout(d time.Duration) func(*config)
- type AutocompleteItem
- type AutocompleteService
- type AutocompleteSuggestParams
- type Client
- type Company
- type CompanyFindParams
- type CompanyService
- type DiscoveryResults
- type DiscoverySearchParams
- type DiscoveryService
- type ErrorDetail
- type ErrorDetailWrapper
- type NameToDomain
- type NameToDomainFindParams
- type NameToDomainService
- type Option
- type Person
- type PersonCompany
- type PersonFindParams
- type PersonService
- type ProspectorResponse
- type ProspectorSearchParams
- type ProspectorService
- type Reveal
- type RevealFindParams
- type RevealService
- type Risk
- type RiskCalculateParams
- type RiskService
Examples ¶
- AutocompleteService.Suggest (Output)
- CompanyService.Find (Output)
- DiscoveryService.Search (Output)
- NameToDomainService.Find (Output)
- NewClient (ManuallyConfiguringEverything_output)
- PersonService.Find (Output)
- PersonService.FindCombined (Output)
- ProspectorService.Search (Output)
- ProspectorService.Search (WithRoles_Output)
- RevealService.Find (Output)
- RiskService.Calculate (Output)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAPIKey ¶
func WithAPIKey(apiKey string) func(*config)
WithAPIKey sets the Clearbit API key.
When this is not provided we'll default to the `CLEARBIT_KEY` environment variable.
func WithStream ¶
func WithStream() func(*config)
func WithTimeout ¶
WithTimeout sets the http timeout
This is just an easier way to set the timeout than directly setting it through the withHTTPClient option.
Types ¶
type AutocompleteItem ¶
type AutocompleteItem struct {
Domain string `json:"domain"`
Logo string `json:"logo"`
Name string `json:"name"`
}
AutocompleteItem represents each of the items returned by a call to Suggest
type AutocompleteService ¶
type AutocompleteService struct {
// contains filtered or unexported fields
}
AutocompleteService gives access to the Autocomplete API.
Company Autocomplete is a free API that lets you auto-complete company names and retrieve logo and domain information.
func (*AutocompleteService) Suggest ¶
func (s *AutocompleteService) Suggest(params AutocompleteSuggestParams) ([]AutocompleteItem, *http.Response, error)
Suggest lets you auto-complete company names and retrieve logo and domain information
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Autocomplete.Suggest(clearbit.AutocompleteSuggestParams{
Query: "clearbit",
})
if err == nil {
fmt.Println(results[0].Domain, resp.Status)
} else {
handleError(err, resp)
}
}
Output: clearbit.com 200 OK
type AutocompleteSuggestParams ¶
type AutocompleteSuggestParams struct {
Query string `url:"query"`
}
AutocompleteSuggestParams wraps the parameters needed to interact with the Autocomplete API
type Client ¶
type Client struct {
Autocomplete *AutocompleteService
Person *PersonService
Company *CompanyService
Discovery *DiscoveryService
Prospector *ProspectorService
Reveal *RevealService
Risk *RiskService
NameToDomain *NameToDomainService
// contains filtered or unexported fields
}
Client is a Clearbit client for making Clearbit API requests.
func NewClient ¶
NewClient returns a new Client.
Example (ManuallyConfiguringEverything_output) ¶
package main
import (
"fmt"
"net/http"
"os"
"time"
"github.com/bviolier/clearbit-go/clearbit"
)
func main() {
var clearbitApiKey = os.Getenv("CLEARBIT_KEY")
client := clearbit.NewClient(
clearbit.WithHTTPClient(&http.Client{}),
clearbit.WithAPIKey(clearbitApiKey),
clearbit.WithTimeout(20*time.Second),
)
_, resp, _ := client.Discovery.Search(clearbit.DiscoverySearchParams{
Query: "name:clearbit",
})
fmt.Println(resp.Status)
}
Output: 200 OK
type Company ¶
type Company struct {
ID string `json:"id"`
Name string `json:"name"`
LegalName string `json:"legalName"`
Domain string `json:"domain"`
DomainAliases []string `json:"domainAliases"`
Site struct {
PhoneNumbers []string `json:"phoneNumbers"`
EmailAddresses []string `json:"emailAddresses"`
} `json:"site"`
Category struct {
Sector string `json:"sector"`
IndustryGroup string `json:"industryGroup"`
Industry string `json:"industry"`
SubIndustry string `json:"subIndustry"`
SicCode string `json:"sicCode"`
NaicsCode string `json:"naicsCode"`
} `json:"category"`
Tags []string `json:"tags"`
Description string `json:"description"`
FoundedYear int `json:"foundedYear"`
Location string `json:"location"`
TimeZone string `json:"timeZone"`
UtcOffset int `json:"utcOffset"`
Geo struct {
StreetNumber string `json:"streetNumber"`
StreetName string `json:"streetName"`
SubPremise string `json:"subPremise"`
City string `json:"city"`
PostalCode string `json:"postalCode"`
State string `json:"state"`
StateCode string `json:"stateCode"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
} `json:"geo"`
Logo string `json:"logo"`
Facebook struct {
Handle string `json:"handle"`
Likes int `json:"likes"`
} `json:"facebook"`
LinkedIn struct {
Handle string `json:"handle"`
} `json:"linkedin"`
Twitter struct {
Handle string `json:"handle"`
ID string `json:"id"`
Bio string `json:"bio"`
Followers int `json:"followers"`
Following int `json:"following"`
Location string `json:"location"`
Site string `json:"site"`
Avatar string `json:"avatar"`
} `json:"twitter"`
Crunchbase struct {
Handle string `json:"handle"`
} `json:"crunchbase"`
EmailProvider bool `json:"emailProvider"`
Type string `json:"type"`
Ticker string `json:"ticker"`
Identifiers struct {
UsEIN string `json:"usEIN"`
} `json:"identifiers"`
Phone string `json:"phone"`
Metrics struct {
AlexaUsRank int `json:"alexaUsRank"`
AlexaGlobalRank int `json:"alexaGlobalRank"`
Employees int `json:"employees"`
EmployeesRange string `json:"employeesRange"`
MarketCap int `json:"marketCap"`
Raised int `json:"raised"`
AnnualRevenue int `json:"annualRevenue"`
EstimatedAnnualRevenue string `json:"estimatedAnnualRevenue"`
FiscalYearEnd int `json:"fiscalYearEnd"`
} `json:"metrics"`
IndexedAt time.Time `json:"indexedAt"`
Tech []string `json:"tech"`
Parent struct {
Domain string `json:"domain"`
} `json:"parent"`
}
Company contains all the company fields gathered from the Company json structure. https://dashboard.clearbit.com/docs#enrichment-api-company-api
type CompanyFindParams ¶
type CompanyFindParams struct {
Domain string `url:"domain,omitempty"`
}
CompanyFindParams wraps the parameters needed to interact with the Company API through the Find method
type CompanyService ¶
type CompanyService struct {
// contains filtered or unexported fields
}
CompanyService gives access to the Company API. https://dashboard.clearbit.com/docs#enrichment-api-company-api
func (*CompanyService) Find ¶
func (s *CompanyService) Find(params CompanyFindParams) (*Company, *http.Response, error)
Find looks up a company based on its domain
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Company.Find(clearbit.CompanyFindParams{
Domain: "clearbit.com",
})
if err == nil {
fmt.Println(results.Name, resp.Status)
} else {
handleError(err, resp)
}
}
Output: Clearbit 200 OK
type DiscoveryResults ¶
type DiscoveryResults struct {
Total int `json:"total"`
Page int `json:"page"`
Results []Company `json:"results"`
}
DiscoveryResults represents each page of companies returned by a call to Search
type DiscoverySearchParams ¶
type DiscoverySearchParams struct {
Page int `url:"page,omitempty"`
PageSize int `url:"page_size,omitempty"`
Limit int `url:"limit,omitempty"`
Sort int `url:"sort,omitempty"`
Query string `url:"query,omitempty"`
}
DiscoverySearchParams wraps the parameters needed to interact with the Discovery API through the Search method
type DiscoveryService ¶
type DiscoveryService struct {
// contains filtered or unexported fields
}
DiscoveryService gives access to the Discovery API.
Our Discovery API lets you search for companies via specific criteria. For example, you could search for all companies with a specific funding, that use a certain technology, or that are similar to your existing customers.
func (*DiscoveryService) Search ¶
func (s *DiscoveryService) Search(params DiscoverySearchParams) (*DiscoveryResults, *http.Response, error)
Search lets you search for companies via specific criteria. For example, you could search for all companies with a specific funding, that use a certain technology, or that are similar to your existing customers.
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Discovery.Search(clearbit.DiscoverySearchParams{
Query: "name:clearbit",
})
if err == nil {
fmt.Println(results.Results[0].Domain, resp.Status)
} else {
handleError(err, resp)
}
}
Output: clearbit.com 200 OK
type ErrorDetail ¶
ErrorDetail represents an individual item in an apiError.
type ErrorDetailWrapper ¶
type ErrorDetailWrapper struct {
Error ErrorDetail `json:"error"`
}
ErrorDetailWrapper is used for single error
type NameToDomain ¶
type NameToDomain struct {
Logo string `json:"logo"`
Name string `json:"string"`
Domain string `json:"domain"`
}
NameToDomain represents the company returned by a call to Find
type NameToDomainFindParams ¶
type NameToDomainFindParams struct {
Name string `url:"name"`
}
NameToDomainFindParams wraps the parameters needed to interact with the NameToDomain API through the Find method
type NameToDomainService ¶
type NameToDomainService struct {
// contains filtered or unexported fields
}
NameToDomainService gives access to the NameToDomain API.
Our NameToDomain API takes a company name, and returns the domain associated with that name.
func (*NameToDomainService) Find ¶
func (s *NameToDomainService) Find(params NameToDomainFindParams) (*NameToDomain, *http.Response, error)
Find takes a company name and returns the domain associated with that name
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
result, resp, err := client.NameToDomain.Find(clearbit.NameToDomainFindParams{
Name: "Uber",
})
if err == nil {
fmt.Println(result.Domain, resp.Status)
} else {
handleError(err, resp)
}
}
Output: uber.com 200 OK
type Option ¶
type Option func(*config)
Option is an option passed to the NewClient function used to change the client configuration
func WithHTTPClient ¶
WithHTTPClient sets the optional http.Client we can use to make requests
type Person ¶
type Person struct {
ID string `json:"id"`
Name struct {
FullName string `json:"fullName"`
GivenName string `json:"givenName"`
FamilyName string `json:"familyName"`
} `json:"name"`
Email string `json:"email"`
Gender string `json:"gender"`
Location string `json:"location"`
TimeZone string `json:"timeZone"`
UTCOffset int `json:"utcOffset"`
Geo struct {
City string `json:"city"`
State string `json:"state"`
StateCode string `json:"stateCode"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
} `json:"geo"`
Bio string `json:"bio"`
Site string `json:"site"`
Avatar string `json:"avatar"`
Employment struct {
Domain string `json:"domain"`
Name string `json:"name"`
Title string `json:"title"`
Role string `json:"role"`
Seniority string `json:"seniority"`
} `json:"employment"`
Facebook struct {
Handle string `json:"handle"`
} `json:"facebook"`
GitHub struct {
Handle string `json:"handle"`
ID int `json:"id"`
Avatar string `json:"avatar"`
Company string `json:"company"`
Blog string `json:"blog"`
Followers int `json:"followers"`
Following int `json:"following"`
} `json:"github"`
Twitter struct {
Handle string `json:"handle"`
ID int `json:"id"`
Bio string `json:"bio"`
Followers int `json:"followers"`
Following int `json:"following"`
Statuses int `json:"statuses"`
Favorites int `json:"favorites"`
Location string `json:"location"`
Site string `json:"site"`
Avatar string `json:"avatar"`
} `json:"twitter"`
LinkedIn struct {
Handle string `json:"handle"`
} `json:"linkedin"`
GooglePlus struct {
Handle string `json:"handle"`
} `json:"googleplus"`
AboutMe struct {
Handle string `json:"handle"`
Bio string `json:"bio"`
Avatar string `json:"avatar"`
} `json:"aboutme"`
Gravatar struct {
Handle string `json:"handle"`
Urls []struct {
URL string `json:"url"`
Type string `json:"type"`
} `json:"urls"`
Avatar string `json:"avatar"`
Avatars []struct {
URL string `json:"url"`
Type string `json:"type"`
} `json:"avatars"`
} `json:"gravatar"`
Fuzzy bool `json:"fuzzy"`
EmailProvider bool `json:"emailProvider"`
IndexedAt time.Time `json:"indexedAt"`
}
Person contains all the person fields gathered from the Person json structure. https://dashboard.clearbit.com/docs#enrichment-api-person-api
type PersonCompany ¶
PersonCompany represents the item returned by a call to FindCombined. It joins the Person and Company structure.
type PersonFindParams ¶
type PersonFindParams struct {
Email string `url:"email,omitempty"`
}
PersonFindParams wraps the parameters needed to interact with the Person API through the Find method
type PersonService ¶
type PersonService struct {
// contains filtered or unexported fields
}
PersonService gives access to the Person API. https://dashboard.clearbit.com/docs#enrichment-api-person-api
func (*PersonService) Find ¶
func (s *PersonService) Find(params PersonFindParams) (*Person, *http.Response, error)
Find looks up a person based on a email address
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Person.Find(clearbit.PersonFindParams{
Email: "alex@clearbit.com",
})
if err == nil {
fmt.Println(results.Name.FullName, resp.Status)
} else {
handleError(err, resp)
}
}
Output: Alex MacCaw 200 OK
func (*PersonService) FindCombined ¶
func (s *PersonService) FindCombined(params PersonFindParams) (*PersonCompany, *http.Response, error)
FindCombined looks up a person and company simultaneously based on a email address
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Person.FindCombined(clearbit.PersonFindParams{
Email: "alex@clearbit.com",
})
if err == nil {
fmt.Println(results.Person.Name.FullName, results.Company.Name, resp.Status)
} else {
handleError(err, resp)
}
}
Output: Alex MacCaw Clearbit 200 OK
type ProspectorResponse ¶
type ProspectorResponse struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
Total int `json:"total"`
Results []struct {
ID string `json:"id"`
Name struct {
FullName string `json:"fullName"`
GivenName string `json:"givenName"`
FamilyName string `json:"familyName"`
} `json:"name"`
Title string `json:"title"`
Role string `json:"role"`
Seniority string `json:"seniority"`
Company struct {
Name string `json:"name"`
} `json:"company"`
Email string `json:"email"`
Location string `json:"location"`
Phone string `json:"phone"`
Verified bool `json:"verified"`
} `json:"results"`
}
type ProspectorSearchParams ¶
type ProspectorSearchParams struct {
Domain string `url:"domain,omitempty"`
Role string `url:"role,omitempty"`
Roles []string `url:"roles[],omitempty"`
Seniority string `url:"seniority,omitempty"`
Seniorities []string `url:"seniorities[],omitempty"`
Title string `url:"title,omitempty"`
Titles []string `url:"titles[],omitempty"`
City string `url:"city,omitempty"`
Cities []string `url:"cities[],omitempty"`
State string `url:"state,omitempty"`
States []string `url:"states[],omitempty"`
Country string `url:"country,omitempty"`
Countries []string `url:"countries[],omitempty"`
Name string `url:"name,omitempty"`
Page int `url:"page,omitempty"`
PageSize int `url:"page_size,omitempty"`
}
ProspectorSearchParams wraps the parameters needed to interact with the Prospector API
type ProspectorService ¶
type ProspectorService struct {
// contains filtered or unexported fields
}
ProspectorService gives access to the Prospector API.
The Prospector API lets you fetch contacts and emails associated with a company, employment role, seniority, and job title.
func (*ProspectorService) Search ¶
func (s *ProspectorService) Search(params ProspectorSearchParams) (ProspectorResponse, *http.Response, error)
Search lets you fetch contacts and emails associated with a company, employment role, seniority, and job title.
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Prospector.Search(clearbit.ProspectorSearchParams{
Domain: "clearbit.com",
})
if err == nil {
fmt.Println(results.Results[0].Email, resp.Status)
} else {
handleError(err, resp)
}
}
Output: alex@clearbit.com 200 OK
Example (WithRoles_Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Prospector.Search(clearbit.ProspectorSearchParams{
Domain: "clearbit.com",
Roles: []string{"sales", "engineering"},
})
if err == nil {
fmt.Println(len(results.Results), resp.Status)
} else {
handleError(err, resp)
}
}
Output: 5 200 OK
type Reveal ¶
type Reveal struct {
IP string `json:"ip"`
Fuzzy bool `json:"fuzzy"`
Domain string `json:"domain"`
Company Company
}
Reveal reprents the company returned by a call to Find
type RevealFindParams ¶
type RevealFindParams struct {
IP string `url:"ip,omitempty"`
}
RevealFindParams wraps the parameters needed to interact with the Reveal API through the Find method
type RevealService ¶
type RevealService struct {
// contains filtered or unexported fields
}
RevealService gives access to the Reveal API.
Our Reveal API takes an IP address, and returns the company associated with that IP.
func (*RevealService) Find ¶
func (s *RevealService) Find(params RevealFindParams) (*Reveal, *http.Response, error)
Find takes an IP address, and returns the company associated with that IP
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Reveal.Find(clearbit.RevealFindParams{
IP: "104.193.168.24",
})
if err == nil {
fmt.Println(results.Company.Name, resp.Status)
} else {
handleError(err, resp)
}
}
Output: Clearbit 200 OK
type Risk ¶
type Risk struct {
ID string `json:"id"`
Live bool `json:"live"`
Email struct {
Valid bool `json:"valid"`
SocialMatch bool `json:"socialMatch"`
CompanyMatch bool `json:"companyMatch"`
NameMatch bool `json:"nameMatch"`
Disposable bool `json:"disposable"`
FreeProvider bool `json:"freeProvider"`
Blacklisted bool `json:"blacklisted"`
} `json:"email"`
Address struct {
GeoMatch interface{} `json:"geoMatch"`
} `json:"address"`
IP struct {
Proxy bool `json:"proxy"`
GeoMatch interface{} `json:"geoMatch"`
Blacklisted bool `json:"blacklisted"`
RateLimited interface{} `json:"rateLimited"`
} `json:"ip"`
Risk struct {
Level string `json:"level"`
Score int `json:"score"`
Reasons []string `json:"reasons"`
} `json:"risk"`
}
Risk represents the risk score returned by a call to Calculate
type RiskCalculateParams ¶
type RiskCalculateParams struct {
Email string `url:"email,omitempty"`
IP string `url:"ip,omitempty"`
CountryCode string `url:"country_code,omitempty"`
ZipCode string `url:"zip_code,omitempty"`
GivenName string `url:"given_name,omitempty"`
FamilyName string `url:"family_name,omitempty"`
Name string `url:"name,omitempty"`
}
RiskCalculateParams wraps the parameters needed to interact with the Risk API through the Calculate method
type RiskService ¶
type RiskService struct {
// contains filtered or unexported fields
}
RiskService gives access to the Risk API.
Our Risk API takes an email address, an IP address, and additional information before returning a risk analysis for the user
func (*RiskService) Calculate ¶
func (s *RiskService) Calculate(params RiskCalculateParams) (*Risk, *http.Response, error)
Find takes an email address, and an IP address, and returns the risk associated with that user
Example (Output) ¶
package main
import (
"fmt"
"net/http"
"github.com/bviolier/clearbit-go/clearbit"
)
func handleError(err error, resp *http.Response) {
fmt.Printf("%#v\n%s\n", err, resp.Status)
}
func main() {
client := clearbit.NewClient()
results, resp, err := client.Risk.Calculate(clearbit.RiskCalculateParams{
Email: "alex@clearbit.com",
Name: "Alex MacCaw",
IP: "127.0.0.1",
})
if err == nil {
fmt.Println(results.Risk.Score, resp.Status)
} else {
handleError(err, resp)
}
}
Output: 0 200 OK