docs.rodeo

MDN Web Docs mirror

OpenSearch description format

The OpenSearch description format can be used to describe the web interface of a search engine. This allows a website to describe a search engine for itself, so that a browser or other client application can use that search engine. OpenSearch is supported by (at least) Firefox, Edge, Safari, and Chrome. (See Reference Material for links to other browsers’ documentation.)

Firefox also supports additional features not in the OpenSearch standard, such as search suggestions. This article focuses on creating OpenSearch-compatible search plugins that support these additional Firefox features.

OpenSearch description files can be advertised as described in Autodiscovery of search plugins.

[!WARNING] OpenSearch plugins can’t be uploaded anymore on addons.mozilla.org (AMO). Search engine feature must use WebExtension API with chrome settings in manifest.json file.

OpenSearch description file

The XML file that describes a search engine follows the basic template below. Sections in [square brackets] should be customized for the specific plugin you’re writing.

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <ShortName>[SNK]</ShortName>
  <Description>[Search engine full name and summary]</Description>
  <InputEncoding>[UTF-8]</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">[https://example.com/favicon.ico]</Image>
  <Url type="text/html" template="[searchURL]"/>
  <Url type="application/x-suggestions+json" template="[suggestionURL]"/>
</OpenSearchDescription>

Autodiscovery of search plugins

Websites with search plugins can advertise them so Firefox users can easily install the plugins.

To support autodiscovery, add a <link> element for each plugin to the <head> of your web page:

<link
  rel="search"
  type="application/opensearchdescription+xml"
  title="[searchTitle]"
  href="[pluginURL]" />

Replace the items in [square brackets] as explained below:

If your site offers multiple search plugins, you can support autodiscovery for them all. For example:

<link
  rel="search"
  type="application/opensearchdescription+xml"
  title="MySite: By Author"
  href="http://example.com/mysiteauthor.xml" />

<link
  rel="search"
  type="application/opensearchdescription+xml"
  title="MySite: By Title"
  href="http://example.com/mysitetitle.xml" />

This way, your site can offer plugins to search by author, or by title.

[!NOTE] In Firefox, an icon change in the search box indicates there’s a provided search plugin. (See image, the green plus sign.) Thus if a search box is not shown in the user’s UI, they will receive no indication. In general, behavior varies among browsers.

Supporting automatic updates for OpenSearch plugins

OpenSearch plugins can automatically update. To support this, include an extra Url element with type="application/opensearchdescription+xml" and rel="self". The template attribute should be the URL of the OpenSearch document to automatically update to.

For example:

<Url type="application/opensearchdescription+xml"
     rel="self"
     template="https://example.com/mysearchdescription.xml" />

[!NOTE] At this time, addons.mozilla.org (AMO) doesn’t support automatic updating of OpenSearch plugins. If you want to put your search plugin on AMO, remove the auto-updating feature before submitting it.

Troubleshooting Tips

If there is a mistake in your Search Plugin XML, you could run into errors when adding a discovered plugin. If the error message isn’t be helpful, the following tips could help you find the problem.

In addition, the search plugin service provides a logging mechanism that may be useful to plugin developers. Use about:config to set the pref browser.search.log to true. Then, logging information will appear in Firefox’s Browser Console (Tools ➤ Browser Tools ➤ Browser Console) when search plugins are added.

Reference Material

In this article

View on MDN