### Node WHOIS CLI Usage Examples Source: https://context7.com/furqansoftware/node-whois/llms.txt When installed globally, the `whois` binary exposes library options as flags for various lookups and configurations. Examples include simple domain/IP lookups, specifying servers, following redirects, verbose output, proxy usage, local interface binding, and setting timeouts. ```bash # Simple domain lookup whois google.com ``` ```bash # IP address lookup whois 8.8.8.8 ``` ```bash # Use a specific WHOIS server whois -s whois.tucows.com tucows.com ``` ```bash # Follow up to 3 redirects whois -f 3 example.com ``` ```bash # Show responses from every server in the redirect chain (verbose) whois -v google.com ``` ```bash # Route through a SOCKS5 proxy whois -p 127.0.0.1:1080 google.com ``` ```bash # Bind outgoing connection to a specific local interface whois -b 192.168.1.50 example.com ``` ```bash # Set a 10-second socket timeout whois -t 10000 example.com ``` ```bash # Show help whois -h ``` -------------------------------- ### Install Node WHOIS Globally Source: https://github.com/furqansoftware/node-whois/blob/master/README.md Install the Node WHOIS client globally for command-line usage. This allows you to run `whois` commands directly from your terminal. ```bash npm install -g whois ``` -------------------------------- ### Install Node WHOIS Locally Source: https://github.com/furqansoftware/node-whois/blob/master/README.md Install the Node WHOIS package locally for use within your Node.js projects. This is the standard method for project dependencies. ```bash npm install whois ``` -------------------------------- ### Perform WHOIS Lookup in Node.js Source: https://github.com/furqansoftware/node-whois/blob/master/README.md Basic usage of the `whois.lookup` function in Node.js. Requires the `whois` module to be installed and required. ```javascript var whois = require('whois') whois.lookup('google.com', function(err, data) { console.log(data) }) ``` -------------------------------- ### Verbose WHOIS Lookup Source: https://context7.com/furqansoftware/node-whois/llms.txt Enable verbose mode to get raw WHOIS text from all servers in the redirect chain. Each response includes the server hostname and its raw data. ```javascript import whois from 'whois'; whois.lookup('google.com', { verbose: true }, (err, results) => { if (err) return console.error(err); results.forEach(({ server, data }) => { console.log(`\n=== Response from: ${server} ===`); console.log(data); }); }); ``` -------------------------------- ### Node WHOIS Command-Line Usage Source: https://github.com/furqansoftware/node-whois/blob/master/README.md Basic command-line syntax for the Node WHOIS client. Use `whois [options] address` to perform lookups. ```bash whois [options] address ``` -------------------------------- ### Configure WHOIS Lookup Options Source: https://github.com/furqansoftware/node-whois/blob/master/README.md An object can be passed to `whois.lookup` to customize its behavior. Options include specifying a WHOIS server, following redirects, setting timeouts, and enabling verbose output. ```javascript { "server": "", // this can be a string ("host:port") or an object with host and port as its keys; leaving it empty makes lookup rely on servers.json "follow": 2, // number of times to follow redirects "timeout": 0, // socket timeout, excluding this doesn't override any default timeout value "verbose": false // setting this to true returns an array of responses from all servers "bind": null // bind the socket to a local IP address "proxy": { // (optional) SOCKS Proxy "host": "", "port": 0, "type": 5 // or 4 } } ``` -------------------------------- ### `lookup` with `follow` option — Control WHOIS redirect depth Source: https://context7.com/furqansoftware/node-whois/llms.txt Controls how many times the library will automatically chase referral servers (e.g., from a TLD registry to a registrar). The `follow` option defaults to 2. ```APIDOC ## lookup with `follow` option ### Description WHOIS responses from top-level registry servers often contain a `Registrar WHOIS Server` field pointing to a more detailed registrar-level server. The `follow` option sets how many times the library will automatically chase these referrals. The default is 2. ### Parameters #### Request Body - **follow** (number) - Optional - The maximum number of referral hops to follow (default: 2). - `0`: Only query the initial TLD registry server, no redirects. - `1`: Follow one referral (e.g., registry → registrar). - `2` (default): Follow up to two hops for the most detailed response. ### Request Example ```javascript import whois from 'whois'; // follow: 0 — only query the TLD registry server, no redirects whois.lookup('google.com', { follow: 0 }, (err, data) => { if (err) return console.error(err); // data comes from whois.verisign-grs.com only console.log(data); }); // follow: 1 — follow one referral (registry → registrar) whois.lookup('google.com', { follow: 1 }, (err, data) => { if (err) return console.error(err); // data comes from whois.markmonitor.com (Google's registrar) console.log(data); }); // Default follow: 2 — follows up to two hops automatically whois.lookup('example.com', (err, data) => { if (err) return console.error(err); console.log(data); // most detailed response available }); ``` ``` -------------------------------- ### `lookup(addr, [options], callback)` — Query WHOIS data for a domain or IP Source: https://context7.com/furqansoftware/node-whois/llms.txt Performs a WHOIS lookup for the given address. Automatically resolves the correct upstream server from `servers.json` unless an explicit `server` option is provided. The callback receives `(err, data)`, where `data` is a plain string or an array of `{ server, data }` objects if `verbose: true`. ```APIDOC ## lookup(addr, [options], callback) ### Description Performs a WHOIS lookup for the given address (domain name or IP). Automatically resolves the correct upstream server from `servers.json` unless an explicit `server` option is provided. The callback receives `(err, data)`, where `data` is a plain string or an array of `{ server, data }` objects if `verbose: true`. ### Parameters #### Path Parameters - **addr** (string) - Required - The domain name or IP address to look up. - **options** (object) - Optional - Configuration options for the lookup. - **server** (string | object) - Optional - Specifies a custom WHOIS server. Can be a "host:port" string or an object with `host` and `port` keys. - **follow** (number) - Optional - Controls the depth of redirect following (default: 2). - **verbose** (boolean) - Optional - If true, returns an array of `{ server, data }` objects. - **callback** (function) - Required - A Node.js-style callback function `(err, data)`. ### Request Example ```javascript import whois from 'whois'; // Basic domain lookup whois.lookup('google.com', (err, data) => { if (err) { console.error('Lookup failed:', err.message); return; } console.log(data); }); // Basic IPv4 lookup whois.lookup('8.8.8.8', (err, data) => { if (err) return console.error(err); console.log(data); }); // IPv6 lookup whois.lookup('2001:4860:4860::8888', (err, data) => { if (err) return console.error(err); console.log(data); }); ``` ### Response #### Success Response (200) - **data** (string | array) - The WHOIS data. A plain string in default mode, or an array of `{ server, data }` objects when `verbose: true`. #### Response Example ```json { "example": "raw WHOIS text containing registrar, creation date, expiry date, name servers, etc." } ``` ``` -------------------------------- ### Control WHOIS Redirect Depth with Node WHOIS Source: https://context7.com/furqansoftware/node-whois/llms.txt Control how many levels of WHOIS server referrals the library follows using the 'follow' option. The default is 2, allowing for registry to registrar lookups. Setting 'follow: 0' queries only the initial TLD registry server. ```javascript import whois from 'whois'; // follow: 0 — only query the TLD registry server, no redirects whois.lookup('google.com', { follow: 0 }, (err, data) => { if (err) return console.error(err); // data comes from whois.verisign-grs.com only console.log(data); }); // follow: 1 — follow one referral (registry → registrar) whois.lookup('google.com', { follow: 1 }, (err, data) => { if (err) return console.error(err); // data comes from whois.markmonitor.com (Google's registrar) console.log(data); }); // Default follow: 2 — follows up to two hops automatically whois.lookup('example.com', (err, data) => { if (err) return console.error(err); console.log(data); // most detailed response available }); ``` -------------------------------- ### `lookup` with `server` option — Specify a custom WHOIS server Source: https://context7.com/furqansoftware/node-whois/llms.txt Overrides automatic server resolution by allowing you to specify a custom WHOIS server. The server can be provided as a string (e.g., 'whois.tucows.com' or 'whois.tucows.com:43') or as an object with `host` and `port` keys. ```APIDOC ## lookup with `server` option ### Description Overrides automatic server resolution. The server can be provided as a "host:port" string or as an object with `host` and `port` keys. Useful when querying a specific registrar's WHOIS server directly. ### Parameters #### Request Body - **server** (string | object) - Required - The custom WHOIS server to use. Can be a string like 'host' or 'host:port', or an object like `{ host: '...', port: 43 }`. ### Request Example ```javascript import whois from 'whois'; // String form: "host" whois.lookup('tucows.com', { server: 'whois.tucows.com' }, (err, data) => { if (err) return console.error(err); console.log(data); }); // Object form with explicit port whois.lookup('tucows.com', { server: { host: 'whois.tucows.com', port: 43 } }, (err, data) => { if (err) return console.error(err); console.log(data); }); // Override port via string whois.lookup('example.com', { server: 'whois.verisign-grs.com:4343' }, (err, data) => { if (err) return console.error(err); console.log(data); }); ``` ``` -------------------------------- ### Access Built-in WHOIS Server Registry Source: https://context7.com/furqansoftware/node-whois/llms.txt Import and use the `SERVERS` export to access the built-in server registry for looking up WHOIS servers by TLD or for IP address lookups using the special `_` key. This allows for inspection or custom server resolution. ```javascript import { SERVERS } from 'whois'; // Look up the WHOIS server for .com console.log(SERVERS['com']); // { host: 'whois.verisign-grs.com', query: 'DOMAIN $addr\r\n' } // Look up the WHOIS server for .de console.log(SERVERS['de']); // { host: 'whois.denic.de', query: '-T dn $addr\r\n', punycode: false } // IP address lookups use the special "_" key console.log(SERVERS['_']['ip']); // { host: 'whois.arin.net', query: 'n + $addr\r\n' } // Check all supported TLDs console.log(Object.keys(SERVERS).filter(k => !k.startsWith('_')).length); // 400+ ``` -------------------------------- ### Basic Domain and IP Lookup with Node WHOIS Source: https://context7.com/furqansoftware/node-whois/llms.txt Perform a basic WHOIS lookup for a domain name or IP address. The library automatically resolves the correct WHOIS server. The callback receives an error or the raw WHOIS text data. ```javascript import whois from 'whois'; // Basic domain lookup whois.lookup('google.com', (err, data) => { if (err) { console.error('Lookup failed:', err.message); return; } console.log(data); // Output: raw WHOIS text containing registrar, creation date, // expiry date, name servers, etc. }); // Basic IPv4 lookup whois.lookup('8.8.8.8', (err, data) => { if (err) return console.error(err); console.log(data); // Output: ARIN WHOIS data for Google's DNS server block }); // IPv6 lookup whois.lookup('2001:4860:4860::8888', (err, data) => { if (err) return console.error(err); console.log(data); }); ``` -------------------------------- ### WHOIS Lookup with Bind Option Source: https://context7.com/furqansoftware/node-whois/llms.txt Force the outgoing TCP connection to use a specific local IP address. This is useful for multi-homed hosts to specify the network interface. ```javascript import whois from 'whois'; whois.lookup('example.com', { bind: '192.168.1.50' }, (err, data) => { if (err) return console.error(err); console.log(data); }); ``` -------------------------------- ### WHOIS Lookup with Proxy Option Source: https://context7.com/furqansoftware/node-whois/llms.txt Route WHOIS queries through a SOCKS4 or SOCKS5 proxy. The proxy can be specified as a 'host:port' string or an object with host, port, and optional type. ```javascript import whois from 'whois'; // SOCKS5 proxy via string (type defaults to 5) whois.lookup('google.com', { proxy: '127.0.0.1:1080' }, (err, data) => { if (err) return console.error(err); console.log(data); }); ``` ```javascript // SOCKS5 proxy via object whois.lookup('google.com', { proxy: { ipaddress: '127.0.0.1', port: 1080, type: 5, } }, (err, data) => { if (err) return console.error(err); console.log(data); }); ``` ```javascript // SOCKS4 proxy whois.lookup('example.com', { proxy: { ipaddress: '10.0.0.1', port: 1080, type: 4, } }, (err, data) => { if (err) return console.error(err); console.log(data); }); ``` -------------------------------- ### WHOIS Lookup with Timeout Option Source: https://context7.com/furqansoftware/node-whois/llms.txt Set a custom socket timeout in milliseconds. If a server doesn't respond within this window, an error is returned. Useful for slow or international WHOIS servers. ```javascript import whois from 'whois'; // Tight timeout — will likely fail for slow servers whois.lookup('google.com', { timeout: 1 }, (err, data) => { if (err) { console.error(err.message); // "lookup: timeout" return; } console.log(data); }); ``` ```javascript // Generous timeout for slow/international WHOIS servers whois.lookup('example.co.jp', { timeout: 15000 }, (err, data) => { if (err) return console.error(err); console.log(data); }); ``` -------------------------------- ### Specify Custom WHOIS Server with Node WHOIS Source: https://context7.com/furqansoftware/node-whois/llms.txt Override the automatic WHOIS server resolution by providing a custom server. The server can be specified as a 'host:port' string or an object with 'host' and 'port' properties. This is useful for directly querying a specific registrar's server. ```javascript import whois from 'whois'; // String form: "host" or "host:port" whois.lookup('tucows.com', { server: 'whois.tucows.com' }, (err, data) => { if (err) return console.error(err); console.log(data); }); // Object form with explicit port whois.lookup('tucows.com', { server: { host: 'whois.tucows.com', port: 43 } }, (err, data) => { if (err) return console.error(err); console.log(data); }); // Override port via string whois.lookup('example.com', { server: 'whois.verisign-grs.com:4343' }, (err, data) => { if (err) return console.error(err); console.log(data); }); ``` -------------------------------- ### IDN / Internationalized Domain Name Support Source: https://context7.com/furqansoftware/node-whois/llms.txt Handles domain names with non-ASCII characters by converting them to Punycode. Some TLDs may handle Unicode natively if configured. ```javascript import whois from 'whois'; // German IDN domain — converted to xn--kche-0ra.de internally whois.lookup('küche.de', (err, data) => { if (err) return console.error(err); // Response contains the original Unicode form because whois.denic.de // uses "punycode": false in servers.json console.log(data.toLowerCase().includes('domain: küche.de')); // true }); ``` ```javascript // Norwegian IDN domain whois.lookup('åre.no', (err, data) => { if (err) return console.error(err); console.log(data.toLowerCase().includes('åre.no')); // true }); ``` -------------------------------- ### WHOIS Lookup with Encoding Option Source: https://context7.com/furqansoftware/node-whois/llms.txt Set the character encoding for reading WHOIS response data. Useful for non-UTF-8 responses, such as latin-1. Defaults to UTF-8. ```javascript import whois from 'whois'; // Use binary encoding for servers that return latin-1 / ISO-8859-1 whois.lookup('148.241.109.161', { encoding: 'binary' }, (err, data) => { if (err) return console.error(err); console.log(data); // Contains "MX-ITYE8-LACNIC" in raw bytes }); ``` ```javascript // Default (no encoding set) — returns a UTF-8 string whois.lookup('google.com', (err, data) => { if (err) return console.error(err); console.log(typeof data); // "string" }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.