Function Repository Resource:

DuckDuckGoQuery

Source Notebook

Query instant answers from the DuckDuckGo safe search engine web API

Contributed by: Daniel de Souza Carvalho

ResourceFunction["DuckDuckGoQuery"]["str"]

sends the query "str" to the web search service DuckDuckGo.

Details

Results are given as an Association.
As this function uses an external API, the performance depends on your connection quality. Your firewall should allow HTTP/S requests.

Examples

Basic Examples (1) 

Query about a particular company:

In[1]:=
ResourceFunction["DuckDuckGoQuery"]["Wolfram Research"] // Dataset
Out[1]=

Scope (5) 

Query about a notable person:

In[2]:=
ResourceFunction["DuckDuckGoQuery"]["Stephen Wolfram"] // Dataset
Out[2]=

Get a list of links to related webpages, with descriptions, for the query "NASDAQ":

In[3]:=
{#["Text"], #["FirstURL"]} & /@ ResourceFunction["DuckDuckGoQuery"]["NASDAQ"]["RelatedTopics"] // ResourceFunction["NiceGrid"]
Out[3]=

Get details about indexed web sites related to the query "White House":

In[4]:=
ResourceFunction["DuckDuckGoQuery"]["White House"][
  "RelatedTopics"] // Dataset
Out[4]=

Get perspectives from unstructured text related to the query:

In[5]:=
DeleteMissing[
 Flatten[Normal[
   Dataset[ResourceFunction["DuckDuckGoQuery"]["White House"]][
      "RelatedTopics"][All, "Topics"][All, All, "Text"]]]]
Out[5]=

Create a word cloud from this text:

In[6]:=
WordCloud[DeleteStopwords[StringJoin[%]]]
Out[6]=

There are many fields in the response and they can be displayed and explored nicely with Dataset:

In[7]:=
ResourceFunction["DuckDuckGoQuery"]["Isaac Newton"] // Dataset

Extract content from an "Infobox":

In[8]:=
Dataset[ResourceFunction["DuckDuckGoQuery"]["Nicola Tesla"]][
   "Infobox"]["content"][All, {"label", "value"}]
Out[8]=

Neat Examples (1) 

Get additional data from DuckDuckGo, such as images:

In[9]:=
SWPic = ResourceFunction["DuckDuckGoQuery"]["Stephen Wolfram"][
   "Image"];
ddgUrl = "https://duckduckgo.com/";
Import[ddgUrl <> SWPic]
Out[11]=

Publisher

Daniel de Souza Carvalho

Version History

  • 1.0.1 – 19 July 2024
  • 1.0.0 – 04 October 2019

Related Resources

Author Notes

DuckDuckGoQuery is a wrapper for the safe search engine web API

License Information