Skip to main content

ddg

Duck Duck Go zero-click api for your command-line

Install

$ pip install ddg

or from the source:

$ python setup.py install

Usage

ddg [-h] [-b] [-d] [-j] [-l] [-s] [-u] [query [query ...]]

www.duckduckgo.com zero-click api for your command-line

positional arguments:

query the search query

optional arguments:
-h, --help

show this help message and exit

-b, --bang

open the !bang redirect url in a new browser tab

-d, --define

return the definition result

-j, --json

return the zero-click info api json response

-l, --lucky

open the result url in a new browser tab

-s, --search

launch a DuckDuckGo search in a new browser tab

-u, --url

return the result url

Examples

Call ddg from your command line to access the Duck Duck Go Zero-Click Info API

$ddg red-black tree
A red–black tree is a type of self-balancing binary search tree, a data structure
used in computer science, typically used to implement associative arrays.

Get the url of the answer source

$ ddg red-black tree -u
https://en.wikipedia.org/wiki/Red-black_tree

Combinining flags behaves as expected

$ ddg schnauzer -d -u
http://www.merriam-webster.com/dictionary/schnauzer

Launch a !Bang redirect in your web browser with the -b flag

Launch a query on Wolfram Alpha

$ ddg wa integral of sin x / x from negative inf to inf -b

Launch a search on Stack Overflow

$ ddg so [c++11] lambda return values -b

Launch a search on Duck Duck Go with -s

$ ddg Lord of the Rings -s

Launch the result url directly with -l

$ ddg python webbrowser -l

ddg plays nice with other utilities in your shell

$ echo "shark" | ddg -dl
$ ddg welsh corgi -u | pbcopy
$ ls | ddg -du

Use -j to output the json response from the API

$ ddg simpsons characters -j >> file.txt

Thanks

The duckduckgo module is a modification from http://github.com/crazedpsyc/python-duckduckgo.
Original duckduckgo module source from http://github.com/mikejs/python-duckduckgo (outdated)

Release history

0.2.2 (2012-12-20)

  • Fixed the error handling for printing results with special characters

0.2.1 (2012-12-18)

  • When an exception is raised in the duckduckgo module, report the error and then return None. This allows ddg.py to continue to the next query rather than performing a sys.exit(1).

  • Updated README

  • Fixed formatting in LICENSE file

  • Changed CHANGES to an rst file

  • Updated the setup.py file

  • Updated the help for all the input arguments

0.2.0 (2012-12-17)

  • Changed the behavior of the -d flag. Rather than prefixing the query with define, now just prioritize the definition result when searching for an answer to the query.

  • Updated README with more examples.

0.1.7 (2012-12-16)

  • Added a new trove classifier and made code more PEP8 compliant

0.1.6 (2012-12-16)

  • Fixed an issue with the -b prefix, please upgrade to the latest version with pip install –upgrade ddg

0.1.5 (2012-12-15)

  • Updated license to MIT

0.1.4 (2012-12-15)

  • Using webbrowser rather than os dependent Popen commands

0.1.1 (2012-12-15)

  • First working version, initial release

Release files for ddg 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ddg 0.2.2
File Size Uploaded
ddg-0.2.2.tar.gz 6.2 kB Details

Release files / ddg-0.2.2.tar.gz

Download URL ddg-0.2.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
db6e5983ebebb8217c602d8b65c425b6c00237583dfa2e49b841d2bcb0b34f15
BLAKE2b-256 checksum
How to use checksums
dd93458f22ec0c7df0db07992cbdd1253a4aa7f634278354161565b193bd0c1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.2 This release

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.7

1 release file

0.1.6

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page