From MediaWiki.org
Jump to: navigation, search
MediaWiki version: 1.9
Tools clipart.png This page is part of the MediaWiki action API documentation.
MediaWiki APIsAPI:Main page

MediaWiki action API

v · d · e

This API is provided by MediaWiki core starting with MediaWiki version 1.25 (gerrit:171573) Prior to MediaWiki 1.25, you needed to install the OpenSearch extension.

Module documentation[edit]


(main | opensearch)
  • This module requires read rights.
  • Source: MediaWiki
  • License: GPL-2.0+

Search the wiki using the OpenSearch protocol.


Search string.


Maximum number of results to return.

No more than 100 (100 for bots) allowed.
Type: integer or max
Default: 10

Namespaces to search.

Values (separate with |): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600
Default: 0

Do nothing if $wgEnableOpenSearchSuggest is false.

Type: boolean (details)

How to handle redirects:

Return the redirect itself.
Return the target page. May return fewer than limit results.

For historical reasons, the default is "return" for format=json and "resolve" for other formats.

One of the following values: return, resolve

The format of the output.

One of the following values: json, jsonfm, xml, xmlfm
Default: json

If warnings are raised with format=json, return an API error instead of ignoring them.

Type: boolean (details)

Search profile to use.

Strict profile with few punctuation characters removed but diacritics and stress marks are kept.
Few punctuation characters, some diacritics and stopwords removed.
Similar to normal with typo correction (two typos supported).
Classic prefix, few punctuation characters and some diacritics removed.
One of the following values: strict, normal, fuzzy, classic
Default: fuzzy
Find pages beginning with Te.
api.php?action=opensearch&search=Te [open in sandbox]

Note on case sensitivity[edit]

Page name searches are case-sensitive. If $wgCapitalLinks is true (this is the default), the first letter is case-insensitive. If the TitleKey extension is enabled, page name searches are entirely case-insensitive.

Result format[edit]

The opensearch API module handles formats differently. It only recognizes XML and JSON (and their *fm formatted versions); every other valid format parameter results in JSON. The JSON format returns an array containing the search query and an array of result titles.

Example of API response in jsonfm format

If the wiki loads the OpenSearchXml extension or is running MediaWiki version 1.25 or greater, which merged this extension into core, then the XML format returns an OpenSearch XML document with titles and URLs. Furthermore

  • if the wiki loads the TextExtracts extension and configures $wgExtractsExtendOpenSearchXml true, then each Item in the XML format may include a <Description> tag with a text extract from the article.
  • likewise, if the wiki loads the PageImages extension and configures $wgPageImagesExpandOpenSearchXml true, then each Item in the XML format may include an <Image> tag with a thumbnail image from the article.

Example API response in xmlfm format

See also[edit]