API:Parsing wikitext

From MediaWiki.org
(Redirected from API:Parse)
Jump to: navigation, search
Language: English  • Deutsch • español • 日本語 • 中文
Tools clipart.png This page is part of the MediaWiki action API documentation.
MediaWiki APIsAPI:Main page

MediaWiki action API

v · d · e

These API modules allow calling the parser for preprocessing and rendering.

Retrieving just the raw source wikitext can be done through prop=revisions.


MediaWiki version: 1.12

Returns preprocessed wikitext (comments stripped, templates expanded, etc.)


  • text: Wikitext to preprocess
  • title: Act like the wikitext is on the page specified. Note: This only really matters when parsing links to the page itself or links to subpages, or when using magic words like {{PAGENAME}}. (Default: API.)


Expand wikitext {{Project:Sandbox}}

Possible errors[edit]



Returns parsed wikitext. Extension:TextExtracts provides additional APIs.


  • title: Act like the wikitext is on this page. Note: This only really matters when parsing links to the page itself or subpages, or when using magic words like {{PAGENAME}}. Type: string (Default: API.)
  • text: Wikitext to parse. Type: string
  • summary: Summary to parse. Type: string
  • page: Parse the content of this page. Cannot be used together with text and title. Type: string
  • pageid: Parse the content of this page. Overrides page. Type: string
  • redirects: If the page parameter is set to a redirect, resolve it. Type: bool
  • oldid: Parse the content of this revision. Overrides page and pageid. Type: string
  • prop: Which pieces of information to get. A pipe character | separated list containing one or more of the following options:
    • text: Gives the parsed text of the wikitext.
    • langlinks: Gives the langlinks the parsed wikitext.
    • categories: Gives the categories of the parsed wikitext.
    • categorieshtml: Gives the html version of the categories.
    • languageshtml: Gives the html version of the language links. (removed in 1.24)
    • links: Gives the internal links in the parsed wikitext.
    • templates: Gives the templates in the parsed wikitext.
    • images: Gives the images in the parsed wikitext.
    • externallinks: Gives the external links in the parsed wikitext.
    • sections: Gives the sections in the parsed wikitext (TOC, table of contents).
    • revid: If page was used, specify the ID of the revision parsed.
    • displaytitle: Adds the title of the parsed wikitext.
    • headitems: Gives items to put in the <head> of the page.
    • headhtml: Gives parsed <head> of the page.
    • modules: Gives the modules, scripts, styles and messages used parsed wikitext. 1.24+
    • indicators: Gives the HTML of page status indicators used on the page. 1.25+
    • iwlinks: Gives interwiki links in the parsed wikitext. Note: Section tree is only generated if there are more than 4 sections, if the __TOC__ keyword is present, or if sections is explicitly requested and the page contains headings/sub-headings (overrides __NOTOC__). Type: string
    • wikitext: Gives the original wikitext that was parsed. 1.25+
    • properties: Gives various properties defined in the parsed wikitext. 1.25?+
    • limitreportdata: Gives the limit report in a structured way. Gives no data, when disablepp is set. 1.23+
    • limitreporthtml: Gives the html version of the PP report. Returns empty if disablepp is true. 1.23+
    • parsetree: Gives the XML parse tree of revision content (requires contentmodel=wikitext). 1.26+
  • pst: Do a pre-save transform (PST) on the input before parsing it (makes {{subst:}} work properly, expands tildes to signatures, etc.). Ignored if page, pageid or oldid is used. Type: bool
  • onlypst: Only do a pre-save transform (PST) on the input, don't parse it. Returns the same wikitext, after a PST has been applied. Ignored if page, pageid or oldid is used. Type: bool
  • section: Only retrieve the content of this section number. When the value is new adds a new section, but then requires the text param. Type: string
  • sectiontitle: The title for the new section Type: string 1.26+
  • disablepp: Disable the PP Report from the parser output. Type: bool
  • disableeditsection: Disable edit section links from the parser output. Type: bool 1.24+
  • generatexml: Generate the XML parse tree (requires contentmodel=wikitext). Use prop=parsetree instead. Type: bool (deprecated in 1.26)
  • preview: Parse in preview mode. Type: bool 1.22+
  • sectionpreview: Parse in section preview mode (enables preview mode too). Type: bool 1.22+
  • disabletoc: Disable table of contents in output. Type: bool 1.23+
  • contentformat: Content serialization format used for the input text. Only valid when used with text. One value: text/x-wiki, text/javascript, application/json, text/css, text/plain.
  • contentmodel: Content model of the input text. Default is the model of the specified title, or wikitext if title is not specified. Only valid when used with text. Can be one of the following: wikitext, javascript, css, text, JsonZeroConfig, Scribunto, JsonSchema.
  • uselang: The language code ("en" for English, "fr" for French, etc.) of the language in which the text or the page should be parsed. This is useful for language-dependent content, such as generated by the {{LangSwitch}} template at the Commons, or generally by things dependent on {{int:Lang}}. Prior to MediaWiki 1.17, this worked by accident; since 1.17, it works by design. Type: string


Parse wikitext: [[foo]] [[API:Query|bar]] [http://www.example.com/ baz]

Possible errors[edit]

Code Info
invalidsection The section parameter must be a valid section id or 'new'
missingrev There is no revision ID oldid
missingtitle The page you specified doesn't exist
nosuchpageid There is no page with ID $1
nosuchsection There is no section sectionnumber in page
params The page parameter cannot be used together with the text and title parameters
permissiondenied You don't have permission to view deleted revisions
readapidenied You need read permission to use this module

Note Note: missingtitle is returned only for syntactically invalid page titles (eg. empty). Trying to fetching a missing page will return the rendered HTML of the "page missing" notice, not an error. However, you can check the revid attribute of <param>, which will always be 0 for missing pages.