duckduck_answer: Call DuckDuckGo Instant Answer API

Description Usage Arguments Value See Also Examples

Description

Makes a synchronous API call to the DuckDuckGo Instant Answer API. Take a look at DuckDuckGo's terms of use (https://api.duckduckgo.com/api) before using it.

Usage

1
2
duckduck_answer(query, no_redirect = FALSE, no_html = FALSE,
  skip_disambig = FALSE, app_name = "duckduckr")

Arguments

query

the query string

no_redirect

TRUE to skip HTTP redirects (for !bang commands)

no_html

TRUE to remove html from results

skip_disambig

TRUE to to skip disambiguation (D) Type.

app_name

the appname used to identify your application.

Value

Always returns a list. If the API call was successful it contains the response of the duckduckgo API as parsed by fromJSON. In addition the object's attributes contain additional meta data. Especially the status attribute indicates if something went wrong during the HTTP call or parsing of the JSON text.

In case the call was successful the status attribute is equal to "OK".

In case something went wrong, the status attribute is equal to "error" and in the error attribute you will find more information. In particular the type, which is either "http_error" or "json_parse_error" depending on the error's source.

In case of a "http_error", there is an additional message and http_status element.

In case of "json_parse_error", there is an additional message element.

In addition there is always a source element with the URL used to query the data.

See Also

https://api.duckduckgo.com/api for more information on the API and their terms of use.

Examples

1
2
3
4
5
## Not run: 
tmp <- duckduck_answer("duckduckgo")
tmp$Abstract

## End(Not run)

duckduckr documentation built on May 2, 2019, 7:22 a.m.