Last active
October 13, 2015 06:58
-
-
Save keith/4156991 to your computer and use it in GitHub Desktop.
Use the Domai.nr API to see what domains are available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# A tiny script to check available domain names | |
# Uses the Domai.nr API http://domai.nr/api/docs/json | |
# A blatent ripoff of http://blog.jerodsanto.net/2012/11/a-domainr-cli-in-less-than-15-lines-of-ruby/ | |
require 'rubygems' | |
require 'open-uri' | |
# `[sudo] install colorize json` | |
require 'colorize' | |
require 'json' | |
if ARGV.count != 1 | |
puts "Usage: ./domainr.rb [URL]".red | |
exit | |
end | |
response = open("https://domai.nr/api/json/search?q=#{ ARGV.shift }").read | |
JSON.parse(response)["results"].each do |domain| | |
domain_name = domain["domain"] | |
case domain["availability"] | |
when "available" | |
puts domain_name.green | |
when "maybe" | |
puts domain_name.yellow | |
when "taken" | |
puts domain_name.red | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment