Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Library for querying the DuckDuckGo API

Project Description

A Python library for querying the DuckDuckGo API.

Copyright Michael Stephens <>, released under a BSD-style license.

Source: Original source: (outdated)

This version has been forked from the original to handle some new features of the API, and switch from XML to JSON.


To install run

python install


>>> import duckduckgo
>>> r = duckduckgo.query('DuckDuckGo')
>>> r.type
>>> r.results[0].text
u'Official site'
>>> r.results[0].url
>>> r.abstract.url
>>> r.abstract.source
>>> r = duckduckgo.query('Python')
>>> r.type
>>> r.related[1].text
u'Python (programming language), a computer programming language'
>>> r.related[1].url
>>> r.related[7].topics[0].text # weird, but this is how the DDG API is currently organized
u'Armstrong Siddeley Python, an early turboprop engine'
>>> r = duckduckgo.query('1 + 1')
>>> r.type
>>> r.answer.text
u'1 + 1 = 2'
>>> r.answer.type
>>> print duckduckgo.query('19301', kad='es_ES').answer.text
19301 es un código postal de Paoli, PA
>>> print duckduckgo.query('how to spell test', html=True).answer.text
<b>Test</b> appears to be spelled right!<br/><i>Suggestions: </i>test, testy, teat, tests, rest, yest.
The easiest method of quickly grabbing the best (hopefully) API result is to use duckduckgo.get_zci::
>>> print duckduckgo.get_zci('foo')
The terms foobar /ˈfʊːbɑːr/, fubar, or foo, bar, baz and qux are sometimes used as placeholder names in computer programming or computer-related documentation. (
>>> print ddg.get_zci('foo fighters site')
Special keyword args for query():
  • useragent - string, The useragent used to make API calls. This is somewhat irrelevant, as they are not logged or used on DuckDuckGo, but it is retained for backwards compatibility.
  • safesearch - boolean, enable or disable safesearch.
  • html - boolean, Allow HTML in responses?

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(5.0 kB) Copy SHA256 Hash SHA256
Source None Jun 3, 2013

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers