GoDaddy DNS Driver Documentation

GoDaddy provide domain name registration and are the worlds largest with over 13 million customers. They also provide nameservers and DNS hosting as well as cloud and website hosting.

../../_images/godaddy.png

Further information on GoDaddy API is available on the GoDaddy API Website

Driver features

  • Manage the records for GoDaddy hosted domains

  • Price and purchase domains with an existing GoDaddy account

  • Fetch legal agreements required to register and purchase domains for a range of TLDs

  • Submit completed agreements to purchase domains

Instantiating the driver

Before you instantiate a driver, you will need a GoDaddy account.

Once you have an account you need to request a Production key on the GoDaddy API website: https://developer.godaddy.com/getstarted#access

You can then use these details to instantiate a driver with the arguments:

  • shopper_id - Your customer ID

  • key - An API key

  • secret - The matching secret for the API key

from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.GODADDY)
driver = cls("customer_id", "api_key", "api_secret")

Listing zones

from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.GODADDY)
driver = cls("customer_id", "api_key", "api_secret")

zones = driver.list_zones()
for zone in zones:
    print("Domain : {}".format(zone.domain))
    print("Expires: {}".format(zone.extra["expires"]))

Returns

Zone : wassle-layer.com
Expires: 2018-09-30T18:22:00Z
Zone : wizzle-wobble.org
Expires: 2017-01-04T04:02:07Z

Listing records

from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.GODADDY)
driver = cls("customer_id", "api_key", "api_secret")

zone = driver.get_zone("wazzle-flooble.com")
records = driver.list_records(zone)
for record in records:
    print("Type : {}".format(record.type))
    print("Data: {}".format(record.data))
    print("TTL: {}".format(record.ttl))

Returns

Type : CNAME
Data: @
TTL: 3600
Type : CNAME
Data: @
TTL: 3600
Type : MX
Data: mailstore1.secureserver.net
TTL: 3600
Type : MX
Data: smtp.secureserver.net
TTL: 3600

Adding records

from libcloud.dns.types import Provider, RecordType
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.GODADDY)
driver = cls("customer_id", "api_key", "api_secret")
zone = driver.get_zone("waffle-machines.com")
record = zone.create_record(name="www", type=RecordType.A, data="127.0.0.1", ttl=5)

Updating records

from libcloud.dns.types import Provider, RecordType
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.GODADDY)
driver = cls("customer_id", "api_key", "api_secret")

record = driver.get_record("waffle-machines.com", "www:A")
record = driver.update_record(
    record=record, name="www", type=RecordType.A, data="50.63.202.22"
)

It is important to note that the GoDaddy API does not give records a unique identifier. So if you have multiple existing records for a single data and type, e.g. 2 A records for www, they will both be replaced with 1 record if you run the update_records method

Pricing a domain

The driver supports checking the availability of a domain that you would like to purchase.

from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.GODADDY)
driver = cls("customer_id", "api_key", "api_secret")

check = driver.ex_check_availability("wazzlewobbleflooble.com")
if check.available is True:
    print("Domain is available for {} {}".format(check.price, check.currency))
else:
    print("Domain is taken")

Purchasing a domain

Domains can be purchased by requesting the agreement schema, which is a JSON schema and submitted a completed document.

from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.GODADDY)
driver = cls("customer_id", "api_key", "api_secret")

# Get the JSON schema for the domain
schema = driver.ex_get_purchase_schema("com")

# Use this schema to prepare a purchase request document

# Load a JSON document that has the completed purchase request
file = open("purchase_request.json", "r")
document = file.read()
order = driver.ex_purchase_domain(document)
print("Made request : order ID : %s" % order.order_id)

API Docs

class libcloud.dns.drivers.godaddy.GoDaddyDNSDriver(shopper_id, key, secret, secure=True, host=None, port=None)[source]

A driver for GoDaddy DNS.

This is for customers of GoDaddy who wish to purchase, update existing domains and manage records for DNS zones owned by GoDaddy NS servers.

Instantiate a new GoDaddyDNSDriver

Parameters
  • shopper_id (str) – Your customer ID or shopper ID with GoDaddy

  • key (str) – Your access key from developer.godaddy.com

  • secret (str) – Your access key secret

connectionCls

alias of libcloud.dns.drivers.godaddy.GoDaddyDNSConnection

create_record(name, zone, type, data, extra=None)[source]

Create a new record.

Parameters
  • name (str) – Record name without the domain name (e.g. www). Note: If you want to create a record for a base domain name, you should specify empty string (‘’) for this argument.

  • zone (Zone) – Zone where the requested record is created.

  • type (RecordType) – DNS record type (A, AAAA, …).

  • data (str) – Data for the record (depends on the record type).

  • extra (dict) – Extra attributes (driver specific). (optional)

Return type

Record

create_zone(domain, type='master', ttl=None, extra=None)

Create a new zone.

Parameters
  • domain (str) – Zone domain name (e.g. example.com)

  • type (str) – Zone type (master / slave).

  • ttl (int) – TTL for new records. (optional)

  • extra (dict) – Extra attributes (driver specific). (optional)

Return type

Zone

delete_record(record)

Delete a record.

Parameters

record (Record) – Record to delete.

Return type

bool

delete_zone(zone)[source]

Delete a zone.

Note: This will CANCEL a purchased domain

Parameters

zone (Zone) – Zone to delete.

Return type

bool

ex_check_availability(domain, for_transfer=False)[source]

Check the availability of the domain

Parameters
  • domain (str) – the domain name e.g. wazzlewobbleflooble.com

  • for_transfer (bool) – Check if domain is available for transfer

Return type

list of GoDaddyAvailability

ex_get_agreements(tld, privacy=True)[source]

Get the legal agreements for a tld Use this in conjunction with ex_purchase_domain

Parameters

tld (str) – The top level domain e.g com, eu, uk

Return type

dict the JSON Schema

ex_get_purchase_schema(tld)[source]

Get the schema that needs completing to purchase a new domain Use this in conjunction with ex_purchase_domain

Parameters

tld (str) – The top level domain e.g com, eu, uk

Return type

dict the JSON Schema

ex_list_tlds()[source]

List available TLDs for sale

Return type

list of GoDaddyTLD

ex_purchase_domain(purchase_request)[source]

Purchase a domain with GoDaddy

Parameters

purchase_request (dict) – The completed document from ex_get_purchase_schema

Return type

GoDaddyDomainPurchaseResponse Your order

export_zone_to_bind_format(zone)

Export Zone object to the BIND compatible format.

Parameters

zone (Zone) – Zone to export.

Returns

Zone data in BIND compatible format.

Return type

str

export_zone_to_bind_zone_file(zone, file_path)

Export Zone object to the BIND compatible format and write result to a file.

Parameters
  • zone (Zone) – Zone to export.

  • file_path (str) – File path where the output will be saved.

get_record(zone_id, record_id)[source]

Return a Record instance.

Parameters
  • zone_id (str) – ID of the required zone

  • record_id (str) – ID of the required record

Return type

Record

get_zone(zone_id)[source]

Get a zone (by domain)

Parameters

zone_id (str) – The domain, not the ID

Return type

Zone

iterate_records(zone)

Return a generator to iterate over records for the provided zone.

Parameters

zone (Zone) – Zone to list records for.

Return type

generator of Record

iterate_zones()

Return a generator to iterate over available zones.

Return type

generator of Zone

list_record_types()

Return a list of RecordType objects supported by the provider.

Returns

list of RecordType

list_records(zone)[source]

Return a list of records for the provided zone.

Parameters

zone (Zone) – Zone to list records for.

Returns

list of Record

list_zones()[source]

Return a list of zones (purchased domains)

Returns

list of Zone

update_record(record, name, type, data, extra=None)[source]

Update an existing record.

Parameters
  • record (Record) – Record to update.

  • name (str) – Record name without the domain name (e.g. www). Note: If you want to create a record for a base domain name, you should specify empty string (‘’) for this argument.

  • type (RecordType) – DNS record type (A, AAAA, …).

  • data (str) – Data for the record (depends on the record type).

  • extra (dict) – (optional) Extra attributes (driver specific).

Return type

Record

update_zone(zone, domain, type='master', ttl=None, extra=None)

Update an existing zone.

Parameters
  • zone (Zone) – Zone to update.

  • domain (str) – Zone domain name (e.g. example.com)

  • type (str) – Zone type (master / slave).

  • ttl (int) – TTL for new records. (optional)

  • extra (dict) – Extra attributes (driver specific). (optional)

Return type

Zone