2.0.0 • Published 2 years ago

available-domains v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

available-domains

Node.js software to detect whether the domain name is available or already taken.

It's fast, stable and provides a simple interface to search through.

Installation

NPM, Yarn or similar is required. Afterwards, you have to install package globally, i.e.:

npm install -g available-domains

Usage

CLI

To find a single or few domains, you may pass them as arguments:

available-domains google.com google.co.uk

Alternatively, you may pass whole file:

available-domains < domains-list.txt

Or pass a result of different command:

cat domains-list.txt | available-domains

The stdout will have only domains line by line, all errors, progress bars etc will land on stderr.

Thanks to that, you may simply stream the results to a different file, while still having all progress information available:

cat domains-list.txt | available-domains > free-domains-list.txt
# or:
available-domains < domains-list.txt > free-domains-list.txt

If you have a lot of domains, and you want to speed up at cost of false-positives, you may use --trust-dns option. It will not be fully accurate, but will be faster.

Usage: available-domains [options] [domains...]

Options:
  -V, --version                                  output the version number
  --concurrency <concurrency>, -c <concurrency>  How many concurrent checks may be performed (default: 30)
  --suffix <suffix>                              Optional suffix(es), helps to add TLDs
  --trust-dns                                    Should it trust ENOTFOUND from DNS (default: false)
  --printTaken, --print-taken, -pt               Should it print taken domains too (with "[T]" prefix) (default: false)
  --timeout <timeout>, -t <timeout>              Timeout for WHOIS connection (ms) (default: 3000)
  --max-retries <maxRetries>, -r <maxRetries>    How many times it may retry rate limited WHOIS query (default: 2)
  --retry-time <retryTime>, -rt <retryTime>      Retry time of WHOIS query when rate limited (ms) (default: 3000)
  --proxy <proxy>, -p <proxy>                    SOCKS Proxy "<ip>:<port>"
  -h, --help                                     Show help information (default: false)

Note:

Because of concurrency, order of results is not guaranteed.

Thanks to piping, you may perform some operations nicely though, i.e.:

cat domains-list.txt | available-domains | sort # Sort alphabetically
cat domains-list.txt | grep -x '.\{0,16\}' | available-domains # Take domains of max 16 characters

Programmatically

There are two functions exposed:

  • isDomainAvailable that returns boolean for specific domain name
  • getAvailableDomains that returns list of available domains (string[]) from provided
const { getAvailableDomains, isDomainAvailable } = require('available-domains');

const result = await isDomainAvailable('google.com');
const list = await getAvailableDomains([ 'google.com', 'google.co.uk' ]);

As the second argument you may provide optional options object.

isDomainAvailable options

NameTypeDescriptionDefault
proxystringSOCKS Proxy ":"null - no proxy
timeoutnumberTimeout for WHOIS connection (ms)3000
maxRetriesnumberHow many times it may retry rate limited WHOIS query2
retryTimenumberRetry time of WHOIS query when rate limited (ms)3000
trustDnsbooleanShould it trust ENOTFOUND from DNSfalse

getAvailableDomains options

It supports same options as isDomainAvailable and additionally:

NameTypeDescriptionDefault
concurrencynumberHow many concurrent checks may be performed30
onStatus(domain: string, available: boolean, finishedCount: number) => voidCallback to immediately get information about each scanned domainnone
onError(domain: string, error: Error, finishedCount: number) => voidCallback to immediately get information about each failed domain scannone

How it works

Firstly, it's resolving DNS for the specified domain. It's cheaper, less limited, but not precise.

If there is an DNS record for that domain, it's immediately treat as taken. Otherwise, WHOIS record is obtained to check it this way.