Skip to content

Build on the API

Every Music Assistant server offers the same API that its own frontend, the apps and the Home Assistant integration use. This page helps you connect to it and find the reference for what you build.

  • A client or a dashboard that browses the library and controls players and queues.
  • An integration that connects Music Assistant to another system.
  • A player: a device or an app that Music Assistant streams to.
  • The Python client and the shared models themselves.
  1. Open the API documentation of a server. Every server serves it at /api-docs, such as http://localhost:8095/api-docs: a commands reference with examples, a schemas reference and a Swagger UI.
  2. Get a token. Authentication is required, except through Home Assistant Ingress. Sign in with POST /auth/login, or create a long-lived token in your profile in the web interface.
  3. Connect.
    • WebSocket at /ws: send the auth command with your token first, then commands with a message_id each. You receive events, such as player_updated, without asking.
    • HTTP at /api: POST a command with the token in an Authorization: Bearer header. Use it for one-off commands.
  4. Check the schema version. GET /info (no token needed), and the first message on a WebSocket connection, give schema_version and min_supported_schema_version. Gate a feature of your client on the schema_version that introduced it.
  5. Use the Python client if you write Python: pip install music-assistant-client. The Home Assistant integration uses it too. Its models come from music-assistant-models, which the server shares.

For listings (sorting, filtering, paging and random order), follow the listing contract. For listening statistics, see the statistics API.

Music Assistant streams to its own players with Sendspin. The Sendspin provider README explains how a browser, an app or a hardware device connects, and links the Sendspin protocol specification.

  • The API documentation at /api-docs on any server: the commands and models of that server version.
  • The webserver README: the routes, authentication, tokens, user roles and remote access.
  • API_SCHEMA_VERSION in constants.py says when the server raises the schema version.
  • The client README: authentication and usage of the Python client.
  • API and events: how the API works inside the server.

Music Assistant is a project of the Open Home Foundation.