# One door for everything: the player’s API, written down 🚪

- Link: https://gexis.net/2026/10/28/one-door-for-everything/
- Published: 2026-10-28T18:00:00+01:00
- Author: George

The player’s touch screen and its phone page never reach into the player’s insides.
They knock on one door: a set of addresses on the player that each do one thing,
_set the volume_, _skip to the next track_, _show me what is playing_. That set 
of addresses is called an **API**, and since this phase it is written down in full,
kept true by a test, and can be tried from a browser.

## 🧭 What an API is, in one paragraph

Think of a restaurant menu. You do not walk into the kitchen; you order from the
menu, and the kitchen sends back the dish. An API is the player’s menu. To set the
volume to 40 %, the phone page sends this to the player:

    ```
    POST http://living-room.local:8090/volume
    {"percent": 40}
    ```

`POST /volume` is the dish, `{"percent": 40}` is how you want it. What changed comes
back on a second line that stays open, the **live state**: whenever anything changes(
the track, the volume, the source), the player sends its whole state again, never
a difference, so a listener never has to keep track between messages.

## 🏠 Why write it down

The player’s own screen and phone page use about 90 of these addresses. Anyone else
on the home network can use them too, without a login, just as anyone on it can 
open the player’s settings. That makes the player easy to build on: a home automation
system, a small control panel by the door, an app.

Until now the menu existed only in pieces: tables in the technical guide, the decision
records, and the code itself. Building on it meant reading the code.

## 📄 One file that describes every route

The menu is now one file, `openapi.json`, written in **OpenAPI 3.1**, the common
format for describing web APIs. For every address it says what it takes, what it
answers, how it fails, and which decision record it comes from. It also describes
the live state message, field by field, in 132 small definitions.

The file is written by hand. The web framework the player’s core is built on does
not generate one, and the add-ons that try are thinly maintained. It is JSON rather
than YAML so that neither the player nor its tests need another library to read 
it. And it ships with the player, so every player carries the description of exactly
its own API.

Errors all look the same: a status number and one readable sentence, such as `{"
error": "..."}`. 409 means _not possible right now_, 502 means _a service the player
depends on did not answer_.

## ✅ A test that keeps it honest

A description that has drifted from the code is worse than none, because people 
trust it. So a test lists every address the player’s core actually registers and
compares that list with the file. It fails when:

 * an address exists that the file does not describe;
 * the file describes an address that no longer exists;
 * an entry lacks a summary, a group, a stability mark or its answers;
 * the file names a device or a home network address (it is published, so it must
   not).

A change to an address now changes the file in the same piece of work, or the build
goes red.

## 🔖 Stable and internal

Not every address is meant for outsiders. Some are the player’s own plumbing, for
example the steps of first-time setup or the panel’s private signals. So each one
carries a mark:

 * **stable** (32): what an integration may rely on, such as the live state, playback,
   volume, sources, the library, radio, settings and backups. A stable address changes
   only with notice in the release notes, and keeps working for one more release
   after the notice.
 * **internal** (58): free to change between releases.

## 🧪 Trying it on the player

⌊The player's API page, served by the player itself⌉⌊The player's API page, served
by the player itself⌉
 _The API page on the player: what the API is, where it lives,
and the routes in groups._

In **Settings → System**, right after _Debug logs_, there is a new switch: **API
explorer**. Switched on, the player serves its API page at `/api`, using **Swagger
UI**, a widely used viewer for OpenAPI files. The routes are grouped by what they
are for: Playback, Panel, Library, Settings and so on.

⌊The Playback group opened⌉⌊The Playback group opened⌉
 _The Playback group: each
line is one route, with its method and a one-line summary._

**Every route can be tried**, against that player, with an _Execute_ button. That
includes _restart_ and _reset to factory settings_, which is why the switch is **
off by default**. The page does not add any power: anyone on the home network can
already call those routes. It only makes them a button, and a button is easy to 
press by accident. Switched off, `/api` is simply not there; the API itself works
the same either way.

Swagger UI is served from the player’s own files, under 2 MB, because a player cannot
count on the internet. It is listed in _Credits_ with its licence, Apache 2.0.

## 🌐 A copy on GitHub, for reading

The same description is also published as a read-only page on GitHub, built from
the file at each release. It cannot try anything, for a good reason: a public page
on secure HTTPS is not allowed by browsers to call a device on a home network over
plain HTTP. For trying, there is the player’s own page.

## 🐞 What writing it down found

Describing every route meant reading every route, and three of them turned out to
answer wrongly:

 * **Radio** answered a bare server error when the Lyrion server was down. It now
   says what happened, with 502: a service the player depends on did not answer.
 * **Transport** commands (play, pause, next) crashed with a server error when the
   active source had not said which commands it accepts. They are now refused cleanly
   with 409, _not possible now_.
 * **The skins list** said every visualiser skin was outside the player’s own set
   whenever artist pictures from Fanart were switched on. The player’s screen never
   read that flag, but an outside app would have been told the wrong thing. It now
   gives the same answer the visualiser does.

Each has a test that fails without its fix. None of them showed on the player’s 
own screen, which is exactly why they had gone unnoticed.
