Skip to main content

Introducing a Ruby Library for the Duck Duck Go API

·1 min

I have just released a new Ruby library for working with the Duck Duck Go Zero-click Info API. It encapsulates the API calls and decoding and populates various objects to hold the results.

Here is the example from the README file, doing a query for Stephen Fry:

require "duck_duck_go"
  
ddg = DuckDuckGo.new
zci = ddg.zeroclickinfo("Stephen Fry") # ZeroClickInfo object
  
zci.heading # Stephen Fry
zci.abstract_text # Stephen John Fry is an English actor, screenwriter, author, playwright, ...
zci.related_topics["_"][0].text # Stephen Fry (cricketer) ...

The Zero Click API supports a number of query types. The example above is for an article search. There are also category searches (i.e. Simpsons Characters) and disambiguation searches (i.e. Apple), amongst others.

Its my first ever RubyGem, having only just taught myself Ruby. I think its OK, but please let me know if you have any feedback.

You can install from RubyGems and the docs are available at RubyDoc. The source code is available at GitHub.