The client library for Subdomains Lookup API in Go language.
The minimum go version is 1.17.
The library is distributed as a Go module
go get github.com/whois-api-llc/subdomains-lookup-go
Full API documentation available here
You can find all examples in example
directory.
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 := subdomainslookup.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 := subdomainslookup.NewClient(apiKey, subdomainslookup.ClientParams{
HTTPClient: &http.Client{
Transport: transport,
Timeout: 20 * time.Second,
},
})
Subdomains Lookup API lets you get a list of all subdomains related to a given domain name.
// Make request to get all subdomains for the domain name.
subdomainsLookupResp, resp, err := client.Get(ctx, "whoisxmlapi.com")
if err != nil {
log.Fatal(err)
}
for _, obj := range subdomainsLookupResp.Result.Records {
log.Printf("Domain: %s, FirstSeen: %s, LastSeen: %s\n",
obj.Domain,
time.Unix(obj.FirstSeen, 0).Format(time.RFC3339),
time.Unix(obj.LastSeen, 0).Format(time.RFC3339),
)
}
// Make request to get raw data from Subdomains Lookup API.
resp, err := client.GetRaw(context.Background(), "whoisxmlapi.com")
if err != nil {
log.Fatal(err)
}
log.Println(string(resp.Body))