Skip to content
Steve edited this page Dec 2, 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_restbase() without any arguments will print available /page/ entry points to stderr:

>>> page.get_restbase()
en.wikipedia.org (restbase) /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. For example, /page/summary:

>>> page = wptools.page('Mount Everest')
>>> page.get_restbase('/page/summary/')
en.wikipedia.org (restbase) /page/summary/Mount_Everest
Mount_Everest (en) data
{
  description: <str(144)> Earth's highest mountain, with a peak at...
  exhtml: <str(1070)> <p><b>Mount Everest</b>, known in Nepali as ...
  exrest: <str(1032)> Mount Everest, known in Nepali as Sagarmāthā...
  image: <list(2)> {'kind': 'restbase-original', u'width': 2679, '...
  pageid: 42179
  requests: <list(1)> restbase
  title: Mount_Everest
  url: https://en.wikipedia.org/wiki/Mount Everest
  url_raw: https://en.wikipedia.org/wiki/Mount Everest?action=raw
}
Clone this wiki locally