Duckduckgo API getting search results

tl;dr -- Screen scrape https://duckduckgo.com/html/?q={search_terms}

As other answerers have mentioned, the URL for DuckDuckGo's limited search API is

http://api.duckduckgo.com/?q=x&format=json

x being the search terms you're looking for.

However, please note that this is not a full search API. As DuckDuckGo's API page mentions,

This API does not include all of our links, however. That is, it is not a full search results API or a way to get DuckDuckGo results into your applications beyond our instant answers. Because of the way we generate our search results, we unfortunately do not have the rights to fully syndicate our results. For the same reason, we cannot allow framing our results without our branding. Please see our partnerships page for more info on guidelines and getting in touch with us.

This is an Instant Answer API, and not a full results API. However, there are some Web links within it, e.g. official sites.

So for your stated purpose of

just submitting string queries (the equivalent of typing into the search bar by hand) and saving the URL of the first results (if there are any).

api.duckduckgo.com will not get you what you want.

Your best bet is probably to just screen scrape the non-JS, web version of DuckDuckGo:

https://duckduckgo.com/html/?q=x

looking for elements with a selector of something like div.result or div.web-result.


just change with whatever you want to search for. This will output the results in JSON

https://api.duckduckgo.com/?q=<your search string>&format=json&pretty=1&no_html=1&skip_disambig=1

I think this is what you are asking for