A MediaWiki API Wrapper

A wrapper for the MediaWiki API, aimed particularly at the Wikimedia 'production' wikis, such as Wikipedia. It can be used to retrieve page text, information about users or the history of pages, and elements of the category tree.

An R API wrapper for MediaWiki, optimised for the Wikimedia Foundation MediaWiki instances, such as Wikipedia.

Author: Oliver Keyes
License: MIT
Status: Stable



WikipediR is a wrapper around the MediaWiki API, optimised for the Wikimedia Foundation's production sites, such as Wikipedia. It is written in and for R, a statistical environment and associated programming language in heavy use by HCI researchers that, somehow, escaped having an API wrapper until now.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.


For the most recent version, on CRAN:


For the development version:



WikipediR currently lacks:

  • Quite a few possible API calls;
  • Direct authentication, through MediaWiki or OAuth.

These issues will be solved in time; if there is a particular feature you want, open an issue here on github: I can't prioritise if I don't know what people are trying to do :).


  • R. Doy.
  • httr and its dependencies.


Version 1.5.0


  • https is now the default for requests (Thanks to Hiroaki Yutani)
  • UTF-8 page names and similar are properly handled (Thanks to Hiroaki Yutani)

Version 1.4.0


  • random_page now allows you to return more than one page.
  • page_backlinks does as well; thanks to Brock Tibert for the code.


  • Vignette tweaks made
  • Package-level documentation improved.


  • "Depends" switched out for "Imports" to avoid annoying loading messages.

Version 1.3.0


  • Various miscellaneous internal improvements.
  • limit introduced as an argument to pages_in_category - thanks to Ben Marwick for finding the bug.
  • limit introduced as an argument to page_links - thanks to Hui Li of the Universit├Ąt Heidelberg for the initial report.

Version 1.2.0

NEW FEATURES *Random pages can now be retrieved with random_page *pageID based querying is available *Custom user

DEVELOPMENT *Doc tweaks and some simplification of argument parsing around page_content and random_page *Additional unit tests *query() marked as exportable to allow simple third-party plugins into WikipediR

Version 1.0.1

  • Roxygenised documentation, some R CHECK errors fixed.
  • Test suite added for error handlers.

Version 1.0.0

  • First release version
  • Introduction of wiki_usercontribs, which retrieves recent contributions for a specified username
  • Bugfixes to error handling routines
  • Bugfix to problems around wiki_con, where species or commons users were unable to take advantage of CurlOpts.

Version 0.7.0

  • wiki_page now returns the DOM of the relevant page, not the wikimarkup, in line with a suggestion from Scott Chamberlain. This should be parsable by the HTML tree parser in the XML package.

Version 0.6.3

  • Standardisation and cleanup of error handlers, and the introduction of a single central LimitHandler.

Version 0.6.2

  • Bug fix from Scott Chamberlain around wiki_page, switching the content type over to x-wikitext.
  • Introduction of w_timeout as a field in the connector object; will be extended to other CURL options in time.

Version 0.6.1

  • Support for Commons and Wikispecies
  • Addition of wiki_recentchanges(), which allows a useR to query the recentchanges feed.

Version 0.5.1

  • Format for wiki_revision changed from the (unacceptable-to-API) text/css to x/wikitext.
  • Error handling improved to pass the full error explanation through to the user, in the case of API errors.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.5.0 by Oliver Keyes, 5 years ago


Report a bug at https://github.com/Ironholds/WikipediR/issues

Browse source code at https://github.com/cran/WikipediR

Authors: Oliver Keyes [aut, cre] , Brock Tilbert [ctb]

Documentation:   PDF Manual  

Task views: Web Technologies and Services

MIT + file LICENSE license

Imports httr, jsonlite

Suggests testthat, knitr, WikidataR, pageviews

Imported by WikidataQueryServiceR, WikidataR, tosca, wikilake.

Suggested by pageviews.

See at CRAN