How to build a domain checker that’s working properly

There are so many domain checker tools out there, so who would want to build another one? Well, it seems a lot of people. Domain registration is always on the rise, and with it, it’s harder and harder to find great domain names that are available for registration.

Businesses are buying domain names on the aftermarket, and domain investors are flipping domain names for profit, but there are a lot of first-time entrepreneurs that don’t have the budget to cash out $20,000 for a domain name.

What kind of domain checkers exists?

We’ve already covered a small list of cool bulk domain checkers that are worth checking out. So we won’t go into depth on that topic here. But let’s quickly recap what kind of domain checkers exist.

  1. Ordinary bulk domain checkers
  2. Advanced bulk domain checkers
  3. Domain suggestion tools / domain name generators

I think we can split all the domain checkers out there into those three separate categories.

1. Simple bulk domain checkers

The simple or ordinary bulk domain checkers are mostly provided by domain registrars. These tools do a simple job of telling you if a domain name is registered or not. You have one simple box, a form, where you paste a few hundred domain names that you want to check. And a few moments later the website (bulk domain checker) responds with a list of registered and available domain names. Since GoDaddy is the biggest domain registrar in the world they have a bulk domain checker.

GoDaddy's bulk domain checker

GoDaddy’s bulk domain checker

Advanced bulk domain checkers

Then there are slightly more advanced bulk domain checkers. These allow you to check different TLDs (some of these are probably not available at your favorite or local domain registrar). Advanced bulk domain checkers give you the option to check both keywords and domain names. Or in webmaster.ninja’s example they allow you to combine a different set of keywords. You can search for keywords or a combination of keywords, or you can look for thousand domain names at once. It’s unfortunate we had to shut down this tool in August 2022 due to low interest.

Webmaster.ninja bulk domain checker

Webmaster.ninja’s bulk domain name checker

Domain suggestion tools

Not exactly bulk domain checkers, since domain suggestion tools focus on giving a (domain) name suggestion… Some of these domain suggestion tools still end up checking hundreds or thousands of domain names. Also called name-spinners or domain name generators. Essentially, you just type a few or a single keyword, and then these tools come up with synonyms or similar words, and then once they are done, they check those keywords on a .com, .net, or any other Top Level Domain that they decide to support.

Instant Domain Search

Instant Domain Search – Domain Generator

So, how do you build it?

In this article, we won’t cover the “domain name generator”, since WhoAPI’s business has nothing to do with that part. However, when it comes to domain availability checks, we know a thing or two. Back in the day, people would “check on Google search if the domain name is available or not”. Little did they know there’s this thing called whois.

But even today people make similar mistakes. They trust that any bulk domain checker is providing accurate results. Not to mention the security aspect of front running. Do you really trust that bulk domain checker that they won’t register that available domain name before you do?

Some bulk domain checkers are built using an old cached database. Yes, it may be fast, but what good is it to you if the results are not accurate and you see registered domain names?

Don’t get me wrong, our bulk domain checker also comes up with an error, but these are extreme situations.

Access to a whois server

If you want to build the most accurate domain availability checker, you need access to a whois server. This is very complex, borderline illegal, and frowned upon. This is mostly because apart from domain availability information, whois contains other information as well. With GDPR, California privacy act, and Brazil’s LGPD, the writing is on the wall and personal information is going to become off-limits in other countries as well.

It is my personal opinion it is sad and disappointing you can’t build advanced domain availability checks tools without such big obstacles. Eitherway, I haven’t even scratched the surface on this topic, and to most, it is a boring topic at best, so let’s proceed to the “how to” part of the article.

Whois API or Domain Availability API

We’ve touched on the problems that come with the Whois. But for this particular situation (building a bulk domain checker) we’ve created a solution for you. You don’t need to pay excessive fees for a bulk whois API. You can check domain availability with our Domain Availability API. This is a very simple API that essentially responds with a “domain registered” or “domain available for registration”. A 1 or a 0. Well, for the most part, there are some errors as well, but they rarely come up.

So what you do is you send the request the user enters on your website. So let’s say you have a form, and the user enters 1000 domain names. You then send 1000 requests to a domain availability API, and you get the results within seconds. The programming code for this is at the bottom of this article.

