clearbit-go: github.com/clearbit/clearbit-go/clearbit Index | Examples | Files

package clearbit

import "github.com/clearbit/clearbit-go/clearbit"

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

Examples

Package Files

autocomplete.go clearbit.go company.go discovery.go doc.go errors.go name_to_domain.go person.go prospector.go reveal.go risk.go

func WithAPIKey Uses

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 WithTimeout Uses

func WithTimeout(d time.Duration) func(*config)

WithTimeout sets the http timeout

This is just an easier way to set the timeout than directly setting it through the withHTTPClient option.

type AutocompleteItem Uses

type AutocompleteItem struct {
    Domain string `json:"domain"`
       string `json:"logo"`
    Name   string `json:"name"`
}

AutocompleteItem represents each of the items returned by a call to Suggest

type AutocompleteService Uses

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 Uses

func (s *AutocompleteService) Suggest(params AutocompleteSuggestParams) ([]AutocompleteItem, *http.Response, error)

Suggest lets you auto-complete company names and retrieve logo and domain information

Code:

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 Uses

type AutocompleteSuggestParams struct {
    Query string `url:"query"`
}

AutocompleteSuggestParams wraps the parameters needed to interact with the Autocomplete API

type Client Uses

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 Uses

func NewClient(options ...Option) *Client

NewClient returns a new Client.

type Company Uses

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"`
         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 Uses

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 Uses

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 Uses

func (s *CompanyService) Find(params CompanyFindParams) (*Company, *http.Response, error)

Find looks up a company based on its domain

Code:

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 Uses

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 Uses

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 Uses

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 Uses

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.

Code:

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 Uses

type ErrorDetail struct {
    Type    string `json:"type"`
    Message string `json:"message"`
}

ErrorDetail represents an individual item in an apiError.

type ErrorDetailWrapper Uses

type ErrorDetailWrapper struct {
    Error ErrorDetail `json:"error"`
}

ErrorDetailWrapper is used for single error

type NameToDomain Uses

type NameToDomain struct {
       string `json:"logo"`
    Name   string `json:"string"`
    Domain string `json:"domain"`
}

NameToDomain represents the company returned by a call to Find

type NameToDomainFindParams Uses

type NameToDomainFindParams struct {
    Name string `url:"name"`
}

NameToDomainFindParams wraps the parameters needed to interact with the NameToDomain API through the Find method

type NameToDomainService Uses

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 Uses

func (s *NameToDomainService) Find(params NameToDomainFindParams) (*NameToDomain, *http.Response, error)

Find takes a company name and returns the domain associated with that name

Code:

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 Uses

type Option func(*config)

Option is an option passed to the NewClient function used to change the client configuration

func WithHTTPClient Uses

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets the optional http.Client we can use to make requests

type Person Uses

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 Uses

type PersonCompany struct {
    Person  Person  `json:"person"`
    Company Company `json:"company"`
}

PersonCompany represents the item returned by a call to FindCombined. It joins the Person and Company structure.

type PersonFindParams Uses

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 Uses

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 Uses

func (s *PersonService) Find(params PersonFindParams) (*Person, *http.Response, error)

Find looks up a person based on a email address

Code:

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 Uses

func (s *PersonService) FindCombined(params PersonFindParams) (*PersonCompany, *http.Response, error)

FindCombined looks up a person and company simultaneously based on a email address

Code:

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 Uses

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 Uses

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 Uses

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 Uses

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.

Code:

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

type Reveal Uses

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 Uses

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 Uses

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 Uses

func (s *RevealService) Find(params RevealFindParams) (*Reveal, *http.Response, error)

Find takes an IP address, and returns the company associated with that IP

Code:

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 Uses

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 Uses

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 Uses

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 Uses

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

Code:

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

Package clearbit imports 6 packages (graph). Updated 2019-04-06. Refresh now. Tools for package owners.