Skip to content

Provider pages

A provider can serve a page of its own, such as a small web interface. You declare it in page in the manifest and serve it from handle_page_request(). The app offers it as an entry in its main menu, for each instance the user may use, when the user holds the scope of the page.

"page": {
"label": "Picture frame",
"scope": "library.read",
"icon": "mdi-image-frame"
}
  • label, scope and icon follow the rules of a menu action. To translate the label, put it in the strings.json of the provider under page.label.
  • A page that breaks a rule is left out with a warning in the log, and the provider loads without it. In the server, check_manifests fails on it.

When a user chooses the entry, the app calls the API command providers/open_page with the instance. The server checks that the user may use the instance and holds the scope, and answers a fresh, short-lived address of the page’s root, which the app opens in a new tab. You register no route:

async def handle_page_request(self, request: web.Request, path: str) -> web.StreamResponse:
if path == "status":
return web.json_response({"showing": self._current_item})
return web.Response(text=PAGE_HTML, content_type="text/html")
  • path is the part of the address after the page’s root, "" for the root itself. Return any aiohttp response, a streamed or WebSocket one included.
  • The server calls it only while the user may still use the instance and holds the scope, and runs it as that user (get_current_user()).
  • An address lapses after 15 minutes without a request and after 12 hours in any case (PAGE_IDLE_TIMEOUT and PAGE_MAX_AGE in provider_pages.py).
  • The page runs sandboxed in an origin of its own. It gets no token or cookie and cannot reach the app, so it talks to your provider through relative URLs to its own sub-paths, such as a fetch that returns JSON.
  • The server sets the security headers on every response and removes any cookie.
  • A page may not offer downloads of provider audio (usage policy); the sandbox blocks downloads.

The demo plugin, _demo_plugin_provider, declares a one-line page.

Music Assistant is a project of the Open Home Foundation.