Function dracor_api()
sends a GET request to DraCor API with a
specified expected type and parses results depending on selected expected
type.
dracor_api(
request,
expected_type = c("application/json", "application/xml", "text/csv", "text/plain"),
parse = TRUE,
default_type = FALSE,
split_text = TRUE,
as_tibble = TRUE,
...
)
A content of a response to GET method to the 'DraCor' API. If
parse = FALSE
or default_type = TRUE
, a single character value
is returned. Otherwise, the resulting value is parsed according to a value of
default_type
parameter. The resulting structure of the output depends
on the selected default_type
value, the respective function for
parsing (see default_type
) and additional parameters that are passed
to the function for parsing.
Character, valid GET request.
Character, 'MIME' type: one of
"application/json"
, "application/xml"
, "text/csv"
,
"text/plain"
.
Logical, if TRUE
(default value), then a response is
parsed depending on expected_type
. See details below.
Logical, if TRUE
, default response data type is
returned. Therefore, a response is not parsed and parse
is ignored.
The default value is FALSE
.
Logical, if TRUE
, plain text lines are read as
different values in a vector instead of returning one character value.
Default value is TRUE
.
Logical, if TRUE
, data frame will be returned as a
tidyverse tibble (tbl_df
). The default value is TRUE
.
Other arguments passed to a parser function.
There are four different 'MIME' types (aka internet media type) that can be
retrieved for DraCor API, the specific combination of possible 'MIME' types
depends on API command. When parse = TRUE
is used, the content is
parsed depending on selected 'MIME' type in expected_type
:
application/json
application/xml
text/csv
text/plain
No need for additional preprocessing
dracor_sparql
dracor_api("https://dracor.org/api/v1/info", expected_type = "application/json")
Run the code above in your browser using DataLab