API:Get the contents of a page

Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎polski • ‎русский • ‎中文 • ‎日本語 • ‎한국어

There are three main methods for retrieving page content via the API:

  1. Get the contents of a page using the Revisions API (as wikitext).
  2. Get the contents of a page using the Parse API (as HTML or wikitext).
  3. Get plain text or limited HTML extracts of a page using the API of the TextExtracts extension.

Method 1: Use the Revisions APIEdit

The Revisions API can be used to retrieve the content of a page as wikitext. This can be done by specifying the title of the page in the titles parameter and setting the rvprop parameter to content. For more options, see API:Revisions .

ExampleEdit

GET request to obtain the wikitext content of the page Pet door.

ResponseEdit

Method 2: Use the Parse APIEdit

The Parse API can be used to retrieve page content in either HTML format (parsed) or Wikitext format (unparsed). This can be done by specifying a page with the page parameter or a revision with the oldid parameter. To retrieve HTML, set prop to text. To retrieve Wikitext, set prop to wikitext.

Example 1Edit

GET request to get parsed HTML content of a page: Pet door

ResponseEdit

Example 2Edit

GET request to get the original wikitext content of a page: Pet door

ResponseEdit

Method 3: Use the TextExtracts APIEdit

Note that the TextExtracts extension must be installed on the wiki in order to use this method. To see if it is installed, go to Special:Version on the wiki you are targeting.

The TextExtracts extension provides an API which allows you to retrieve plain-text or limited HTML extracts of page content. See Extension:TextExtracts for additional documentation.

ExampleEdit

Get request to extract 10 sentences from the page w:Pet door.

ResponseEdit

Additional notesEdit

The content extracted directly from Wikipedia can be inserted into any MediaWiki wiki through Extension:InterwikiExtracts . The content extracted comes in the form of limited wikitext, omitting leading templates, links to files or pages.

See alsoEdit