DNSimple Ruby Client

A Ruby client for the DNSimple API.

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

$ gem install dnsimple

Getting Started

This library is a Ruby client you can use to interact with the DNSimple API.

Here's a short example.

require 'dnsimple'

client = Dnsimple::Client.new(username: 'YOUR_USERNAME', api_token: 'YOUR_TOKEN')

# Fetch your user details
user = client.users.user
puts "My email is #{user.email}"

# Get a list of your domains
domains = client.domains.list
domains.each do |domain|
  puts "Domain: %s (id: %d)" % [domain.name, domain.id]
end

# Create a domain
domain = client.domains.create("example.com")
puts "Domain: %s (id: %d)" % [domain.name, domain.id]

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

Authentication

This client supports both the HTTP Basic and API Token authentication mechanism.

HTTP Basic

client = Dnsimple::Client.new(username: 'YOUR_USERNAME', password: 'YOUR_PASSWORD')
client.users.user
# => User

HTTP Basic with two-factor authentication enabled

See the 2FA API documentation.

# Request the 2FA exchange token
client = Dnsimple::Client.new(username: 'YOUR_USERNAME', password: 'YOUR_PASSWORD')
token  = client.users.exchange_token('otp-token')

# Authenticate with the exchange token
client.exchange_token = token
client.users.user
# => User

API Token

client = Dnsimple::Client.new(username: 'YOUR_USERNAME', api_token: 'YOUR_TOKEN')

client.users.user
# => User