API:Get the contents of a page

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


 * 1) Get the contents of a page using the  API (as wikitext).


 * 1) Get the contents of a page using the  API (as HTML or 2>Special:MyLanguage/Wikitext|wikitext).


 * 1) Get plain text or limited HTML extracts of a page using the 1>Special:MyLanguage/Extension:TextExtracts#API|API of the TextExtracts extension.

Method 1: Use the Revisions API
The  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   parameter and setting the   parameter to  . For more options, see .

Example
GET request to obtain the wikitext content of the page <tvar|1>Pet door</>.

Method 2: Use the Parse API
The <tvar|1></> 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 <tvar|1> </> parameter or a revision with the <tvar|2> </> parameter. To retrieve HTML, set <tvar|1> </> to <tvar|2> </>. To retrieve Wikitext, set <tvar|1> </> to <tvar|2> </>.

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

Response
\n\n\n\n\n "   } }

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

Method 3: Use the TextExtracts API
The <tvar|1></> extension provides an API which allows you to retrieve plain-text or limited HTML extracts of page content. See <tvar|1></> for additional documentation.

Example
Get request to extract 10 sentences from the page <tvar|1>Pet door</>.

Additional notes
The content extracted directly from Wikipedia can be inserted into any MediaWiki wiki through <tvar|1></>. The content extracted comes in the form of limited wikitext, omitting leading templates, links to files or pages.