DigitalNZ client library for ruby

By Nathan Donaldson in Other on July 24, 2009

Image 0460 full 2x

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,]