Build a REST request to one of Wikipedia's specific REST APIs
Source:R/rest-request.R
wikipedia_rest_apis.Rd
core_request_request()
builds a request for the MediaWiki Core REST API, the basic REST
API available on all MediaWiki wikis.
wikimedia_rest_request()
builds a request for the Wikimedia REST API, an additional
api just for Wikipedia and other wikis managed by the Wikimedia
Foundation
Arguments
- ...
<
dynamic-dots
> Components to add to the URL. Unnamed arguments are added to the path of the request, while named arguments are added as query parameters.- language
The two-letter language code for the Wikipedia edition
Value
A core/rest
, wikimedia/rest
, object, an S3 vector that subclasses
httr2_request
(see httr2::request). The request needs to be passed to
httr2::req_perform to retrieve data from the API.
Examples
# Get the html of the 'Earth' article on English Wikipedia
response <- core_rest_request("page", "Earth", "html") %>%
httr2::req_perform()
response <- wikimedia_rest_request("page", "html", "Earth") %>%
httr2::req_perform()
# Some REST requests take query parameters. Pass these as named arguments.
# To search German Wikipedia for articles about Goethe
response <- core_rest_request("search/page", q = "Goethe", limit = 2, language = "de") %>%
httr2::req_perform() %>%
httr2::resp_body_json()