reqMediaWiki {wikiTools}R Documentation

Uses httr package to retrieve responses using the MediaWiki API.

Description

For MediaWiki requests only user_agent is necessary in the request headers. See https://www.mediawiki.org/wiki/API:Etiquette. The standard and default output format in MediaWiki is JSON. All other formats are discouraged. The output format should always be specified using the request param "format" in the "query" request. See https://www.mediawiki.org/wiki/API:Data_formats#Output.

Usage

reqMediaWiki(
  query,
  project = "en.wikipedia.org",
  method = "GET",
  attempts = 2,
  debug = FALSE
)

Arguments

query

A list with de (key, values) pairs with the search. Note that if titles are included in the query, the MediaWiki API has a limit of 50 titles in each query. If number of titles is greater than this limit a error is raised.

project

The Wikimedia project to search. Default en.wikipedia.org.

method

The method used in the httr request. Default 'GET'. Note in "https://www.mediawiki.org/wiki/API:Etiquette#Request_limit": "Whenever you're reading data from the web service API, you should try to use GET requests if possible, not POST, as the latter are not cacheable."

attempts

On ratelimit errors, the number of times the request is retried using a 60 seconds interval between retries. Default 2. If 0 no retries are done.

debug

For debugging purposes (default FALSE). If debug='info' information about chunked queries is shown. If debug='query' also the query launched is shown.

Value

The response in JSON format, raise exception on errors.

Author(s)

Angel Zazo, Department of Computer Science and Automatics, University of Salamanca


[Package wikiTools version 1.2.7 Index]