Skip to content

whois

stable

WHOIS domain lookup and response parsing. Queries WHOIS servers over TCP and provides helpers to extract registrar, dates, nameservers, and availability from the raw response.

use plugin whois::{query, parse_whois, get_registrar, …}
12 functions Networking
/ filter jk navigate Esc clear
Functions (12)
  1. query Query WHOIS for a domain name
  2. parse_whois Parse a raw WHOIS response into a key-value table
  3. get_registrar Extract the registrar name from a WHOIS response
  4. get_creation_date Extract the domain creation date
  5. get_expiration_date Extract the domain expiration date
  6. get_nameservers Extract the list of nameservers
  7. whois_server_for_tld Get the WHOIS server hostname for a TLD
  8. get_status Extract domain status values
  9. get_updated_date Extract the last updated date
  10. get_domain_name Extract the canonical domain name
  11. is_available Check if a domain appears to be unregistered
  12. raw_query Query a specific WHOIS server directly

Query WHOIS for a domain name

Looks up the WHOIS server for the domain's TLD and returns the raw WHOIS response text. Falls back to whois.iana.org for unknown TLDs.

use plugin whois::{query}

let response = query("example.com")
print(response)

Parse a raw WHOIS response into a key-value table

Parses a raw WHOIS response string into a table of {key, value} string pairs, skipping comment lines (starting with % or #).

use plugin whois::{query, parse_whois}

let response = query("example.org")
let fields = parse_whois(response)
print("fields: {#fields}")

Extract the registrar name from a WHOIS response

Scans the WHOIS response for a line containing "registrar" and returns the value. Returns nil if not found.

use plugin whois::{query, get_registrar}

let response = query("example.com")
let registrar = get_registrar(response)
print("registrar: {registrar}")

Extract the domain creation date

Extracts the domain creation date by searching for "creation date", "created", or "registration date" fields.

use plugin whois::{query, get_creation_date, get_expiration_date}

let response = query("example.com")
print("created: {get_creation_date(response)}")
print("expires: {get_expiration_date(response)}")

Extract the domain expiration date

Extracts the expiration date by searching for "expir", "registry expiry", "paid-till", or "expiration date" fields.

Extract the list of nameservers

Returns a table of all nameserver values found in the WHOIS response. Keys are 0-indexed integers.

use plugin whois::{query, get_nameservers}

let response = query("example.com")
let ns = get_nameservers(response)
print("first NS: {ns[0]}")

Get the WHOIS server hostname for a TLD

Returns the known WHOIS server hostname for common TLDs (com, net, org, io, dev, uk, de, etc.). Returns nil for unknown TLDs.

use plugin whois::{whois_server_for_tld}

let server = whois_server_for_tld("io")
print(server)  // "whois.nic.io"

Extract domain status values

Returns a table of all domain status values (e.g. "clientTransferProhibited") found in the WHOIS response.

use plugin whois::{query, get_status}

let response = query("example.com")
let statuses = get_status(response)
print("status count: {#statuses}")

Extract the last updated date

Extracts the last-updated date by searching for "updated date", "last modified", "last updated", or "changed" fields.

Extract the canonical domain name

Extracts the canonical domain name from the WHOIS response (the "domain name" or "domain" field).

Check if a domain appears to be unregistered

Returns true if the WHOIS response contains standard phrases indicating the domain is unregistered, such as "no match for", "not found", or "status: available".

use plugin whois::{query, is_available}

let response = query("this-domain-probably-does-not-exist-xyz.com")
if is_available(response) {
  print("domain is available")
}

Query a specific WHOIS server directly

Queries the specified WHOIS server hostname directly over TCP port 43 and returns the raw response. Use this for TLDs not in the built-in server map.

use plugin whois::{raw_query}

let response = raw_query("whois.verisign-grs.com", "example.com")
print(response)
enespt-br