- Impact
- 21,791
OK, probably there is not one real domainer one the planet who doesn't have an account at Godaddy, or hasn't had to deal with that registrar at one time. Chances are, even if you dislike them you have a number of domains registered with them because they were acquired at auctions or otherwise.
I am not really a fan of their interface, I find that I am wasting too much time performing simple but tedious steps.
In spite of their poor UI (imo) they have an API that is readily available to you, provided that you have enough technical knowledge. You do not have to put up with their UI really, you can automate maintenance with remote calls instead.
So here is the deal: I will now show you how to take advantage of their API in order to save time on domain name management.
Here are two features that I developed for an immediate need:
One of my pet peeves is that when you win a closeout domain it is configured to use Godaddy name servers. If you want to park the domain, you have to log in every time to set the name servers. A pain isn't it ?
As far as I know you cannot define default name servers, which is a shame.
Answer: use the API
Feature #2: get EPP codes for transfer
I normally consolidate domains to another registrar, so I will transfer names before they expire. For this you need to unlock the domain, and the EPP code.
Answer: use the API
I made a little script to implement these two features, it is attached in this thread.
The script is written in bash for Linux and there are no particular dependencies but you need to have the magical tool Curl installed on your system. Type curl in the command line to check. Most developers should already be familiar with it. It ships with many if not most Linux distros. If you don't have it, installing is as easy as:
(as root)
Or yum, dnf or pacman depending on your flavor of Linux.
If you are stuck on Windows, the code can still be ported. It should be easy to reuse the Curl snippets in Powershell for example.
Or you could set up a Linux virtual machine with Virtualbox or VMware to try out the code. A VPS on Linux is another possibility.
I apologize in advance for the average quality of this code, I spent only a few hours on it, and this is more a proof of concept than a complete solution. But it is very compact: less than 100 lines
First of all go to: https://developer.godaddy.com/
I recommend that you read up a bit the intro and the documentation to get acquainted with the possibilities.
Then click on Getting Access to generate API keys for your own use.
You will get two Key/Secret pairs, one to use on a test environment, and one to use on production servers.
Setting up a payment method is not required, because we will not performing financial operations.
Now that you have your own key pair, you are ready to go.
You need to adapt the script and enter the secret keys you've just obtained:
You enter the production keys.
Also, enter your preferred name servers, for example:
At least 2 NS are required, separated with a comma, whitespace optional.
When you are done editing the file, one final step:
(to make the script executable)
Now run the script from the command line like this:
or:
(This is assuming the script is in the current directory)
If you do not provide a domain name as parameter, you will be prompted for one.
The menu is very simple and looks like this:
Choose an option:
1) Change domain name (current: yourdomain.com)
2) Get domain info incl. EPP code
3) Set name servers, unlock and disable auto-renew
4) Exit
1: change the current domain you will be working on.
2. output domain information in XML format, basically you get the contacts assigned to the domain plus extra info such as EPP code, autorenew and lock settings etc. Like an augmented whois record.
This option will also extract the EPP code for you.
3. Update domain name: this option performs several steps in one shot:
The API is HTTP-based and returns standard HTTP codes. 200 means OK, 404 is self-explanatory: the URL is wrong.
Other possible codes include 204 (OK but no content returned).
I also have stumbled on:
But the call otherwise succeeded. So I am not sure if I am doing something wrong or if it is a bug.
Finally...
The code is provided as-is, with no guarantees.
Code
I am not really a fan of their interface, I find that I am wasting too much time performing simple but tedious steps.
In spite of their poor UI (imo) they have an API that is readily available to you, provided that you have enough technical knowledge. You do not have to put up with their UI really, you can automate maintenance with remote calls instead.
So here is the deal: I will now show you how to take advantage of their API in order to save time on domain name management.
Here are two features that I developed for an immediate need:
- Set name servers
- Retrieve EPP codes
One of my pet peeves is that when you win a closeout domain it is configured to use Godaddy name servers. If you want to park the domain, you have to log in every time to set the name servers. A pain isn't it ?
As far as I know you cannot define default name servers, which is a shame.
Answer: use the API
Feature #2: get EPP codes for transfer
I normally consolidate domains to another registrar, so I will transfer names before they expire. For this you need to unlock the domain, and the EPP code.
Answer: use the API
I made a little script to implement these two features, it is attached in this thread.
The script is written in bash for Linux and there are no particular dependencies but you need to have the magical tool Curl installed on your system. Type curl in the command line to check. Most developers should already be familiar with it. It ships with many if not most Linux distros. If you don't have it, installing is as easy as:
Code:
apt-get install curl
Or yum, dnf or pacman depending on your flavor of Linux.
If you are stuck on Windows, the code can still be ported. It should be easy to reuse the Curl snippets in Powershell for example.
Or you could set up a Linux virtual machine with Virtualbox or VMware to try out the code. A VPS on Linux is another possibility.
I apologize in advance for the average quality of this code, I spent only a few hours on it, and this is more a proof of concept than a complete solution. But it is very compact: less than 100 lines
First of all go to: https://developer.godaddy.com/
I recommend that you read up a bit the intro and the documentation to get acquainted with the possibilities.
Then click on Getting Access to generate API keys for your own use.
You will get two Key/Secret pairs, one to use on a test environment, and one to use on production servers.
Setting up a payment method is not required, because we will not performing financial operations.
Now that you have your own key pair, you are ready to go.
You need to adapt the script and enter the secret keys you've just obtained:
Code:
key="<your key goes here>" # key API
secret="<your key goes here>" # secret for API
Also, enter your preferred name servers, for example:
Code:
name_servers="ns1.sedoparking.com, ns2.sedoparking.com"
When you are done editing the file, one final step:
Code:
chmod +x gdapi.sh
Now run the script from the command line like this:
Code:
./gdapi.sh
Code:
./gdapi.sh <domain>
(This is assuming the script is in the current directory)
If you do not provide a domain name as parameter, you will be prompted for one.
The menu is very simple and looks like this:
Choose an option:
1) Change domain name (current: yourdomain.com)
2) Get domain info incl. EPP code
3) Set name servers, unlock and disable auto-renew
4) Exit
1: change the current domain you will be working on.
2. output domain information in XML format, basically you get the contacts assigned to the domain plus extra info such as EPP code, autorenew and lock settings etc. Like an augmented whois record.
This option will also extract the EPP code for you.
3. Update domain name: this option performs several steps in one shot:
- disable auto-renew
- unlock the domain
- set default name servers of your choice
- In this example, requests are sent in JSON format but responses are requested in XML format. It's a matter of preference, but parsing will differ depending on which one you choose.
- Again, you need to have Curl installed on your system (available for nearly every platform). The script doesn't check whether Curl is installed.
- There is no validation of the domain name
- Obviously, you can only perform actions on domain names that belong to you
- I have not tested with ccTLDs, only .com/.net. EPP-compliant ccTLDs should be OK.
The API is HTTP-based and returns standard HTTP codes. 200 means OK, 404 is self-explanatory: the URL is wrong.
Other possible codes include 204 (OK but no content returned).
I also have stumbled on:
Code:
HTTP/1.1 409 Conflict
{"code":"INELIGIBLE_DOMAIN","message":"The domain was not purchased with a subaccount","name":"ApiError"}
Finally...
- Do not abuse the privilege, and overload Godaddy servers with useless traffic
- Requests tend to run slowly (and are probably deliberately throttled), so this script is probably not a good option for dropcatching
- NB: to the best of my knowledge the API does not grant access to the auctions
The code is provided as-is, with no guarantees.
Code
Code:
#!/bin/bash
# Constants
api_url="https://api.godaddy.com/v1/"
# Your API keys
key="" # key API
secret="" # secret for API
# comma-separated list of name servers, spaces allowed
# at least 2 name servers are required
name_servers="ns1.sedoparking.com, ns2.sedoparking.com"
headers="Authorization: sso-key $key:$secret"
# if the domain name was not provided in parameter
if [ -z $1 ]; then
echo -n "Enter domain name: "
read domain
else
domain=$1
fi
if [ -z $domain ]; then
echo "Domain name may not be blank, exit"
exit 1
fi
while true; do
options=("Change domain name (current: $domain)" "Get domain info incl. EPP code" "Set name servers, unlock and disable auto-renew" "Exit")
echo -e "\nChoose an option: "
select opt in "${options[@]}"; do
case $REPLY in
1) domain=""
while [ -z $domain ]; do
echo -n "Enter domain name: "
read domain
done
break ;;
2) echo "Fetching domain info ($domain)..."
# send query
result=$(curl --silent --include -X GET -H "$headers" -H "Content-Type: application/json" -H "Accept: text/xml" "$api_url/domains/$domain")
# uncomment below to see Curl response
echo "$result"
# extract EPP code from XML response
epp_code=$(echo $result | grep -Po '<authCode>.*</authCode>' | sed 's/<\/*authCode>//g')
echo -e "\nEPP code: $epp_code\n"
break ;;
3) echo "Set name servers, unlock domain name and disable auto-renew ($domain)...";
# parse list of name servers (build list)
ns_list=$(echo "$name_servers" | sed 's/,\s*/", "/g')
request="{ \"locked\": false, \"nameServers\": [ \"$ns_list\" ], \"renewAuto\": false, \"subaccountId\": \" \" }"
# send request
result=$(curl --silent --include -X PATCH -H "$headers" -H "Content-Type: application/json" -H "Accept: text/xml" -d "$request" "https://api.godaddy.com/v1/domains/$domain")
echo "$result"
break ;;
4) exit 0;
break ;;
*) echo "Invalid option"
;;
esac
done
done