DuckDuckGoSearchAPIWrapper#

class langchain_community.utilities.duckduckgo_search.DuckDuckGoSearchAPIWrapper[source]#

Bases: BaseModel

Wrapper for DuckDuckGo Search API.

Free and does not require any setup.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param backend: str = 'api'#

Options: api, html, lite

param max_results: int = 5#
param region: str | None = 'wt-wt'#

See https://pypi.org/project/duckduckgo-search/#regions

param safesearch: str = 'moderate'#

Options: strict, moderate, off

param source: str = 'text'#

Options: text, news

param time: str | None = 'y'#

Options: d, w, m, y

results(query: str, max_results: int, source: str | None = None) List[Dict[str, str]][source]#

Run query through DuckDuckGo and return metadata.

Parameters:
  • query (str) – The query to search for.

  • max_results (int) – The number of results to return.

  • source (str | None) – The source to look from.

Returns:

snippet - The description of the result. title - The title of the result. link - The link to the result.

Return type:

A list of dictionaries with the following keys

run(query: str) str[source]#

Run query through DuckDuckGo and return concatenated results.

Parameters:

query (str) –

Return type:

str

Examples using DuckDuckGoSearchAPIWrapper