Node.js wrapper for the DuckDuckGo Instant Answers API.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 3ef82e1 Oct 2, 2013
Failed to load latest commit information.
lib Update ddg.js Oct 2, 2013
node_modules/request first commit v0.0.1 Aug 1, 2013
test Added v0.0.2 Aug 1, 2013
.gitignore first commit v0.0.1 Aug 1, 2013
.npmignore first commit v0.0.1 Aug 1, 2013
LICENSE first commit v0.0.1 Aug 1, 2013 Update Sep 13, 2013
index.js Update index.js Aug 25, 2013
package.json Update package.json Aug 15, 2013


Node.js wrapper for DuckDuckGo's Instant Answers API.


$ npm install ddg

It's that simple.


ddg = require('ddg');

ddg.query("duckduckgo", function(err, data){
	console.log(data) // logs a dictionary with all return fields

See the instant answers API docs for more information on the return fields

Custom options

ddg = require('ddg');

options = {
		"useragent": "My duckduckgo app",
		"no_redirects": "1",
		"no_html": "0",

ddg.query('duckduckgo', options, function(err, data){

List of all options

  • useragent
  • format (json or xml)
  • pretty (default: 1)
  • no_html (default: 0)
  • skip_disambig (default: 0)
  • no_redirects (default: 1)

Getting query AbstractText

Here I'm making a query for 'bioshock' and loging the AbstractText taken from Wikipedia.

ddg = require('ddg');

ddg.query('bioshock', options, function(err, data){


BioShock is a first-person shooter video game developed by Irrational Games (at the time, named 2K Boston), and published by 2K Games.

Generating information from results (url,text)

With Instant Answers API + node-ddg it becomes quite simple to get duckduckgo data.

ddg = require('ddg')

ddg.query('bioshock', function(err, data){
	results = data.RelatedTopics; //related topics is a list of 'related answers'
	for (i=0;i<results.length;i++) {
		console.log('-- '+results[i].Text)

-- BioShock (series) - BioShock is a first-person shooter video game series 
developed by Irrational Games—the first under the name 2K Boston/2K Australia—and 
designed by Ken Levine.
-- Video games set in the 1960s
-- Art Deco games
-- Video games using Havok
-- Alternate history video games
-- Dystopian fiction
-- Video games developed in Australia
-- Games for Windows certified games
-- Unreal Engine games
-- Video games developed in Canada

Now you can get and manipulate data from the API in a clean and asynchronous fashion.

Access fields directly

If you want to get one specific field and nothing else, you can use the field you want as a method and run it as seen below.

ddg = require('ddg');

ddg.Definition('lion', function(err, data){


 lion definition: a large heavily built social cat ('''Panthera leo''') of open or
 rocky areas chiefly of sub-Saharan Africa though once widely distributed 
 throughout Africa and southern Asia that has a tawny body with a tufted tail and
  a shaggy blackish or dark brown mane in the male.

Here's a list of all Instant Answer API root fields (supported)

  • Abstract
  • AbstractText
  • AbstractSource
  • AbstractURL
  • Image
  • Heading
  • Answer
  • AnswerType
  • Definition (used in example above)
  • DefinitionSource
  • DefinitionURL
  • RelatedTopics
  • Results
  • Type
  • Redirect


Github - jawerty

Twitter - @jawerty

Email -

Website -



This project has no offiliation with the company DuckDuckGo.