API:Get the contents of a page

From MediaWiki.org
Jump to navigation Jump to search

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

  1. Get the content of a page through API: Revisions .
  2. Get parsed content of a page through API: Parse .
  3. Get plain text or limited HTML extracts of a given page through Extension: TextExtracts#API .

Method 1: Get the content of a page through API: Revisions[edit]

This can be done by specifying the parameter titles of the page. The retrieved content is in the form of wikitext.

Example[edit]

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

Response[edit]

Method 2: Get the parsed content of a page by API: Parse[edit]

This can be done by:

  1. Specifying a page or revision using the parameter page. The retrieved content is in the form of HTML.
  2. Specifying parameter prop as wikitext to get the original wikitext that was parsed. The retrieved content is in the form of wikitext.

Example 1[edit]

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

Response[edit]

Example 2[edit]

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

Response[edit]

Method 3: Get the content of the page using Extension: TextExtracts#API[edit]

The TextExtracts extension provides an API which allows to retrieve plain-text or limited HTML extracts of page content.

Example[edit]

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

Response[edit]

Additional notes[edit]

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

See also[edit]