Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@menzow
Created May 24, 2018 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save menzow/fbf0d1065b4fa03d68de8649bc13e582 to your computer and use it in GitHub Desktop.
Save menzow/fbf0d1065b4fa03d68de8649bc13e582 to your computer and use it in GitHub Desktop.
JSON whois cli [https://jsonwhois.io/] [bash]
#!/bin/bash
# dependencies: jq, curl, bash
# Usage: ./whois.sh example.com
# Caches lookups in /var/cache/whois
# Sign up for api key here: https://jsonwhois.io/register
domain="$1"
cache_dir='/var/cache/whois'
cache_entry="$cache_dir/$domain"
json_whois_api_key="YOUR_API_KEY"
[[ ! -d "$cache_dir" ]] && mkdir -p "/var/cache/whois"
if [[ -f "$cache_entry" ]]; then
jq '.' "$cache_entry"
exit;
fi
curl -s "https://api.jsonwhois.io/whois/domain?key=$json_whois_api_key&domain=$domain" | jq '.' - | tee "$cache_entry"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment