Posted in:

Ruby code example for WhoAPI

For a long time we were missing “code example” for a popular programming language Ruby! Luck wanted me to be a guest speaker on a panel discussion during Web Industrija (last Thursday). Although the panel discussion was really interesting (From ideas to investments), and guests congratulated me, we have a much more interesting announcement 🙂

During the Web Industrija I met Alexander Rusa from Emerion. Alexander loves Ruby, and it was very kind of him to provide us with a code example for such a fantastic language! When he is not writing cool Ruby code for hot startups, he is working at Emerion, one of the hosting companies in Austria.

We’re going to check if the domain name “whoapi.com” is available. If error occurs it will be translated automatically, if not you should see “1” (domain taken) as a resulting string.

[source language=”ruby”]
require ‘open-uri’
require ‘json’domain = “whoapi.com” # domain to check
r = “taken” # request type: domain availability
apikey = “demokey” # your API key

output = JSON.parse(open(
“http://api.whoapi.com/?domain=#{domain}&r=#{r}&apikey=#{apikey}”).read)

if output[“status”].to_i == 0
puts output[“taken”]
else
puts output[“status_desc”]
end
[/source]

Written by Goran Duskic

I am the founder and CEO at WhoAPI. Entrepreneur for more than a decade in the hosting and domain industry. Sold my previous company. 500 Startups and StartLabs alumni. Author of a white paper "Domain Disclosure: Dirty Dozen" and eBook "26 Fundraising Questions for Startups".

98 posts

Leave a Reply

Your email address will not be published. Required fields are marked *