Skip to content

Instantly share code, notes, and snippets.

@Cgboal
Created December 8, 2020 11:46
Show Gist options
  • Save Cgboal/13895356db66269897ca6bae290cbbbd to your computer and use it in GitHub Desktop.
Save Cgboal/13895356db66269897ca6bae290cbbbd to your computer and use it in GitHub Desktop.
Pull reverse whois info from reverse-whois.whoisxmlapi.com
#!/usr/bin/bb
(require '[babashka.curl :as curl])
(require '[cheshire.core :as json])
(require '[clojure.string :as s])
(def my-api-key "PUT_YOUR_API_KEY_HERE")
(defn make-request-body [api-key query]
{:apiKey api-key
:searchType "current"
:mode "purchase"
:punycode true
:basicSearchTerms {:include [query]
:exclude []}})
(defn fetch-results [api-key query]
(curl/post "https://reverse-whois.whoisxmlapi.com/api/v2" {:headers {"Accept" "application/json"}
:body (json/generate-string (make-request-body api-key query))}))
(defn extract-domains [resp]
(-> resp
(:body)
(json/parse-string true)
(:domainsList)
(->> (s/join "\n"))))
(defn reverse-whois [api-key query]
(-> (fetch-results api-key query)
(extract-domains)))
(println (reverse-whois my-api-key (first *command-line-args*)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment