openapi: 3.0.3 info: title: Sonda API version: 0.1.0 description: | Sonda is a privacy-first, self-hosted music server. This is its first-party REST API. **Authentication.** Log in with `POST /auth/login` and send the access token as `Authorization: Bearer `. Access tokens are short-lived; renew the session with `POST /auth/refresh`. Each refresh token works once. **Roles.** Operations marked *admin* need an account with the admin role. The first user who registers is the admin. **Errors.** Every error has the same shape: `{"error": {"code": "...", "message": "..."}}`. The `code` is stable and meant for programs; the `message` is for people. **Paging.** Lists take `limit` (default 50, at most 200; a larger value is lowered to 200) and `offset`, and answer with `items`, `total`, `limit` and `offset`. servers: - url: /api/v1 tags: - name: System - name: Auth description: Accounts and sessions. - name: Users description: User management (admin). - name: Libraries description: Named folders of music (admin). - name: Scan description: Indexing the libraries. - name: Catalog description: Browsing and searching what can be played. - name: Playback description: Streaming and listening history. - name: Taste description: What Sonda has learned from your listening, and the settings that are yours. - name: Discovery description: Music outside the library, from external providers an admin switched on, and suggestions scored for you. - name: Providers description: External services Sonda can ask about artists, set up by an admin. paths: /health: get: tags: [System] operationId: getHealth summary: Liveness check responses: '200': description: The server is up. content: application/json: schema: type: object additionalProperties: false required: [status] properties: status: {type: string, enum: [ok]} /openapi.yaml: get: tags: [System] operationId: getOpenAPI summary: This document responses: '200': description: The OpenAPI description of the API. content: application/yaml: schema: {type: string} /auth/register: post: tags: [Auth] operationId: register summary: Create the first user description: | Only works while no user exists. The new user is the admin. Afterwards registration is closed and admins create accounts with `POST /users`. requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/Credentials'} responses: '201': description: The admin account. content: application/json: schema: {$ref: '#/components/schemas/User'} '400': {$ref: '#/components/responses/InvalidInput'} '403': description: A user already exists (`registration_closed`). content: application/json: schema: {$ref: '#/components/schemas/Error'} '409': description: The username is taken (`username_taken`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /auth/login: post: tags: [Auth] operationId: login summary: Open a session requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/LoginRequest'} responses: '200': description: A new session. content: application/json: schema: {$ref: '#/components/schemas/Session'} '400': {$ref: '#/components/responses/InvalidInput'} '401': description: Wrong username or password (`invalid_credentials`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /auth/refresh: post: tags: [Auth] operationId: refresh summary: Renew a session description: | Exchanges a refresh token for a new access token and a new refresh token. The old refresh token stops working. Presenting a spent one again, more than ten seconds after it was used, ends every session of that user; inside those ten seconds it only fails, so two tabs refreshing together do not log each other out. This holds for any spent token, including one revoked by logout or by a password change. requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/RefreshRequest'} responses: '200': description: A new session. content: application/json: schema: {$ref: '#/components/schemas/Session'} '400': {$ref: '#/components/responses/InvalidInput'} '401': description: The refresh token is unknown, expired or already used (`invalid_refresh_token`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /auth/logout: post: tags: [Auth] operationId: logout summary: End a session description: Revokes one refresh token. Always answers 204, so it never reveals whether the token existed. requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/RefreshRequest'} responses: '204': {description: Done.} '400': {$ref: '#/components/responses/InvalidInput'} /auth/me: get: tags: [Auth] operationId: getMe summary: The signed-in account security: [{bearerAuth: []}] responses: '200': description: Your account. content: application/json: schema: {$ref: '#/components/schemas/User'} '401': {$ref: '#/components/responses/Unauthorized'} /auth/password: post: tags: [Auth] operationId: changePassword summary: Change your password description: | Revokes every refresh token of the account, so no session can be renewed. An access token that was already issued keeps working until it expires (15 minutes by default). security: [{bearerAuth: []}] requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/PasswordChange'} responses: '204': {description: Password changed.} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': description: The current password is wrong (`invalid_credentials`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /users: get: tags: [Users] operationId: listUsers summary: List users description: Admin only. security: [{bearerAuth: []}] responses: '200': description: Every account, oldest first. content: application/json: schema: type: object additionalProperties: false required: [users] properties: users: type: array items: {$ref: '#/components/schemas/User'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} post: tags: [Users] operationId: createUser summary: Create a user description: Admin only. security: [{bearerAuth: []}] requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/CreateUser'} responses: '201': description: The new account. content: application/json: schema: {$ref: '#/components/schemas/User'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '409': description: The username is taken (`username_taken`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /users/{id}: parameters: - {$ref: '#/components/parameters/Id'} patch: tags: [Users] operationId: updateUser summary: Grant or remove the admin role description: Admin only. The last admin cannot be demoted. security: [{bearerAuth: []}] requestBody: required: true content: application/json: schema: type: object required: [is_admin] properties: is_admin: {type: boolean} responses: '200': description: The updated account. content: application/json: schema: {$ref: '#/components/schemas/User'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '404': description: No such user (`user_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} '409': description: This is the last admin (`last_admin`). content: application/json: schema: {$ref: '#/components/schemas/Error'} delete: tags: [Users] operationId: deleteUser summary: Delete a user description: | Admin only. Removes the account and its refresh tokens. Access tokens already issued stop working at once on admin routes, `/auth/me`, `/auth/password` and `/listens`; other routes accept them until they expire (15 minutes by default). The last admin cannot be deleted. security: [{bearerAuth: []}] responses: '204': {description: Deleted.} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '404': description: No such user (`user_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} '409': description: This is the last admin (`last_admin`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /users/{id}/password: parameters: - {$ref: '#/components/parameters/Id'} put: tags: [Users] operationId: resetUserPassword summary: Reset a user's password description: | Admin only. Revokes every refresh token of that user, so no session can be renewed. Access tokens already issued keep working until they expire (15 minutes by default). security: [{bearerAuth: []}] requestBody: required: true content: application/json: schema: type: object required: [password] properties: password: type: string format: password description: 8 to 256 bytes (UTF-8). responses: '204': {description: Password reset.} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '404': description: No such user (`user_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /libraries: get: tags: [Libraries] operationId: listLibraries summary: List libraries description: Admin only. security: [{bearerAuth: []}] responses: '200': description: Every library, oldest first. content: application/json: schema: type: object additionalProperties: false required: [libraries] properties: libraries: type: array items: {$ref: '#/components/schemas/Library'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} post: tags: [Libraries] operationId: createLibrary summary: Add a library description: | Admin only. The path must be an absolute, existing directory, never the filesystem root, and never inside or around another library (a bad path or an overlap is `400 invalid_input`). A name or path that another library already uses is `409 library_exists`. Names are unique ignoring case. security: [{bearerAuth: []}] requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/NewLibrary'} responses: '201': description: The new library. content: application/json: schema: {$ref: '#/components/schemas/Library'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '409': description: Another library has this name or path (`library_exists`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /libraries/{id}: parameters: - {$ref: '#/components/parameters/Id'} patch: tags: [Libraries] operationId: updateLibrary summary: Rename or move a library description: | Admin only. Send `name`, `path` or both. Files keep their identity when the path changes. Changing the path is refused while a scan runs. security: [{bearerAuth: []}] requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/LibraryUpdate'} responses: '200': description: The updated library. content: application/json: schema: {$ref: '#/components/schemas/Library'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '404': {$ref: '#/components/responses/LibraryNotFound'} '409': description: The name or path is used by another library (`library_exists`), or a scan is running (`scan_running`). content: application/json: schema: {$ref: '#/components/schemas/Error'} delete: tags: [Libraries] operationId: deleteLibrary summary: Remove a library description: | Admin only. Removes the library and its index entries. Tracks and listening history stay; the music on disk is never touched. Refused while a scan runs. security: [{bearerAuth: []}] responses: '204': {description: Removed.} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '404': {$ref: '#/components/responses/LibraryNotFound'} '409': description: A scan is running (`scan_running`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /libraries/{id}/scan: parameters: - {$ref: '#/components/parameters/Id'} post: tags: [Scan] operationId: scanLibrary summary: Scan one library description: | Admin only. Starts a scan in the background; follow it with `GET /library/scan`. With `full=true` every file is read again, not only the new or changed ones. security: [{bearerAuth: []}] parameters: - {$ref: '#/components/parameters/Full'} responses: '202': {$ref: '#/components/responses/ScanStarted'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '404': {$ref: '#/components/responses/LibraryNotFound'} '409': description: A scan is already running (`scan_running`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /library/scan: get: tags: [Scan] operationId: getScanStatus summary: Scan status description: Whether a scan is running and how the last one ended. security: [{bearerAuth: []}] responses: '200': description: The current state. content: application/json: schema: {$ref: '#/components/schemas/ScanStatus'} '401': {$ref: '#/components/responses/Unauthorized'} post: tags: [Scan] operationId: scanAll summary: Scan every library description: | Admin only. Starts a scan in the background. Only MP3 and FLAC files are read; other audio formats are counted as `unsupported`. Housekeeping folders of NAS boxes (`@Recycle`, `#recycle`, `@eaDir`, `.@__thumb`, `$RECYCLE.BIN`) are skipped. A scan reads the tags of files that are new or changed. Send `full=true` to read every file again: that is how MusicBrainz ids and genres reach music that was indexed before they were read. Files keep their identity, so listening history is kept. security: [{bearerAuth: []}] parameters: - {$ref: '#/components/parameters/Full'} responses: '202': {$ref: '#/components/responses/ScanStarted'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '403': {$ref: '#/components/responses/AdminRequired'} '409': description: A scan is already running (`scan_running`), or there is no library yet (`no_libraries`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /artists: get: tags: [Catalog] operationId: listArtists summary: List artists description: | Artists credited on a playable track, or that are the album artist of an album with one. Sorted by name. security: [{bearerAuth: []}] parameters: - {$ref: '#/components/parameters/Q'} - {$ref: '#/components/parameters/Limit'} - {$ref: '#/components/parameters/Offset'} - {$ref: '#/components/parameters/LibraryId'} responses: '200': description: A page of artists. content: application/json: schema: {$ref: '#/components/schemas/ArtistPage'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} /artists/{id}: parameters: - {$ref: '#/components/parameters/Id'} get: tags: [Catalog] operationId: getArtist summary: One artist security: [{bearerAuth: []}] responses: '200': description: The artist. content: application/json: schema: {$ref: '#/components/schemas/Artist'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: | No such artist (`artist_not_found`). An artist with nothing to play is not found either, unless a provider named it as similar to another artist: those can be shown, with `track_count` and `album_count` of 0, but they are never part of the lists. content: application/json: schema: {$ref: '#/components/schemas/Error'} /artists/{id}/similar: parameters: - {$ref: '#/components/parameters/Id'} get: tags: [Discovery] operationId: getSimilarArtists summary: Artists similar to one description: | Artists an external provider (Last.fm) finds similar to this one, best first. Each says whether it is in the library, and `id` works with `GET /artists/{id}`; one that is not in the library has no files. The provider is only asked when an admin switched it on and the stored answer is missing or old (7 days; a "no such artist" answer is kept 1 day). What is sent is the artist's name or MusicBrainz id and nothing about any user. Several requests for the same artist at once make one call. A provider that is off or failing is not an error: the answer is `200` and `provider_status` says why. Then `items` holds whatever was stored before, if anything, and `stale` is true when it is older than it should be. `score` is the provider's own number between 0 and 1. It is relative to the list it came in (the best one is usually 1), so it only compares artists inside one answer. `rank` is the position. Show `attribution` where you show the data. security: [{bearerAuth: []}] parameters: - name: limit in: query description: How many to return. 20 when absent or 0; values above 50 are lowered to 50, the most that is kept. schema: {type: integer, minimum: 0, default: 20} responses: '200': description: The similar artists. content: application/json: schema: {$ref: '#/components/schemas/SimilarArtists'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such artist (`artist_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /artists/{id}/tags: parameters: - {$ref: '#/components/parameters/Id'} get: tags: [Discovery] operationId: getArtistTags summary: Tags of an artist, from each provider description: | What each provider says kind of music this artist plays: Last.fm's top tags and MusicBrainz's tags and genres, and last the genres of the artist's own music files (`provider` is `files`: the genre tags the scan read, each weighted by how many of the playable tracks the artist is credited on have it; it asks nobody, is always `ok` and has a null `retrieved_at`). There is always one entry for each, Last.fm first. The weights are the providers' own numbers, kept as they came and never mixed: Last.fm's is relative to the artist (1 to 100, the top tag is usually 100; a tag with no votes is dropped), MusicBrainz's is a count of votes. `genre` is true for a MusicBrainz tag that it also lists among its curated genres, and for every tag of the `files` entry, which are genres by definition. A provider is only asked when an admin switched it on and its stored answer is missing or old (7 days; a "no such artist" answer is kept 1 day), with the same rules as `GET /artists/{id}/similar`. What is sent is the artist's name or MusicBrainz id to Last.fm (its id when known), and only the MusicBrainz id to MusicBrainz: Sonda never looks an id up by name. An artist's id comes from the tags in the music files, or from Last.fm for an artist it named that is not in the library; for any other artist the MusicBrainz entry says `no_id`. Show each `attribution` where you show the tags. security: [{bearerAuth: []}] responses: '200': description: One entry per provider. content: application/json: schema: {$ref: '#/components/schemas/ArtistTags'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such artist (`artist_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /discover: get: tags: [Discovery] operationId: discover summary: Artists you may like description: | Suggests artists, in your library or not, each with a `score` from 0 to 1 and the parts it is made of, so every number can be explained. **Where it starts.** From the artists you name with `seed` (one to five, repeat the parameter), or, when you named none and turned on `discover_from_listening` in `PATCH /me/settings`, from the up to 20 artists you play most. With neither the request is refused (`seed_required`) and nothing is sent to anyone. For each seed, the similar artists are the stored ones, or are asked from Last.fm when they are missing or old and an admin switched Last.fm on (see `GET /artists/{id}/similar`). **What is sent**: the name or MusicBrainz id of each seed, and, for the best candidates that have no tags yet, the name of the candidate (tags are asked from Last.fm only, never from MusicBrainz). The seeds from your listening are therefore sent only when you allowed it. A seed is never suggested to itself, and nobody else's listening is read. **The score** is `S = wA·A + wG·G + wP·P + wD·D` with the weights of the server's `[scoring]` config (default 0.40, 0.25, 0.25, 0.10; only their proportions matter). `a` is the affinity: 1 − Π(1 − weight·match) over the seeds that point at the artist, where `match` is Last.fm's similarity (relative to each seed's own list) and `weight` is 1 for a seed you named or your `preference` for one taken from your listening (see `GET /me/taste`). `g` is how close the artist's tags are to the tags of the artists you like (cosine of the tag vectors); it is `null` when there is nothing to compare, and then the score is worked out without it, the other weights rescaled, so a missing part never counts as a bad one. `p` is what your listening says about the artist, from `preference` mapped to 0 to 1, and 0.5 for an artist you never played. `d` is a bonus for what you have not played: `1 / (1 + listens)`. Only the best candidates by affinity (at least 20) are scored, then the best `limit` by score are returned; ties go to the higher affinity, then to the lower id. `because` names up to three seeds that count most for the suggestion. The first request after a seed's data gets old can take several seconds, because the provider is asked politely, a few at a time; later ones are served from the database. `provider_status` is `disabled` when something had to be asked from Last.fm (a seed's similar artists are missing or old) and Last.fm is off or has no key; anything stored earlier is still used, so the list can be empty. With every seed's data stored and fresh the status is `ok` whether Last.fm is on or not. It is `error` when Last.fm failed for some seed (the rest is still returned) and `ok` otherwise. Show `attribution` where you show the data. security: [{bearerAuth: []}] parameters: - name: seed in: query description: An artist id to start from. Repeat up to 5 times. Without it, your listening is used if you allowed that. schema: {type: array, items: {type: integer, format: int64}, maxItems: 5} style: form explode: true - name: limit in: query description: How many suggestions to return. 20 when absent or 0; values above 30 are lowered to 30. schema: {type: integer, minimum: 0, default: 20} - name: in_library in: query description: "`true` keeps only artists you have, `false` only artists you do not. Absent keeps both." schema: {type: boolean} responses: '200': description: The suggestions, best first. content: application/json: schema: {$ref: '#/components/schemas/Discover'} '400': description: A seed that is not an artist, too many seeds, a bad `limit` or `in_library` (`invalid_input`), or no seed and no permission to use your listening (`seed_required`). content: application/json: schema: {$ref: '#/components/schemas/Error'} '401': {$ref: '#/components/responses/Unauthorized'} /discover/dismissed: get: tags: [Discovery] operationId: listDismissed summary: Artists you are not interested in description: | The artists you told Discover you are not interested in (`POST /discover/{id}/dismiss`), newest first. Only yours; nobody else's choices are visible or affect your Discover. security: [{bearerAuth: []}] parameters: - {$ref: '#/components/parameters/Limit'} - {$ref: '#/components/parameters/Offset'} responses: '200': description: A page of artists. content: application/json: schema: {$ref: '#/components/schemas/MarkedPage'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} /discover/{id}/dismiss: parameters: - {$ref: '#/components/parameters/Id'} post: tags: [Discovery] operationId: dismissArtist summary: Not interested in this artist description: | Hides the artist from your Discover: it is never suggested again, and an artist taken from your listening that you dismissed no longer seeds your suggestions. An artist is dismissed or on your wishlist, never both: dismissing one that is on the wishlist takes it off. Doing it twice is the same as once. Nothing is sent to anyone. The artist can be one of yours or one a provider named. An artist that a provider named and nobody else does is kept for as long as it is dismissed, so the choice survives a new list from the provider; such an artist is listed for you, but other users cannot see that it exists. When an admin takes a provider's data back (`DELETE /providers/{name}/data`), what only that provider's lists named goes, your choice with it. security: [{bearerAuth: []}] responses: '204': {description: "Done, also when it was already dismissed."} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such artist (`artist_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} delete: tags: [Discovery] operationId: undismissArtist summary: Interested again description: Lets Discover suggest the artist again. A wish on the wishlist is not touched. security: [{bearerAuth: []}] responses: '204': {description: "Done, also when it was not dismissed."} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such artist (`artist_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /wishlist: get: tags: [Discovery] operationId: listWishlist summary: Your wishlist description: | The artists you want, newest first. It is a list for you: nothing is downloaded or sent anywhere. `in_library` says whether there is music of the artist to play now, so a client can hide the ones you already got. Only yours. security: [{bearerAuth: []}] parameters: - {$ref: '#/components/parameters/Limit'} - {$ref: '#/components/parameters/Offset'} responses: '200': description: A page of artists. content: application/json: schema: {$ref: '#/components/schemas/MarkedPage'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} /wishlist/{id}: parameters: - {$ref: '#/components/parameters/Id'} put: tags: [Discovery] operationId: addToWishlist summary: Put an artist on your wishlist description: | Adds the artist. An artist is on the wishlist or dismissed, never both: adding one you dismissed lifts the dismissal. Doing it twice keeps the first date. The artist can be one of yours or one a provider named; the latter is kept while it is on a wishlist (see `POST /discover/{id}/dismiss` for what a purge does). Discover marks it `wishlisted`. security: [{bearerAuth: []}] responses: '204': {description: "Done, also when it was already there."} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such artist (`artist_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} delete: tags: [Discovery] operationId: removeFromWishlist summary: Take an artist off your wishlist description: A dismissal of the artist is not touched. security: [{bearerAuth: []}] responses: '204': {description: "Done, also when it was not there."} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such artist (`artist_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /me/taste: get: tags: [Taste] operationId: getMyTaste summary: What Sonda has learned about your taste description: | Your taste, worked out from your own listening history every time you ask. It uses local data only: nothing is sent to any provider, and nobody else's history is read. Each event has a value: a `complete` listen +1, any other listen that counts +0.5 (see `POST /listens`), a `skip` before that -1, and a play too short to mean anything 0. An event weighs half as much for every 90 days (`taste.half_life_days`) that has passed, and one dated after the moment of the request weighs as if it happened then. Only the last ten half-lives are read (900 days by default); older events weigh less than a thousandth and are left out, also from `listens`. For each artist the values add up, and `preference` is `tanh(sum / 3)`: from -1 to 1, approaching both (a large sum rounds to exactly 1), so one skip does not sink an artist and listening makes one loved at most. A track with several artists credits each of them. `artists` are the ones you like (a `preference` above 0), the most played first. They are ordered by the sum itself, so artists whose `preference` rounds to 1 keep their order; ties go to the lower id. `tags` are the kinds of music you like, at most 50: the tags of those artists (the genres of your files that still exist, and what Last.fm and MusicBrainz said earlier, if they were ever asked) added up, each artist weighing as much as its `preference`, and scaled so the best tag is 1, best first. Tags are read from what is already stored; this request never asks a provider. The tag profile is built from your 200 most liked artists. security: [{bearerAuth: []}] parameters: - name: limit in: query description: How many artists to return. 20 when absent or 0; values above 50 are lowered to 50. It does not limit `tags`. schema: {type: integer, minimum: 0, default: 20} responses: '200': description: Your taste. Both lists are empty until you have listened to something. content: application/json: schema: {$ref: '#/components/schemas/Taste'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} /me/settings: get: tags: [Taste] operationId: getMySettings summary: Your own settings description: | Settings that belong to you, not to the server. Everyone starts with the private defaults: anything that would send something about your taste to a provider is off. security: [{bearerAuth: []}] responses: '200': description: Your settings. content: application/json: schema: {$ref: '#/components/schemas/UserSettings'} '401': {$ref: '#/components/responses/Unauthorized'} patch: tags: [Taste] operationId: updateMySettings summary: Change your own settings description: | Changes the settings named in the body and leaves the others alone. An empty object changes nothing. `null` is the same as leaving a field out. The body must be one JSON object, with nothing after it, and the names must be spelt exactly: a setting that does not exist is refused rather than ignored. security: [{bearerAuth: []}] requestBody: required: true content: application/json: schema: {$ref: '#/components/schemas/UpdateUserSettings'} responses: '200': description: Your settings as they are now. content: application/json: schema: {$ref: '#/components/schemas/UserSettings'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} /artists/{id}/description: parameters: - {$ref: '#/components/parameters/Id'} get: tags: [Discovery] operationId: getArtistDescription summary: What Wikipedia says about an artist description: | A short text about the artist from Wikipedia, with the page it comes from. The way to it is a chain of identifiers, never a search by name: the artist's MusicBrainz id, then the Wikidata item that MusicBrainz links to it, then the Wikipedia page that Wikidata names in the first of the server's languages (`[wikipedia] languages`) that has one. A page is used only if it is an article about that same item (not a page of disambiguation). An artist with no MusicBrainz id answers `no_id`: Sonda does not look an id up by name. It needs the `wikipedia` provider, which an admin switches on; nothing is sent while it is off (`disabled`). What is sent: the MusicBrainz id to MusicBrainz, the Wikidata item to Wikidata, the title of the page to Wikipedia, and your server's IP address and a `User-Agent` with the contact of the admin to all three. The answer is stored: 30 days, or a day when there was nothing to find, and an old one is returned as `stale` if Wikipedia fails. When there is nothing to show, `description` is `null` and `provider_status` is `ok`. The text is CC BY-SA 4.0. Where you show it, name the page (`title`), link to it (`url`) and give the licence (`license`, `license_url`), and say if you changed it. security: [{bearerAuth: []}] responses: '200': description: The description, or `null` with the status that says why. content: application/json: schema: {$ref: '#/components/schemas/ArtistDescription'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such artist (`artist_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /albums: get: tags: [Catalog] operationId: listAlbums summary: List albums description: | Albums with a playable track, sorted by title. `artist_id` matches the albums an artist owns plus those where it is credited on a playable track, the same set as its `album_count`. security: [{bearerAuth: []}] parameters: - {$ref: '#/components/parameters/Q'} - {$ref: '#/components/parameters/Limit'} - {$ref: '#/components/parameters/Offset'} - {$ref: '#/components/parameters/LibraryId'} - {$ref: '#/components/parameters/ArtistId'} responses: '200': description: A page of albums. content: application/json: schema: {$ref: '#/components/schemas/AlbumPage'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} /albums/{id}: parameters: - {$ref: '#/components/parameters/Id'} get: tags: [Catalog] operationId: getAlbum summary: One album security: [{bearerAuth: []}] responses: '200': description: The album. content: application/json: schema: {$ref: '#/components/schemas/Album'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such album, or nothing of it can be played (`album_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /albums/{id}/cover: parameters: - {$ref: '#/components/parameters/Id'} get: tags: [Catalog] operationId: getAlbumCover summary: The cover of an album description: | A JPEG made from the picture in the album's own files: the picture embedded in one of its first files, or else a `cover`, `folder`, `front`, `album` or `albumart` image (`.jpg`, `.jpeg` or `.png`, any case) in the album's folder, in that order of names. It is built the first time it is asked for (that request can take a moment), scaled to fit and saved in the server's data folder, and served from there afterwards. It never contacts anybody. Pictures that are too big (over 20 MB or 16 million pixels) or are not pictures are ignored, and only files inside the library are read. For an album split in folders named like `CD1` or `Disc 2`, the picture in the folder above them is used too. At most a couple of covers are built at the same time, so a client that asks for many at once may wait. An album with no picture answers `cover_not_found`, and the server does not look again for a day; a new or changed file of the album, or a full rescan, makes it look again. A cover that was found is checked again after a week, so a picture replaced in the folder is noticed. The picture is `private` for an hour in caches and has an `ETag`: send it back as `If-None-Match`. An `` element cannot send headers, so, like the stream, this also accepts the access token as the `access_token` query parameter. A header, when present, always wins. security: - bearerAuth: [] - streamQueryToken: [] parameters: - name: size in: query description: "`small` (300 pixels at most on the longest side) or `large` (1000). Large when absent. Never enlarged: a small picture stays as it is." schema: {type: string, enum: [small, large], default: large} - name: If-None-Match in: header required: false schema: {type: string} - name: Range in: header required: false schema: {type: string} responses: '200': description: The cover. headers: ETag: {$ref: '#/components/headers/ETag'} Cache-Control: {$ref: '#/components/headers/CacheControl'} Content-Length: {$ref: '#/components/headers/ContentLength'} Last-Modified: {$ref: '#/components/headers/LastModified'} content: image/jpeg: schema: {type: string, format: binary} '206': description: The requested byte range of the cover. headers: Content-Range: schema: {type: string} content: image/jpeg: schema: {type: string, format: binary} '304': {description: Not modified since the `ETag` sent.} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such album (`album_not_found`), or it has no cover (`cover_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} head: tags: [Catalog] operationId: headAlbumCover summary: Headers of a cover description: Same as `GET`, without the body. security: - bearerAuth: [] - streamQueryToken: [] parameters: - name: size in: query schema: {type: string, enum: [small, large], default: large} - name: If-None-Match in: header required: false schema: {type: string} responses: '200': description: Headers of the cover. headers: ETag: {$ref: '#/components/headers/ETag'} Cache-Control: {$ref: '#/components/headers/CacheControl'} Content-Length: {$ref: '#/components/headers/ContentLength'} Last-Modified: {$ref: '#/components/headers/LastModified'} '304': {description: Not modified since the `ETag` sent.} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': {description: "No such album, or it has no cover."} /tracks: get: tags: [Catalog] operationId: listTracks summary: List tracks description: | Tracks with at least one file that is not flagged missing; a track with several files appears once. Grouped by album, then disc and track number. security: [{bearerAuth: []}] parameters: - {$ref: '#/components/parameters/Q'} - {$ref: '#/components/parameters/Limit'} - {$ref: '#/components/parameters/Offset'} - {$ref: '#/components/parameters/LibraryId'} - {$ref: '#/components/parameters/ArtistId'} - {$ref: '#/components/parameters/AlbumId'} responses: '200': description: A page of tracks. content: application/json: schema: {$ref: '#/components/schemas/TrackPage'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} /tracks/{id}: parameters: - {$ref: '#/components/parameters/Id'} get: tags: [Catalog] operationId: getTrack summary: One track security: [{bearerAuth: []}] responses: '200': description: The track. content: application/json: schema: {$ref: '#/components/schemas/Track'} '400': {$ref: '#/components/responses/InvalidInput'} '401': {$ref: '#/components/responses/Unauthorized'} '404': description: No such track, or it has no playable file (`track_not_found`). content: application/json: schema: {$ref: '#/components/schemas/Error'} /tracks/{id}/stream: parameters: - {$ref: '#/components/parameters/Id'} get: tags: [Playback] operationId: streamTrack summary: Stream a track description: | Serves the original audio file. Supports `Range` requests, so players can seek, and conditional requests. Streaming never records a listen; report one with `POST /listens`. An `