Godaddy domain name API in Python
Introduction
Buying and selling domain names is fun and can be rewarding at the same time, specially if we manage to generate a unique domain name that could sell for a fortune. Getting rich overnight is not our topic today, however we are going to discuss how can we automate checking domain name availability using Python and Godaddy REST API. Given a new domain name, we need first to check if it is available for purchase. Next, we may need to get it appraised to get an idea about how much it is worth. To manually look up a domain name just go to godaddy.com and search for that domain name. You can also use ton of other similar websites. For domain name appraisal, Godaddy released a machine learning based domain name appraisal tool that we can leverage for our advantage.
Using keywords to generate domain names is tedious specially when checking for availability. The question is there a better way to automate this process ? The short answer is yes but first let us mention that there are a couple of web based tools that can help in suggesting cool names. I would recommend instant domain search. Such tools are helpful and some are interactive which is handy, however the automation piece is missing. Our goal is to be able to generate as many domain names as possible, automatically check their availability and appraisal if available. If we manage to do that – as we will demonstrate later – we can generate unthinkable domain names.
Let us see how…
Godaddy developer API
In order to automate checking domain name availability, we are going to utilize Godaddy open REST APIs. To do so, we need to register as a developer and get an API key and secret.
- Go to Godaddy developer site
- Follow the instructions to create an account
- Follow the UI instructions to create API key and secret
- Write the information down because we are going to use it later
For details about the available APIs you can refer to the documentation here. In this post, we are only interested in checking domain name availability and appraisal which is explained below…
Bulk domain name availability check
The script that we want to implement is supposed to search for as many domain names as possible. For that reason, it is efficient to to use bulk search instead of checking domain names one by one. Below, you can find the signature of the bulk search API end point…
1 |
https://api.godaddy.com/v1/domains/available |
A POST request on this end point requires a JSON payload along with headers. The JSON payload is a list of domain names and the headers should contain the developer API key and secret.
Godaddy appraisal API
A domain name can be appraised using the following end point…
1 |
https://api.godaddy.com/v1/appraisal/[name] |
Where name is the domain name we wish to appraise.
That it all we need, let us proceed…
Godaddy domain name API Python example
Now it is time to implement what we have discussed earlier. Follow the code snippet below. Code is explained in details using comments
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# This is needed to send POST and GET requests import requests # This is needed to limit the frequeny # by which we are going to hit the API # endpoints. Only certain number of # requests can be made in a mintue import time # This is needed to convert API # responses into JSON objects import json # Godaddy developer key and secret api_key = "your_api_key" secret_key = "your_secret" # API key and secret are sent in the header headers = {"Authorization" : "sso-key {}:{}".format(api_key, secret_key)} # Domain availability and appraisal end points url = "https://api.godaddy.com/v1/domains/available" appraisal = "https://api.godaddy.com/v1/appraisal/{}" # If a domain name is available # decide whether to appraise or not do_appraise = True # Number of domains to check in each call. # For example, we can not check more than 500 # domain names in one call so we need to split # the list of domain names into chunks chunk_size = 500 # Filter domain names by length max_length = 30 # Filter domain names by price range min_price = 0 max_price = 5000 # If appraisal is enabled, only include # domain names with min appraisal price min_appr_price = 0 # When a domain is appraised, Godaddy API # returns similar domains sold. This is a # nice feature to take a look at sold domains. # To filter similar sold domains we can do that # by setting the min sale price and the min # year the domain was sold min_sale_price = 0 min_sale_year = 2000 # Domain name structure: # prefix + keyword + suffix + extension # You can manually insert few values into # these lists and start the search or read # from files as demonstrated below prefixes = [] keywords = [] suffixes = [] extensions = [] # This list holds all generated domains # It is the list we are going to check all_domains = [] # This list holds similar domains sold # This is retrieved from Godaddy appraisal API similar_domains = [] # This holds available domains found that match # the search criteria found_domains = {} # Open prefix, keyword, suffix and extension from files with open("prefix.txt") as f: prefixes = f.read().splitlines() with open("keyword.txt") as f: keywords = f.read().splitlines() with open("suffix.txt") as f: suffixes = f.read().splitlines() with open("extension.txt") as f: extensions = f.read().splitlines() # Generate domains for prefix in prefixes: for keyword in keywords: for suffix in suffixes: for extension in extensions: domain = "{}{}{}.{}".format(prefix, keyword, suffix, extension) # Filter by length if len(domain) <= max_length: all_domains.append(domain) # This function splits all domains into chunks # of a given size def chunks(array, size): for i in range(0, len(array), size): yield array[i:i + size] # Split the original array into subarrays domain_chunks = list(chunks(all_domains, chunk_size)) # For each domain chunk (ex. 500 domains) for domains in domain_chunks: # Get availability information by calling availability API availability_res = requests.post(url, json=domains, headers=headers) # Get only available domains with price range for domain in json.loads(availability_res.text)["domains"]: if domain["available"]: price = float(domain["price"])/1000000 if price >= min_price and price <= max_price: print("{:30} : {:10}".format(domain["domain"], price)) found_domains[domain["domain"]]=price print("-----------------------------------------------") # API call frequency should be ~ 30 calls per minute time.sleep(2) # For each domain found get appraisal value and similar sold domains # Filter domains by appraisal price # Filter similar sold domains by sale price and year if not do_appraise: exit() for domain, price in found_domains.items(): # Call appraisl API appraisal_res = requests.get(appraisal.format(domain), headers=headers).json() try: # Get appraisal and similar sold domains govalue = appraisal_res["govalue"] comparable_sales = appraisal_res["comparable_sales"] except: print(appraisal_res) continue # Filter by min appraisal price if govalue >= min_appr_price: print("{:30} : {:10} : {}".format(domain, price, govalue)) for sale in comparable_sales: # Filter similar sold domains by price and year if sale["price"] >= min_sale_price and sale["year"] >= min_sale_year: similar_domain = "{:30} : {:10} : {:10}".format( sale["domain"], sale["price"], sale["year"]) # Do not include duplicates if similar_domain not in similar_domains: similar_domains.append(similar_domain) # Do not abuse the API time.sleep(2) # Print similar sold domains print("--------------------------------------------------------") for domain in similar_domains: print(domain) print("--------------------------------------------------------") |
Domain name generation
Let us give the script a try. We are going to use the following input files…
- Prefix words: a prefix is recommended to be a catchy word such as best, free, easy, etc…
1 2 |
best free |
- Main keywords: the keyword mainly describes what the domain name is all about…
1 2 |
auto food |
- Suffix words: suffix words complete the meaning for example bestautoservice.com
1 2 |
store service |
- Domain extensions: remember that the .com domain is the most popular domain extension and the one that you need to snatch before anyone else.
1 2 |
com net |
Now run the script by typing…
1 |
python test.py |
Note that if you encounter errors then it is probably because the requests module is not installed. If that is the case then you need to install it as follows…
1 2 3 |
sudo easy_install requests # You can also use pip sudo pip install requests |
Here is the output…
Available domain names
This is the list of available domains and corresponding price
1 2 3 4 5 6 7 8 |
freeautostore.com : 11.99 freeautoservice.net : 19.99 freeautostore.net : 19.99 bestautoservice.net : 19.99 freefoodstore.net : 19.99 bestautostore.net : 19.99 bestfoodservice.net : 19.99 freefoodservice.net : 19.99 |
Domain appraisal
This is the domain name, its price and appraised value
1 2 3 4 5 6 7 8 |
freeautostore.com : 11.99 : 1071 freeautoservice.net : 19.99 : 653 freeautostore.net : 19.99 : 129 bestautoservice.net : 19.99 : 768 freefoodstore.net : 19.99 : 263 bestautostore.net : 19.99 : 311 bestfoodservice.net : 19.99 : 192 freefoodservice.net : 19.99 : 100 |
Similar domain names sold
This is a list of similar domain names that were sold, along with price and sale year
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
freeautolisting.com : 777 : 2015 myautostore.com : 25000 : 2014 freeautotrader.com : 5000 : 2007 easyautosale.com : 550 : 2010 cybercarstore.com : 1288 : 2010 ezautobuy.com : 495 : 2017 theautostore.com : 2000 : 2003 freewebstore.com : 7500 : 2011 mobiletyreshop.com : 899 : 2017 pghautodepot.com : 799 : 2017 europeancarservice.net : 688 : 2008 bestautoparts.net : 695 : 2013 freehealthservices.net : 10 : 2012 ezautoparts.net : 1032 : 2007 usaautosales.net : 650 : 2012 freehealthquote.net : 377 : 2014 primeautogroup.net : 185 : 2016 theautostore.net : 488 : 2014 davesautobody.net : 799 : 2017 ultimatecarwash.net : 488 : 2008 freestateblogs.net : 100 : 2014 nationalautosales.net : 2388 : 2015 customautoaccessories.net : 299 : 2014 thefashionstore.net : 80 : 2017 bestautoinsurance.net : 1900 : 2009 bestlaptopdeals.net : 688 : 2012 topautoinsurance.net : 280 : 2012 bestcarinsurance.net : 405 : 2009 bestmedicalcare.net : 488 : 2008 realfoodlover.net : 22 : 2013 chineseherbstore.net : 388 : 2010 freefungames.net : 19 : 2014 thefoodpalette.net : 150 : 2017 freestockphoto.net : 325 : 2016 freemiums.net : 200 : 2017 freewebsitenow.net : 185 : 2016 freeforumshosting.net : 305 : 2018 discountelectronicsstore.net : 388 : 2008 grandautosales.net : 188 : 2011 bestbenefit.net : 297 : 2016 bestpharmacies.net : 98 : 2017 bestequipment.net : 588 : 2008 bestusa.net : 888 : 2017 bestfinancing.net : 300 : 2013 bestrestaurants.net : 4288 : 2009 bestsupplements.net : 400 : 2009 bestaffiliates.net : 10 : 2013 bestcognac.net : 30 : 2015 bestchocolate.net : 788 : 2010 freepublicity.net : 99 : 2017 freeadvertising.net : 1757 : 2006 freecoupon.net : 59 : 2016 freevitamins.net : 688 : 2008 freetowing.net : 550 : 2010 freeinsurance.net : 2308 : 2017 freeemailmarketing.net : 988 : 2010 freeproducts.net : 1900 : 2008 freefootball.net : 1000 : 2008 freecalculators.net : 100 : 2008 |
Thanks for visiting. If you have questions, please use the comments section below.
Hey thanks for the script but I’m facing an error on python2.7 in my centos7 machine:
[root@localhost html]# python gg.py
Traceback (most recent call last):
File “gg.py”, line 108, in
for domain in json.loads(availability_res.text)[“domains”]:
KeyError: ‘domains’
gg.py is the name of my file.
I tried a lot of things, not worked.
I had to edit the URLs in lines 22 and 23 because I created my keys the OTE (not production) environment. I had the same errors you did. When I changed the URLs, it worked great!
From the GD docs:
For the OTE environment, use your OTE Key and Secret with the following base URL: https://api.ote-godaddy.com
For the production environment, use your production Key and Secret with the following base URL: https://api.godaddy.com
Thanks a lot, it’s what I needed!
I have not tried Python 2.x. I used Python 3.x instead.
I assume you have requests library installed, your API and secret keys are correct
KeyError means the domains key does not exist in the response. Maybe you are getting an empty response. If everything is configured correctly then the only thing I can think of is that you are using some lookup parameters that are yielding no results. Try to play with the search parameters (ex. price range, number of characters, etc)
Worth noting about OTE vs Production: Definitely use production. The quality of the data in OTE is poor. It it inaccurate and good only for testing that your code works. Even in production, the results are not the same each time I run the script, but quality of results is far superior to OTE.
Thanks a bunch for this! I’m new to Python (but not programming) and found your site when I was looking for coding examples to play with.
If I have the suffix.txt file empty because I don’t want check domains with a suffix, how can I modify the code to work with that? The same with the prefix. Thanks in advance!
Hey, I have my own list of domain names in txt file. And I want to check the domain availability of those names and write it in another txt file if they are available . How can I modify this code to that…??
I modified it as ….but it’s not working.
import requests
import time
import json
api_key = “3mM44UaguNL6GH_Kc3bKzig25G1mZtnA87nwS”
secret_key = “37ZnMbQkQrYJ5pF57ZhrEi”
headers = {“Authorization” : “sso-key {}:{}”.format(api_key, secret_key)}
url = “https://api.godaddy.com/v1/domains/available”
all_domains=[]
with open(“links.txt”) as f:
for domains in f:
availability_res = requests.post(url, json=domains, headers=headers)
for domain in json.loads(availability_res.text)[“domains”]:
if domain[“available”]:
with open(“available_domains.txt”, ‘w’, newline=””, encoding=”UTF-8″) as f:
f.write(domain)
print(“Not Available”)
60 calls per minute is working fine. Would there be any problem like getting blocked by GoDaddy in future if I don’t maintain time.delay(2)?
for what its worth, I didn’t see any comments for it so thought I would add here – there is a Godaddy python lib :
https://pypi.org/project/GoDaddyPy/
for domain in json.loads(availability_res.text)[“domains”]:
KeyError: ‘domains’
regardless of getting API key and secret key can’t get over this error please help asap
Hello,
Thank you for sharing this.
Does anyone know of a way to modify the code so that it saves the domain name and the appraisal in a text or csv file?
Thank you in advance for your help.
Tony