Skip to main content

Crate duckduckgo

Crate duckduckgo 

Source
Expand description

ยง๐Ÿฆ† Duckduckgo

DDG

Crates.io Docs.rs npm PyPI MIT License

duckduckgo is a multi-language toolkit for searching DuckDuckGo from code or the command line. The core is written entirely in Rust and compiled to a native extension, so Python and Node.js callers enjoy the same performance and correctness guarantees as the Rust library, with no runtime dependencies beyond the native extension itself ๐Ÿ—ฟ.

๐Ÿง Linux (Recommended)๐ŸชŸ Windows๐Ÿณ Docker๐Ÿ“ฆ Linux Distros
ddg-tui-linuxddg-tui-windowsddg-tui-linuxddg-tui-linux
Download ddg binaryDownload ddg.exe binarydocker pull wiseaidev/ddgapt install ddg-rs (TODO: Publish)
cargo install duckduckgo --features rust-binarycargo install duckduckgo --features rust-binarydocker run -it wiseaidev/ddgdnf install ddg-rs (TODO: Publish)
ddg โ† launches TUIddg โ† launches TUIRead DOCKER.mdRead PACKAGING.md

ยง๐Ÿค” What does this crate provide?

The library exposes 4 search backends:

  • Instant Answer: the official api.duckduckgo.com JSON endpoint, which returns structured data including abstracts, definitions, direct answers, and related topics.
  • Lite: the minimal lite.duckduckgo.com HTML interface, which returns plain text results without JavaScript.
  • Images: paginated image results via duckduckgo.com/i.js.
  • News: paginated news articles via duckduckgo.com/news.js.

A comprehensive SearchParams builder covers every documented DuckDuckGo URL parameter: region, safe-search, theme, colours, fonts, header behaviour, and more.

ยง๐Ÿฆ€ Rust

The Rust crate is available on crates.io. For a complete API reference, installation guide, and worked examples, visit the Rust Usage Guide.

The crate ships the following Cargo features:

FeatureDescription
rust-binaryEnables the standalone ddg terminal CLI executable
pythonPython extension module via pyo3
nodeNode.js native add-on via napi-derive

ยง๐ŸŒ WebAssembly (WASM)

duckduckgo natively supports the wasm32-unknown-unknown target! Because it uses reqwest under the hood, it seamlessly switches to the fetch API when deployed in the browser.

This makes it perfect for client-side search inside Rust frontend frameworks like Yew, Dioxus, and Leptos. We actively use this technique in the llm/examples/chat application.

For CORS considerations, code examples, and usage details, read the WASM usage guide.

ยง๐Ÿ Python

The Python bindings are published to PyPI as ddg-rs and can be installed with pip install ddg-rs. The package is built with maturin and ships pre-compiled wheels for the major CPython versions.

The Python module exposes the Browser, SearchParams, LiteSearchResult, ImageResult, and NewsResult types. All network methods are synchronous - they drive an embedded Tokio runtime so callers do not need an event loop.

For installation instructions, configuration options, and full method signatures, read the Python usage guide.

ยง๐ŸŸฉ Node.js

The Node.js bindings are published to npm as ddg-rs and can be installed with npm install ddg-rs. The package is built with napi-rs and ships a pre-compiled .node add-on.

The module exposes the Browser class, SearchParams builder, and plain object result types (LiteSearchResult, ImageResult, NewsResult, InstantAnswerResponse). Like the Python API, all network calls are synchronous within the binding.

For installation instructions, type definitions, and examples, read the Node.js usage guide.

ยง๐Ÿ’ป Command-line interface

The ddg binary supports full-text, image, news, and Instant Answer searches directly from the terminal. It accepts a rich set of options including user-agent selection, cookie storage, HTTP proxy support, safe-search, and a choice of result backends.

For the full option reference and usage examples, see the CLI documentation or run ddg --help after installing with cargo install duckduckgo --features rust-binary.

ยง๐Ÿณ Docker Deployment

duckduckgo is completely containerized and includes the CLI and TUI pre-installed.

For instructions on pulling the container and usage, refer to the Docker usage guide.

ยง๐Ÿ“ฆ Linux Distros Packaging (TODO)

For system-wide installations that rely on native package managers, the project includes .deb and .rpm packaging pipelines. This enables installation via apt (Debian/Ubuntu/Kali) and dnf (RedHat/Fedora).

For packaging instructions and build flows, refer to the Linux Packaging guide.

ยง๐Ÿ”’ Privacy

DuckDuckGo does not track users or personalise results. This library makes direct HTTPS requests to the same public endpoints that the browser does. No API key, account, or authentication token is required.

For more information about DuckDuckGoโ€™s privacy practices, visit duckduckgo.com/privacy.

ยง๐Ÿ“š Further reading

ยง๐Ÿ“„ License

Licensed under the MIT License.

ยงโญ Star us

If you use or enjoy this toolkit, please leave us a star on GitHub! It helps others discover the project and keeps the momentum going and the coffee flowing โ˜•.

Star History Chart

Modulesยง

appcli
CLI Application Entry Point
browser
Browser
clicli
colors
icon
params
Search Parameters
response
API Response Types
topic
tuitui
TUI Module
user_agents