API:Search and discovery

MediaWiki, its extensions, and its sibling projects hold tremendous potential for knowledge discovery through search. The mechanisms, tools, and services for doing so are maintained by the Search and Discovery team.

Searching MediaWiki
The quickest way to find information in MediaWiki is to look it up directly.

Navigating Wikidata
Get started by reading Help:Navigating_Wikidata.

MediaWiki API
The MediaWiki API has several search-related modules. You can make requests and view generated help at any wiki's /w/api.php entry point, or fill in API request parameters at Special:ApiSandbox.

Search modules

 * action=opensearch
 * See API:Opensearch. Returns search results in OpenSearch format, each with text extract  on Wikimedia projects.   View generated API help


 * action=languagesearch
 * Search for language names in any script. View generated API help

Query list submodules
These Query submodules return a list of wiki pages matching the search criteria, and some return additional information about each page. Furthermore, you can use each as a generator to provide many other  Properties of the set of returned pages, such as a lead image, snippet, and/or page description.


 * action=query list=prefixsearch
 * This merely returns wiki page titles with the given prefix. See the showcase article  Page info in search results.  View generated API help.


 * action=query list=search
 * See API:Search page. On Wikimedia wikis it provides search results from CirrusSearch, returning typical search result information such as text snippets and page size.   View generated API help


 * action=query list=geosearch
 * Returns wiki pages near a location, with their geographical information. See GeoData extension information]] and the showcase article  Showing nearby wiki information.  View generated API help.

Wikidata query service
Wikidata query service is a work in progress to allow graph-based searching of Wikidata via RDF.

CirrusSearch API
CirrusSearch is a MediaWiki extension to enable Elastic-based search of MediaWiki content. is the main interface to this.

In addition, CirrusSearch can report its configuration and internal information. These APIs are probably only useful if you're familiar with Elasticsearch and want to see how CirrusSearch uses it.
 * page parameter
 * This is an action parameter to index.php, for example https://en.wikipedia.org/wiki/Special:Search/cat%20dog%20chicken?cirrusDumpQuery


 * parameter to Special:Search queries
 * For example, https://en.wikipedia.org/wiki/2014?action=cirrusdump


 * API modules cirrus-config-dump, cirrus-settings-dump, cirrus-mapping-dump
 * These dump the CirrusSearch setup.

Wikidata
Wikidata's API includes a few actions (wbgetentities, wbgetclaims, wbsearchentities) that can be used to search for information about entities, properties, statements, and claims. Let's explore the first one,.

Command line
Using the command line, we can get lots of information about an entity. Let's try item Q39246:

With a little work, we can see that Q39246 is the Wikidata identifier for Richard Feynman, and that there are 48 claims made about him.

Web browser
We can perform the above steps right from the Web browser's JavaScript console. On Wikipedia, the Wikidata item identifier is available via the MediaWiki configuration value.

Browse to https://en.wikipedia.org/wiki/Richard_Feynman, open up the JavaScript console, and run the following:

The output is pretty long, and includes the full JSON representation of entity Q39246. We can dig into it as before from the  callback function:

This outputs the string  to the JavaScript console.

User JavaScript pages
With common.js and a bit of elbow grease, we can build and embed a graphical Wikidata explorer right in Wikipedia articles: