DNSimple Ruby Client

A Ruby client for the DNSimple API v2.

Build Status Coverage Status

DNSimple provides DNS hosting and domain registration that is simple and friendly. We provide a full API and an easy-to-use web interface so you can get your domain registered and set up with a minimal amount of effort.

Installation

You can install the gem manually:

$ gem install dnsimple

Or use Bundler and define it as a dependency in your Gemfile:

gem 'dnsimple', '~> 4.0'

Usage

This library is a Ruby client you can use to interact with the DNSimple API v2. Here are some examples.

require 'dnsimple'

client = Dnsimple::Client.new(access_token: "a1b2c3")

# Fetch your details
response = client.identity.whoami   # execute the call
response.data                       # extract the relevant data from the response or
client.identity.whoami.data         # execute the call and get the data in one line

# Define an account ID.
 = 1010

# You can also fetch it from the whoami response
# as long as you authenticate with an Account access token
whoami = client.identity.whoami.data
 = whoami..id

# List your domains
puts client.domains.list_domains().data                      # => domains from the account 1234, first page
puts client.domains.list_domains(, query: { page: 3 }).data  # => domains from the account 1234, third page
puts client.domains.all_domains().data                       # => all domains from the account 1234 (use carefully)

# Create a domain
response = client.domains.create_domain(, name: "example.com")
puts response.data

# Get a domain
response = client.domains.domain(, "example.com")
puts response.data

For the full library documentation visit http://rubydoc.info/gems/dnsimple

Sandbox Usage

If you would like to test the DNSimple sandbox environment then pass the base_url named argument when you construct the client. For example:

require 'dnsimple'

client = Dnsimple::Client.new(base_url: "https://api.sandbox.dnsimple.com", access_token: "a1b2c3")

You will need to ensure that you are using an access token created in the sandbox environment. Production tokens will not work in the sandbox environment.

License

Copyright (c) 2010-2016 Aetrion LLC. This is Free Software distributed under the MIT license.