Question

I am using an API that does a WhoIs query to determine the availability of domains.

However, it seems every TLD gives a different type of response, so I have to create custom searches for each one:

result.match("No match for") //.com
result.match("NOT FOUND") //.info, .org
!result.match("Administrative")//.biz
result.match("Invalid query or domain")//.tk
!result.message.match("registered")//.ca
result.match("No Match")//.edu
result.match("Status: free")//.de
result.match("Not found:")//.de

There are hundreds more TLDs to go through. Surely this isn't the best way to do this. Is there a simpler way to determine if a domain has been registered or not?

No correct solution

OTHER TIPS

Unfortunately not. The only way to determine if a domain is available or not, is via a whois call. You cannot use alternative ways such as DNS because even if the domain doesn't resolve it doesn't mean it is available.

The major problem is exactly that one: every server can responds with a completely different string. If you really want to do it right, you have to collect all different strings or test against a large set of possibilities.

I'm the author of the Ruby whois library. So far, it's the only open source library that provides specs and parsers for every single response. Check it out, you can use it directly or get all the different responses from there, the code is open source.

Also keep in mind that if you don't want to deal with that, there are services you can use to check a domain availability.

Here's a few:

Disclaimer: I'm the author of RoboWhois.

I try to solve this problem by compiling a comprensive Whois server list. This list contains more than 500 top level domains. Feel free to use that list.

However if you don't want to bother with keeping the list up to date or rate limits on whois server I can recommend you my Whois API which is using that list as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top