### Navigation

- index
- modules |
- next |
- previous |
- Mopidy 1.0.2 documentation »
- API reference »

# Extension API

If you want to learn how to make Mopidy extensions, read Extension development.

class `mopidy.ext.``Extension`

  Base class for Mopidy extensions

  `dist_name` = None

    The extension’s distribution name, as registered on PyPI

    Example: `Mopidy-Soundspot`

  `ext_name` = None

    The extension’s short name, as used in setup.py and as config section name

    Example: `soundspot`

  `get_command`()

    Command to expose to command line users running `mopidy`.

    Returns: | Instance of a `Command` class.

  `get_config_schema`()

    The extension’s config validation schema

    Returns: | `ExtensionConfigSchema`

  `get_default_config`()

    The extension’s default config as a bytestring

    Returns: | bytes or unicode

  `setup`(registry)

    Register the extension’s components in the extension `Registry`.

    For example, to register a backend:

        def setup(self, registry):
            from .backend import SoundspotBackend
            registry.add('backend', SoundspotBackend)

    See `Registry` for a list of registry keys with a special meaning. Mopidy will instantiate and start any classes registered under the `frontend` and `backend` registry keys.

    This method can also be used for other setup tasks not involving the extension registry. For example, to register custom GStreamer elements:

        def setup(self, registry):
            from .mixer import SoundspotMixer
            gobject.type_register(SoundspotMixer)
            gst.element_register(
                SoundspotMixer, 'soundspotmixer', gst.RANK_MARGINAL)

    Parameters: | registry (`Registry`) – the extension registry

  `validate_environment`()

    Checks if the extension can run in the current environment.

    Dependencies described by `setup.py` are checked by Mopidy, so you should not check their presence here.

    If a problem is found, raise `ExtensionError` with a message explaining the issue.

    Raises: | `ExtensionError`
    Returns: | `None`

  `version` = None

    The extension’s version

    Should match the `__version__` attribute on the extension’s main Python module and the version registered on PyPI.

class `mopidy.ext.``Registry`

  Registry of components provided by Mopidy extensions.

  Passed to the `setup()` method of all extensions. The registry can be used like a dict of string keys and lists.

  Some keys have a special meaning, including, but not limited to:

  - `backend` is used for Mopidy backend classes.
  - `frontend` is used for Mopidy frontend classes.
  - `local:library` is used for Mopidy-Local libraries.

  Extensions can use the registry for allow other to extend the extension itself. For example the `Mopidy-Local` use the `local:library` key to allow other extensions to register library providers for `Mopidy-Local` to use. Extensions should namespace custom keys with the extension’s `ext_name`, e.g. `local:foo` or `http:bar`.

  `add`(name, cls)

    Add a component to the registry.

    Multiple classes can be registered to the same name.

`mopidy.ext.``load_extensions`()

  Find all installed extensions.

  Returns: | list of installed extensions

`mopidy.ext.``validate_extension`(extension)

  Verify extension’s dependencies and environment.

  Parameters: | extensions – an extension to check
  Returns: | if extension should be run

### Navigation

- index
- modules |
- next |
- previous |
- Mopidy 1.0.2 documentation »
- API reference »