Skip to content
Steve edited this page Aug 13, 2017 · 8 revisions

RESTBase offers a subset of MediaWiki API functions at much higher performance. It is used by the Mediawiki Foundation for high-volume activities. Wptools provides access to most /page entry points to the RESTBase API https://en.wikipedia.org/api/rest_v1/. Calling get_rest() without any arguments will print available /page entry points to stderr:

>>> page.get_rest()
en.wikipedia.org (rest) /page/
RESTBase /page/ entry points: [u'data-parsoid', u'graph', u'html', u'mobile-sections', u'mobile-sections-lead', u'mobile-sections-remaining', u'pdf', u'random', u'related', u'revision', u'segments', u'summary', u'title', u'wikitext']

RESTBase /page entry points that require only a title will yield a useful result. RESTBase is still evolving, so we only populate page attributes for a selction of entry points. For example, /page/summary:

>>> page = wptools.page('Mount Everest').get_rest('/page/summary')
Mount_Everest (en)
{
  lang: en
  title: Mount_Everest
}
en.wikipedia.org (rest) /page/summary/Mount_Everest
Mount_Everest (en)
{
  cache: <dict(1)> {rest}
  description: <str(144)> Earth's highest mountain, with a peak at 8...
  endpoint: /page/summary/Mount_Everest
  exhtml: <str(467)> <p><b>Mount Everest</b>, also known in Nepali a...
  exrest: <str(443)> Mount Everest, also known in Nepali as Sagarmāt...
  images: <list(2)>
  lang: en
  pageid: 42179
  title: Mount_Everest
  url: https://en.wikipedia.org/wiki/Mount_Everest
  url_raw: https://en.wikipedia.org/wiki/Mount_Everest?action=raw
}

See the get_rest() method for details.

Clone this wiki locally