get_rest_resource {wikkitidy}R Documentation

Get resources from one of Wikipedia's two REST APIs

Description

This function is intended for developer use. It makes it easy to quickly generate vectorised calls to the different APIs.

Usage

get_rest_resource(
  ...,
  language = "en",
  api = c("core", "wikimedia", "wikimedia_org", "xtools"),
  response_format = c("json", "html"),
  response_type = NULL,
  failure_mode = c("error", "quiet")
)

Arguments

...

<dynamic-dots> The URL components and query parameters of the desired resources. Names of the arguments are ignored. The function follows the tidyverse vector recycling rules, so all vectors must have the same length or be of length one. Unnamed arguments will be appended to the URL path; named arguments will be added as query parameters

language

Character vector of two-letter language codes

api

The desired REST api: "core", "wikimedia", "wikimedia_org", or "xtools"

response_format

The expected Content-Type of the response. Currently "html" and "json" are supported.

response_type

The schema of the response. If supplied, the results will be parsed using the schema.

failure_mode

How to respond if a request fails "error", the default: raise an error "quiet", silently return NA

Value

A list of responses. If response_format == "json", then the responses will be simple R lists. If response_format == "html", then the responses will xml_document objects. If response_type is supplied, the response will be coerced into a tibble::tbl_df or vector using the relevant schema. If the response is a 'scalar list' (i.e. a list of length == 1), then it is silently unlisted, returning a simple list or vector.


[Package wikkitidy version 0.1.12 Index]