DDGS (formerly duckduckgo-search)

9.13.0 · active · verified Thu Apr 09

DDGS is a Python metasearch library that aggregates results from various web search services, including DuckDuckGo, Bing, and Google, without requiring an API key. It provides programmatic access to different search types such as text, images, videos, news, and books. The library is actively maintained, with frequent releases; the current version is 9.13.0.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize the DDGS client and perform a basic text search. It also includes an example of an image search, showcasing common parameters like region, safesearch, timelimit, and max_results. Results are returned as a list of dictionaries.

from ddgs import DDGS

# Initialize DDGS with optional proxy or timeout
ddgs_client = DDGS(timeout=20)

# Perform a text search
results = ddgs_client.text(
    "python programming tutorials",
    region="wt-wt", # worldwide
    safesearch="moderate",
    timelimit="y", # past year
    max_results=5
)

for r in results:
    print(f"Title: {r.get('title')}\nURL: {r.get('href')}\n")

# Example of an image search
image_results = ddgs_client.images(
    "cute puppies",
    region="us-en",
    safesearch="off",
    max_results=3
)

if image_results:
    print(f"First image URL: {image_results[0].get('image')}")

view raw JSON →