https://github.com/whois-api-llc/domain-discovery-go
Domains & Subdomains Discovery API client library for Go
https://github.com/whois-api-llc/domain-discovery-go
discovery domain go golang subdomain whois whoisxmlapi
Last synced: 10 months ago
JSON representation
Domains & Subdomains Discovery API client library for Go
- Host: GitHub
- URL: https://github.com/whois-api-llc/domain-discovery-go
- Owner: whois-api-llc
- License: mit
- Created: 2022-09-15T13:58:24.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-15T14:03:16.000Z (almost 4 years ago)
- Last Synced: 2025-01-25T21:27:59.222Z (over 1 year ago)
- Topics: discovery, domain, go, golang, subdomain, whois, whoisxmlapi
- Language: Go
- Homepage: https://domains-subdomains-discovery.whoisxmlapi.com/
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://opensource.org/licenses/MIT)
[](https://pkg.go.dev/github.com/whois-api-llc/domain-discovery-go)
[](https://github.com/whois-api-llc/domain-discovery-go/actions/)
# Overview
The client library for
[Domains & Subdomains Discovery API](https://domains-subdomains-discovery.whoisxmlapi.com/)
in Go language.
The minimum go version is 1.17.
# Installation
The library is distributed as a Go module
```bash
go get github.com/whois-api-llc/domain-discovery-go
```
# Examples
Full API documentation available [here](https://domains-subdomains-discovery.whoisxmlapi.com/api/documentation/making-requests)
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](https://whoisxmlapi.com/).
Using the API Key you can create Client.
Most users will be fine with `NewBasicClient` function.
```go
client := domaindiscovery.NewBasicClient(apiKey)
```
If you want to set custom `http.Client` to use proxy then you can use `NewClient` function.
```go
transport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
client := domaindiscovery.NewClient(apiKey, domaindiscovery.ClientParams{
HTTPClient: &http.Client{
Transport: transport,
Timeout: 20 * time.Second,
},
})
```
## Make basic requests
Domains & Subdomains Discovery API lets you find domains and subdomains related by specific terms in their hostnames.
```go
// Make request to get a list of all domains matching the criteria without subdomains.
domainDiscoveryResp, resp, err := client.Get(ctx,
&domaindiscovery.SearchTerms{[]string{"amazon.*"}, nil},
nil)
for _, domainName := range domainDiscoveryResp.DomainsList {
log.Println(domainName)
}
// Make request to get only subdomains matching the criteria.
domainDiscoveryResp, resp, err := client.Get(ctx,
nil,
&domaindiscovery.SearchTerms{[]string{"adidas*"}, []string{"*shoes*"}})
log.Println(domainDiscoveryResp.DomainsCount)
// Make request to get raw data in XML.
resp, err := client.GetRaw(ctx,
&domaindiscovery.SearchTerms{Include: []string{"amazon.com"}, Exclude: nil},
&domaindiscovery.SearchTerms{Include: []string{"aws*"}, Exclude: []string{"*portal*", "*beta*"}},
domaindiscovery.OptionOutputFormat("XML"))
log.Println(string(resp.Body))
```