npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

whoisxmlapi

v2.2.0

Published

Client for whoisxmlapi.com, with JSON results!

Downloads

24

Readme

A client for https://whoisxmlapi.com, that returns results in JSON.

The whoisxmlapi is a non-REST HTTP API, ie, it's not very good.

  • GET is used to change things
  • Resources aren't endpoints, instead the same resource is accessed by different query parameters to do very different things
  • Credentials are insecurely sent in query strings rather than headers (these can leak into caches etc)
  • JSON is sent with incorrect content encoding
  • Numbers are sent as Strings
  • Booleans are sent as Numbers

However, whoisxmlapi works reliably. Other services I've tried (particularly https://jsonwhois.com) sporadically gave 500 errors and staff didn't respond in a reasonable time about fixing them.

Hence writing this module to:

  • a) help me use the service
  • b) save you the trouble of working around the oddness described above

Now requires node 8

This library now uses async/awaitfrom node 8. This means you can await results from your whois tests without callbacks.

const result = await whois.lookup('google.com')

Use v1 if you really like callbacks.

Installation

npm install whoisxmlapi

Usage

Just:

var whois = require('whoisxmlapi')(username, password, options);

Where:

  • username and password are Strings and mandatory
  • options is an Object and optional.

Options

  • cacheMaxItems - how many whois results to keep in the cache.

That's all for now.

Basic whois lookup

const result = await whois.lookup('google.com')
console.log(JSON.stringify(result, null, 2))

Returns the following results:

{
	"WhoisRecord": {
		"createdDate": "1997-09-15T00:00:00-0700",
		"updatedDate": "2015-06-12T10:38:52-0700",
		"expiresDate": "2020-09-13T21:00:00-0700",
		"registrant": {
			"name": "Dns Admin",
			"organization": "Google Inc.",
			"street1": "Please contact [email protected], 1600 Amphitheatre Parkway",
			"city": "Mountain View",
			"state": "CA",
			"postalCode": "94043",
			"country": "UNITED STATES",
			"email": "[email protected]",
			"telephone": "16502530000",
			"fax": "16506188571",
			"rawText": "Registrant Name: Dns Admin\nRegistrant Organization: Google Inc.\nRegistrant Street: Please contact [email protected], 1600 Amphitheatre Parkway\nRegistrant City: Mountain View\nRegistrant State/Province: CA\nRegistrant Postal Code: 94043\nRegistrant Country: US\nRegistrant Phone: +1.6502530000\nRegistrant Fax: +1.6506188571\nRegistrant Email: [email protected]"
		},
		"administrativeContact": {
			"name": "DNS Admin",
			"organization": "Google Inc.",
			"street1": "1600 Amphitheatre Parkway",
			"city": "Mountain View",
			"state": "CA",
			"postalCode": "94043",
			"country": "UNITED STATES",
			"email": "[email protected]",
			"telephone": "16506234000",
			"fax": "16506188571",
			"rawText": "Admin Name: DNS Admin\nAdmin Organization: Google Inc.\nAdmin Street: 1600 Amphitheatre Parkway\nAdmin City: Mountain View\nAdmin State/Province: CA\nAdmin Postal Code: 94043\nAdmin Country: US\nAdmin Phone: +1.6506234000\nAdmin Fax: +1.6506188571\nAdmin Email: [email protected]"
		},
		"technicalContact": {
			"name": "DNS Admin",
			"organization": "Google Inc.",
			"street1": "2400 E. Bayshore Pkwy",
			"city": "Mountain View",
			"state": "CA",
			"postalCode": "94043",
			"country": "UNITED STATES",
			"email": "[email protected]",
			"telephone": "16503300100",
			"fax": "16506181499",
			"rawText": "Tech Name: DNS Admin\nTech Organization: Google Inc.\nTech Street: 2400 E. Bayshore Pkwy\nTech City: Mountain View\nTech State/Province: CA\nTech Postal Code: 94043\nTech Country: US\nTech Phone: +1.6503300100\nTech Fax: +1.6506181499\nTech Email: [email protected]"
		},
		"domainName": "google.com",
		"nameServers": {
			"rawText": "ns1.google.com\nns3.google.com\nns2.google.com\nns4.google.com\n",
			"hostNames": [
				"ns1.google.com",
				"ns3.google.com",
				"ns2.google.com",
				"ns4.google.com"
			],
			"ips": []
		}
		(cut for brevity)
	}
}

Domains that do not have whois

If a domain does not have whois, the result will be null

const result = await whois.lookup('register.bs')

Returns

null

Getting account balance

const result = await whois.getAccountBalance()
console.log(JSON.stringify(result, null, 2))

Returns the following results:

{
	"balance": "4910",
	"reserve": "5100",
	"monthly_balance": null,
	"monthly_reserve": null,
	"reverse_whois_balance": null,
	"reverse_whois_reserve": null,
	"reverse_whois_monthly_balance": null,
	"reverse_whois_monthly_reserve": null,
	"ba_query_balance": null,
	"ba_query_reserve": null,
	"ra_query_balance": null,
	"ra_query_reserve": null,
	"ds_query_balance": null,
	"ds_query_reserve": null,
	"reverse_ip_balance": null,
	"reverse_ip_reserve": null,
	"reverse_ip_monthly_balance": null,
	"reverse_ip_monthly_reserve": null
}

Setting warning threshhold

const result = whois.setWarnThreshold(500, true, true)
console.log(JSON.stringify(result, null, 2))

Returns the following results:

{
	"balance": "4910",
	"reserve": "5100",
	"monthly_balance": null,
	"monthly_reserve": null,
	"warn_threshold": "500",
	"warn_threshold_enabled": "\u0001",
	"warn_empty_enabled": "\u0001",
	"reverse_whois_balance": null,
	"reverse_whois_reserve": null,
	"reverse_whois_monthly_balance": null,
	"reverse_whois_monthly_reserve": null,
	"ba_query_balance": null,
	"ba_query_reserve": null,
	"ra_query_balance": null,
	"ra_query_reserve": null,
	"ds_query_balance": null,
	"ds_query_reserve": null,
	"reverse_ip_balance": null,
	"reverse_ip_reserve": null,
	"reverse_ip_monthly_balance": null,
	"reverse_ip_monthly_reserve": null
}

Running the integration tests

Tests expect a config.js file in the module dir or a parent dir with the following contents:

'whoisxmlapi': {
	// From https://www.whoisxmlapi.com/user/management.php
	'username': 'some-username',
	'password': 'some-password',
}

Then run:

mocha

To execute the tests