Is it checking domain name availability with DNS records?

One of the ways of checking for domain availability is asking for NS entries. It’s common practice among developers where you try to find out if the domain name is registered without hitting the whois. Well, the only problem with that is that it’s not 100% accurate. A domain name could be registered, and not “be present” in the DNS.

If you are just playing around, you can get away with it. But if you want to build a serious tool, businesses can depend on, and it has global support with all the CCTLDs and the new gTLDs, then you need something more robust.

You need a serious Domain Availability API. So how would a developer use such an API.

PHP code for Domain Availability API

Below is an example of a request to the Domain Availability API using PHP language. In case you use either Java, JavaScript, Python, Ruby, Objective C or C# feel free to check our generic Domain Availability API examples in your favorite language here: https://whoapi.com/code-examples/#1614265593437-66e9ea0e-2eb3.

<?php
# Request to API can fail under some conditions,
# so we will wrap it in try .. catch block
try {
  $domain = 'msn.com';
 
  # This function will return True if the domain is taken, False if it's not
  $is_taken = request_api($domain);
 
  echo "Domain $domain is: ".($is_taken ? "Taken" : "Vailable")."\n";
} catch (Exception $e) {
  echo "Error: ".$e->getMessage()."\n";
  exit;
}

/**
  * Make request to the API
  * @param string Domain name
  * @return boolean
  */
function request_api($domain) {
  /* Settings */
  
  // Request timeout in seconds
  $timeout = 60;
  
  // Url
  $url = "https://api.whoapi.com/?"
    ."r=taken"
    ."&apikey=".YOUR_API_KEY
    ."&domain=".$domain;
  
  /* Make Request */
  
  // Init curl
  $curl = curl_init($url);
  
  // Curl settings
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_FAILONERROR, true);
  curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
  curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
  
  // Make request
  $result = curl_exec($curl);
  $error = curl_error($curl);
  curl_close($curl);
  
  /* Validate result */
  
  // HTTP error
  if (!empty($error)) {
    throw new Exception("API error:\n".$url."\n".$error);
  }
  
  // Empty result
  if (empty($result)) {
    throw new Exception("API reply is empty:\n".$url);
  }
  
  // Decode the reply
  $result_decoded = json_decode($result, true);
  
  // Error while decoding?
  if (empty($result_decoded)) {
    throw new Exception("API decoding failed:\n".$url."\n".$result);
  }
  
  // Status is missing?
  if (!isset($result_decoded['status'])) {
    throw new Exception("API status is missing:\n".$url."\n".var_export($result_decoded, true));
  }
  
  // Status is invalid?
  if ((int)$result_decoded['status'] !== 0) {
    throw new Exception("API status is invalid:\n".$url."\n".var_export($result_decoded, true));
  }
  
  // Taken is missing?
  if (!isset($result_decoded['taken'])) {
    throw new Exception("API taken field is missing:\n".$url."\n".var_export($result_decoded, true));
  }
  
  /* Return result */
  return !empty($result_decoded['taken']);
}
?>

Do not forget to replace YOUR_API_KEY in the code example with your real WhoAPI key. You can find it in your members area here: https://my.whoapi.com. We offer free requests to this API so you do not need to pay us to test the code.

As a result of the successful launch you should see the following string:
Domain msn.com is: Taken

Now you can use the code for your purposes of checking domain availability.

So that’s how you build a domain checker that’s working properly. I understand it’s hard at first, and the team behind these pages are no strangers to creating APIs and tools… but we are by no means some special one-of-a-kind people. You can do it too, and the only way to build a domain checker tool, is by taking the first step. Reading this post is the first step. Second is using the code we laid out for you. I hope this short guide helps you.

GoranDuskic

Goran Duskic has been the Founder and CEO of WhoAPI Inc. since 2011, a company that specializes in developing APIs, including the well-known Whois API. He started his career in internet entrepreneurship in 2006 and has co-founded several online businesses, including a web hosting company that he later sold. Goran's work primarily involves creating practical API solutions to meet technological needs.

Post a Comment

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