README
¶
Overview
The client library for Website Contacts API in Go language.
The minimum go version is 1.17.
Installation
The library is distributed as a Go module
go get github.com/whois-api-llc/website-contacts-go
Examples
Full API documentation available here
You can find all examples in example
directory.
Create a new client
To start making requests you need the API Key. You can find it on your profile page on whoisxmlapi.com. Using the API Key you can create Client.
Most users will be fine with NewBasicClient
function.
client := websitecontacts.NewBasicClient(apiKey)
If you want to set custom http.Client
to use proxy then you can use NewClient
function.
transport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
client := websitecontacts.NewClient(apiKey, simplegeoip.ClientParams{
HTTPClient: &http.Client{
Transport: transport,
Timeout: 20 * time.Second,
},
})
Make basic requests
Website Contacts API lets you get well-structured domain owner contact information, including company name and key contacts with direct-dial phone numbers, email addresses, and social media links.
// Make request to get parsed Website Contacts API response for the domain name
wContactsResp, resp, err := client.Get(ctx, "whoisxmlapi.com")
if err != nil {
log.Fatal(err)
}
log.Println(wContactsResp.DomainName)
log.Println(wContactsResp.Emails)
// Make request to get raw Website Contacts API data
resp, err := client.WContactsService.GetRaw(context.Background(), "whoisxmlapi.com")
if err != nil {
log.Fatal(err)
}
log.Println(string(resp.Body))
Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // WContactsService is an interface for Website Contacts API WContactsService // contains filtered or unexported fields }
Client is the client for Website Contacts API services.
func NewBasicClient ¶
NewBasicClient creates Client with recommended parameters.
func NewClient ¶
func NewClient(apiKey string, params ClientParams) *Client
NewClient creates Client with specified parameters.
type ClientParams ¶
type ClientParams struct { // HTTPClient is the client used to access API endpoint // If it's nil then value API client uses http.DefaultClient HTTPClient *http.Client // WContactsBaseURL is the endpoint for 'Website Contacts API' service WContactsBaseURL *url.URL }
ClientParams is used to create Client. None of parameters are mandatory and leaving this struct empty works just fine for most cases.
type ErrorMessage ¶
ErrorMessage is an error message.
func (ErrorMessage) Error ¶
func (e ErrorMessage) Error() string
Error returns error message as a string.
type ErrorResponse ¶
ErrorResponse is returned when the response status code is not 2xx.
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
Error returns error message as a string.
type Option ¶
Option adds parameters to the query.
func OptionHardRefresh ¶
OptionHardRefresh sets the parameter for demanding the website contacts information from scratch.
func OptionOutputFormat ¶
OptionOutputFormat sets Response output format JSON | XML. Default: JSON.
type Phones ¶
type Phones struct { PhoneNumber string `json:"phoneNumber"` Description string `json:"description"` CallHours string `json:"callHours"` }
Phones is the list of phone numbers with description and call hours.
type Response ¶
type Response struct { *http.Response // Body is the byte slice representation of http.Response Body Body []byte }
Response is the http.Response wrapper with Body saved as a byte slice.
type SocialLinks ¶
type SocialLinks struct { Facebook string `json:"facebook"` Instagram string `json:"instagram"` LinkedIn string `json:"linkedIn"` Twitter string `json:"twitter"` }
SocialLinks is the Facebook/Instagram/LinkedIn/Twitter URLs found on the main website's page.
type WContactsResponse ¶
type WContactsResponse struct { // DomainName is a domain name. DomainName string `json:"domainName"` // WebsiteResponded Determines if the website was active during the crawling. WebsiteResponded bool `json:"websiteResponded"` // Meta is the metadata defined in the title and description meta tag on the main page. Meta Meta `json:"meta"` // CountryCode is the Website country (ISO-3166). CountryCode string `json:"countryCode"` // CompanyNames is the list of possible company names. CompanyNames []string `json:"companyNames"` // Emails is the list of email addresses with description. Emails []Emails `json:"emails"` // Phones is the list of phone numbers with description and call hours. Phones []Phones `json:"phones"` // PostalAddresses is the list of postal addresses. Every address is presented in the format of: // street, city, state, zip code, country. Some positions may be missing. PostalAddresses []string `json:"postalAddresses"` // SocialLinks is the Facebook/Instagram/LinkedIn/Twitter URLs found on the main website's page. SocialLinks SocialLinks `json:"socialLinks"` }
WContactsResponse is a response of Website Contacts API.
type WContactsService ¶
type WContactsService interface { // Get returns parsed Website Contacts API response Get(ctx context.Context, domainName string, opts ...Option) (*WContactsResponse, *Response, error) // GetRaw returns raw Website Contacts API response as Response struct with Body saved as a byte slice GetRaw(ctx context.Context, domainName string, opts ...Option) (*Response, error) }
WContactsService is an interface for Website Contacts API.