DigitalNZ client library for ruby

By Nathan Donaldson

24 July 2009


We’ve just released a new client library for accessing the’s search API. This library uses nokogiri for speedily parsing the XML, making it faster than an existing dnz client library using JSON parsing.


sudo gem install dnz-client

Or for the bleeding edge (if there is one):

sudo gem install boost-dnz-client

You’ll need to have an API key from


Simple search

require 'dnz/client'

client ='api_key')
search ='otago')

search.results.each do |result|
  puts result.title

Fetch all categories

require 'dnz/client'

client ='api_key')
categories = client.categories

categories.each do |category|
  puts "Category %s has %d results" % [, category.count]

Fetch a facet

require 'dnz/client'

client ='api_key')
search ='otago', :facets => ['category'])

search.facets['category'].each do |category|
  puts 'Search for otago has %d items in category %s' % [category.count,]

Learn more

Our web application development work for DigitalNZ

Why we chose Ruby on Rails for this development

Ruby on Rails developer jobs in Wellington

Make a bigger impact tomorrow

Talk to us today