API:Opensearch

From MediaWiki.org
Jump to: navigation, search
MediaWiki version: 1.9
Tools clipart.png This page is part of the MediaWiki API documentation.
Language: English  • polski
MediaWiki API

Quick overview:

v · d · e

Contents

[edit] Parameters

  • search – the search string
  • limit – maximum amount of results to return (defaults to 10)
  • namespacenamespace numbers to search (delimited by |, defaults to 0)
  • suggest – do nothing if $wgEnableOpenSearchSuggest is false
  • format – see below

[edit] Error Codes

  • readapidenied – You need read permission to use this module.

[edit] Note on case sensitivity

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.

[edit] Example

The opensearch API module handles formats differently. Only XML and JSON (and their formatted versions) are recognized, every other valid format parameter results in JSON. The JSON format returns an array containing the search query and an array of result titles: JSON

[
        "api",
        [
                "API",
                "Apiales",
                "Apiaceae",
                "Apia",
                "Apicomplexa",
                "Apicomplexa lifecycle stages",
                "Apidae",
                "APIA Leichhardt Tigers",
                "Apical membrane",
                "Apical consonant"
        ]
]

The XML format returns an OpenSearch XML file with titles, URLs and short descriptions: XML

<?xml version="1.0"?>
<SearchSuggestion version="2.0" xmlns="http://opensearch.org/searchsuggest2">
  <Query xml:space="preserve">api</Query>
  <Section>
    <Item>
      <Text xml:space="preserve">Application programming interface</Text>
      <Description xml:space="preserve">An application programming interface (API) is a particular set of rules and specifications that a software program can follow to access and make use of the services and resources provided by another particular software program that implements that API. </Description>
      <Url xml:space="preserve">http://en.wikipedia.org/wiki/Application_programming_interface</Url>
    </Item>
    <Item>
      <Text xml:space="preserve">Apiales</Text>
      <Description xml:space="preserve">The Apiales are an order of flowering plants. </Description>
      <Url xml:space="preserve">http://en.wikipedia.org/wiki/Apiales</Url>
      <Image source="http://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Umbella.jpg/50px-Umbella.jpg" width="50" height="46" />
    </Item>
  </Section>
</SearchSuggestion>

[edit] See also