Skip to main content

Python API client for Domain Management Automation with DNSimple

Project description

Python DNSimple

[![Build Status](](

## Introduction

This is a client for the [DNSimple REST API]( It currently allows you to fetch existing domain info, as well as register new domains and manage domain records.

`dnsimple-python` works for both python 2 & 3.

**Note:** As of 1.0.0 this now uses [DNSimple's APIv2]( This is incompatible with older versions of the library because of authentication changes. Please review the docs and tests before deploying to production.

### Getting started

You'll need the `json` module that is included with python version 2.6 and later, or the `simplejson` module if you are using an earlier version.

`dnsimple-python` also depends on the `requests` library.

Import the module:

from dnsimple import DNSimple

You can provide your DNSimple credentials in one of two ways:

#### Provide email/password or api\_token credentials programmatically:

# Use email/password authentication: HTTP Basic
dns = DNSimple(email=YOUR_USERNAME, password=YOUR_PASSWORD)

# Use api_token credentials
dns = DNSimple(api_token=YOUR_API_TOKEN)

# If you have many accounts you can provide account_id (661 is an example)
# You can find your account id in url (
dns = DNSimple(email=YOUR_USERNAME, password=YOUR_PASSWORD, account_id=661)

##### Store you email/password or api\_token credentials in a file called `.dnsimple` in the current directory with the following data:

password: yourpassword


api_token: yourapitoken

Or (assuming `$DNSIMPLE_EMAIL` and `$DNSIMPLE_TOKEN` are environment variables):

api_token: %(DNSIMPLE_TOKEN)s

You then need not provide any credentials when constructing `DNSimple`:

dns = DNSimple()

## Domain Operations

### Check out your existing domains:

Just run:

domains =

Results appear as a Python dict:

{'domain': {'created_at': '2010-10-14T09:45:32Z',
'expires_at': '10/14/2011 5:45:00 AM',
'id': 999,
'last_enom_order_id': None,
'name': '',
'name_server_status': 'active',
'registrant_id': 99,
'registration_status': 'registered',
'updated_at': '2010-10-14T10:00:14Z',
'user_id': 99}},
{'domain': {'created_at': '2010-10-15T16:02:34Z',
'expires_at': '10/15/2011 12:02:00 PM',
'id': 999,
'last_enom_order_id': None,
'name': '',
'name_server_status': 'active',
'registrant_id': 99,
'registration_status': 'registered',
'updated_at': '2010-10-15T16:30:16Z',
'user_id': 99}}]

### Get details for a specific domain


Results are the same as `domains()` above, but only show the domain specified.

### Check whether a domain is available


# Hmm, looks like I'm too late to get that one...
{u'currency': u'USD',
u'currency_symbol': u'$',
u'minimum_number_of_years': 1,
u'name': u'',
u'price': u'14.00',
u'status': u'unavailable'}

### Register a new domain


This will register '', automatically picking the registrant\_id from your first domain. To specify a particularly `registrant_id`, just run:

dns.register('', 99)

Responses will be in a dictionary describing the newly created domain, same as the `domain()` call above.

### Delete a domain

Careful with this one!


## Record operations

All operations on domain records are now supported:

* List records: `records(id_or_domainname)`
* Get record details: `record(id_or_domainname, record_id)`
* Add record: `add_record(id_or_domainname, data)`
* Update record: `update_record(id_or_domainname, record_id, data)`
* Delete record: `delete_record(id_or_domainname, record_id)`

## SSL Certificates

All read-only operations around ssl certificates are supported:

* [List certificates]( `certificates(id_or_domainname)`
* [Get certificate details]( `certificate(id_or_domainname, certificate_id)`
* [Download a certificate]( `download_certificate(id_or_domainname, certificate_id)`
* [Get a certificate's private key]( `certificate_private_key(id_or_domainname, certificate_id)`

## Running Tests

Before running tests, you'll need to ensure your environment is set up correctly.
Currently we do live tests against DNSimple's sandbox so you will need to set that up. This also means that running tests concurrently will cause failures.

### Set up DNSimple Sandbox account
1. If you don't already have a DNSimple sandbox account, [create one]( and make sure to have your email address, password, and API token handy.
1. Copy the file `tests/.env.example` to `tests/.env` and supply your sandbox credentials

### Setup Python
If you don't wish to use pyenv you will want to skip this and run `tox` manually after setting up your environment

1. install [pyenv]( using homebrew or git
1. `make test` to run all tests

## License

Licensed under the [MIT license](

## Authors

* Original Author [Mike MacCana](
* APIv2 Support [Kirill Motkov](
* Maintainer [David Aronsohn](

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dnsimple, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size dnsimple-1.2.0.tar.gz (27.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page