Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
DuckDuckGo is a privacy-focused search engine. This tool provides web search, news, and image search capabilities without requiring an API key.
Installation
pip install "praisonai[tools]"
No API key required!
Quick Start
from praisonai_tools import DuckDuckGoTool
# Initialize
ddg = DuckDuckGoTool()
# Search
results = ddg.search("Python programming")
print(results)
Usage with Agent
from praisonaiagents import Agent
from praisonai_tools import DuckDuckGoTool
agent = Agent(
name="Researcher",
instructions="You are a research assistant. Use DuckDuckGo to search for information.",
tools=[DuckDuckGoTool()]
)
response = agent.chat("Search for the latest Python tutorials")
print(response)
Available Methods
search(query, max_results=5)
Search the web.
from praisonai_tools import DuckDuckGoTool
ddg = DuckDuckGoTool()
results = ddg.search("machine learning basics", max_results=3)
# Returns:
# [
# {"title": "...", "url": "...", "snippet": "..."},
# ...
# ]
news(query, max_results=5)
Get news articles.
news = ddg.news("AI technology", max_results=5)
# Returns:
# [
# {"title": "...", "url": "...", "source": "...", "date": "...", "snippet": "..."},
# ...
# ]
images(query, max_results=5)
Search for images.
images = ddg.images("cute cats", max_results=3)
# Returns:
# [
# {"title": "...", "image_url": "...", "thumbnail": "...", "source": "..."},
# ...
# ]
Configuration Options
ddg = DuckDuckGoTool(
proxy="socks5://localhost:9050", # Optional: use proxy
timeout=10 # Request timeout in seconds
)
Function-Based Usage
from praisonai_tools import duckduckgo_search
# Quick search without instantiating class
results = duckduckgo_search("latest tech news", max_results=5)
CLI Usage
# Use with praisonai (no API key needed)
praisonai --tools DuckDuckGoTool "Search for Python best practices"
Error Handling
from praisonai_tools import DuckDuckGoTool
ddg = DuckDuckGoTool()
results = ddg.search("my query")
if results and "error" in results[0]:
print(f"Error: {results[0]['error']}")
else:
for r in results:
print(f"- {r['title']}: {r['url']}")
Common Errors
| Error | Cause | Solution |
|---|
duckduckgo-search not installed | Missing dependency | Run pip install duckduckgo-search |
RatelimitException | Too many requests | Add delay between requests or use proxy |
TimeoutException | Request timeout | Increase timeout or check network |
Advantages
- No API key required - Works out of the box
- Privacy-focused - No tracking
- Multiple search types - Web, news, images
- Free - No usage limits (respect rate limits)
- Tavily - AI-powered search
- Exa - Neural search engine
- Serper - Google search API