Files
Nemera/docs/technical/api/library/audio-library/music-library/Api.Tracks.md
T
BinaryAlley 4ffa81fffe Adds the music track stream endpoint
Adds the track stream route, its query, validator and handler, a flat stream projection in the track repository, and an endpoint that streams the audio file with HTTP range support. Excludes the route from the eventual consistency pipeline through endpoint metadata and limits it per user with a concurrency limiter. Missing, unreadable and out of scope files are reported as not found without leaking the path. Adds the API and request documentation and the stream tests.
2026-10-13 22:18:36 +03:00

15 KiB

Lumina API

Track

Add Track

Add Track Request

POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
{
  "path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
  "metadata": {
    "title": "Bohemian Rhapsody",
    "originalTitle": "Bohemian Rhapsody",
    "description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
    "disambiguation": "album version",
    "releaseInfo": {
      "originalReleaseDate": "1975-10-31",
      "originalReleaseYear": 1975,
      "reReleaseDate": "2011-11-21",
      "reReleaseYear": 2011,
      "releaseCountry": "GB",
      "releaseVersion": "Original"
    },
    "language": {
      "languageCode": "en",
      "languageName": "English",
      "nativeName": "English"
    },
    "originalLanguage": {
      "languageCode": "en",
      "languageName": "English",
      "nativeName": "English"
    },
    "tags": [
      { "name": "classic" },
      { "name": "epic" }
    ],
    "genres": [
      { "name": "Rock" },
      { "name": "Progressive Rock" }
    ],
    "isVideo": false,
    "durationInSeconds": 354,
    "sampleRate": 44100,
    "channels": 2,
    "bitDepth": 16,
    "audioCodec": "FLAC",
    "bitrate": 980,
    "acoustId": "f0e1d2c3-b4a5-4c6d-8e7f-9a0b1c2d3e4f",
    "replayGainTrackGain": -7.5,
    "replayGainTrackPeak": 0.9877,
    "replayGainAlbumGain": -6.8,
    "replayGainAlbumPeak": 0.9999
  },
  "trackNumber": 1,
  "discNumber": 1,
  "script": "Latn",
  "key": "CMajor",
  "bpm": 72,
  "work": {
    "musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
    "title": "Bohemian Rhapsody",
    "type": "Song",
    "languages": [
      { "languageCode": "en", "languageName": "English", "nativeName": "English" }
    ],
    "iswcs": ["T-010489707-6"]
  },
  "musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
  "musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
  "moods": [
    { "name": "dramatic" },
    { "name": "anxious" }
  ],
  "isrcs": [
    { "value": "GBUM71029604" }
  ],
  "contributors": [
    { "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
    { "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
  ],
  "ratings": [
    {
      "value": 4.5,
      "maxValue": 5,
      "source": "MusicBrainz",
      "voteCount": 2345
    },
    {
      "value": 4.8,
      "maxValue": 5,
      "source": "LastFm",
      "voteCount": 1234
    }
  ]
}

Add Track Response

201 Created
{
  "id": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
  "albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
  "libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
  "path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
  "metadata": {
    "title": "Bohemian Rhapsody",
    "originalTitle": "Bohemian Rhapsody",
    "description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
    "disambiguation": "album version",
    "releaseInfo": { "originalReleaseDate": "1975-10-31", "originalReleaseYear": 1975, "reReleaseDate": "2011-11-21", "reReleaseYear": 2011, "releaseCountry": "GB", "releaseVersion": "Original" },
    "language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
    "originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
    "tags": [ { "name": "classic" }, { "name": "epic" } ],
    "genres": [ { "name": "Rock" }, { "name": "Progressive Rock" } ],
    "isVideo": false,
    "durationInSeconds": 354,
    "sampleRate": 44100,
    "channels": 2,
    "bitDepth": 16,
    "audioCodec": "FLAC",
    "bitrate": 980,
    "acoustId": "f0e1d2c3-b4a5-4c6d-8e7f-9a0b1c2d3e4f",
    "replayGainTrackGain": -7.5,
    "replayGainTrackPeak": 0.9877,
    "replayGainAlbumGain": -6.8,
    "replayGainAlbumPeak": 0.9999
  },
  "trackNumber": 1,
  "discNumber": 1,
  "script": "Latn",
  "key": "CMajor",
  "bpm": 72,
  "work": {
    "musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
    "title": "Bohemian Rhapsody",
    "type": "Song",
    "languages": [
      { "languageCode": "en", "languageName": "English", "nativeName": "English" }
    ],
    "iswcs": ["T-010489707-6"]
  },
  "musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
  "musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
  "createdOnUtc": "2025-01-01T12:00:00.0000000Z",
  "updatedOnUtc": "2025-01-20T14:45:00.0000000Z",
  "moods": [
    {
      "name": "dramatic"
    },
    {
      "name": "anxious"
    }
  ],
  "isrcs": [
    {
      "value": "GBUM71029604"
    }
  ],
  "contributors": [
    {
      "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
      "role": "Vocals"
    },
    {
      "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
      "role": "Guitar"
    }
  ],
  "ratings": [
    {
      "value": 4.5,
      "maxValue": 5,
      "source": "MusicBrainz",
      "voteCount": 2345
    },
    {
      "value": 4.8,
      "maxValue": 5,
      "source": "LastFm",
      "voteCount": 1234
    }
  ]
}

Get Track

Get Track Request

GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f

Get Track Response

200 Ok
{
  "id": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
  "albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
  "libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
  "path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
  "metadata": {
    "title": "Bohemian Rhapsody",
    "originalTitle": "Bohemian Rhapsody",
    "description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
    "disambiguation": "album version",
    "releaseInfo": { "originalReleaseDate": "1975-10-31", "originalReleaseYear": 1975, "reReleaseDate": "2011-11-21", "reReleaseYear": 2011, "releaseCountry": "GB", "releaseVersion": "Original" },
    "language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
    "originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
    "tags": [ { "name": "classic" }, { "name": "epic" } ],
    "genres": [ { "name": "Rock" }, { "name": "Progressive Rock" } ],
    "isVideo": false,
    "durationInSeconds": 354,
    "sampleRate": 44100,
    "channels": 2,
    "bitDepth": 16,
    "audioCodec": "FLAC",
    "bitrate": 980,
    "acoustId": "f0e1d2c3-b4a5-4c6d-8e7f-9a0b1c2d3e4f",
    "replayGainTrackGain": -7.5,
    "replayGainTrackPeak": 0.9877,
    "replayGainAlbumGain": -6.8,
    "replayGainAlbumPeak": 0.9999
  },
  "trackNumber": 1,
  "discNumber": 1,
  "script": "Latn",
  "key": "CMajor",
  "bpm": 72,
  "work": {
    "musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
    "title": "Bohemian Rhapsody",
    "type": "Song",
    "languages": [
      { "languageCode": "en", "languageName": "English", "nativeName": "English" }
    ],
    "iswcs": ["T-010489707-6"]
  },
  "musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
  "musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
  "createdOnUtc": "2025-01-01T12:00:00.0000000Z",
  "updatedOnUtc": "2025-01-20T14:45:00.0000000Z",
  "moods": [
    {
      "name": "dramatic"
    },
    {
      "name": "anxious"
    }
  ],
  "isrcs": [
    {
      "value": "GBUM71029604"
    }
  ],
  "contributors": [
    {
      "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
      "role": "Vocals"
    },
    {
      "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
      "role": "Guitar"
    }
  ],
  "ratings": [
    {
      "value": 4.5,
      "maxValue": 5,
      "source": "MusicBrainz",
      "voteCount": 2345
    },
    {
      "value": 4.8,
      "maxValue": 5,
      "source": "LastFm",
      "voteCount": 1234
    }
  ]
}

Stream Track

Stream Track Request

GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f/stream
Authorization: Bearer <token>
Range: bytes=0-1048575

Streams the audio file of the track identified by the route, with HTTP range support. The Range header is optional: without it the whole file is streamed, and with it only the requested range is streamed, so that a player can start playback before the whole file is downloaded and can seek within the file. The audio file is streamed to an Admin, who can stream the tracks of all libraries, or to the owner of the library of the track.

Stream Track Response

200 Ok

or, when a range is requested:

206 Partial Content
Content-Range: bytes 0-1048575/3542771
Accept-Ranges: bytes

The response is the raw bytes of the audio file, served with the media type of the file when it is an audio type, or application/octet-stream otherwise. Every response carries X-Content-Type-Options: nosniff, Cache-Control: private and Vary: Authorization, together with a Last-Modified and an ETag derived from the size and the modification time of the file.

Update Track

Update Track Request

PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
{
  "metadata": {
    "title": "Bohemian Rhapsody",
    "originalTitle": "Bohemian Rhapsody",
    "description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
    "disambiguation": "album version",
    "releaseInfo": {
      "originalReleaseDate": "1975-10-31",
      "originalReleaseYear": 1975,
      "reReleaseDate": "2011-11-21",
      "reReleaseYear": 2011,
      "releaseCountry": "GB",
      "releaseVersion": "Original"
    },
    "language": {
      "languageCode": "en",
      "languageName": "English",
      "nativeName": "English"
    },
    "originalLanguage": {
      "languageCode": "en",
      "languageName": "English",
      "nativeName": "English"
    },
    "tags": [
      { "name": "classic" },
      { "name": "epic" }
    ],
    "genres": [
      { "name": "Rock" },
      { "name": "Progressive Rock" }
    ],
    "isVideo": false,
    "durationInSeconds": 354,
    "sampleRate": 44100,
    "channels": 2,
    "bitDepth": 16,
    "audioCodec": "FLAC",
    "bitrate": 980,
    "acoustId": "f0e1d2c3-b4a5-4c6d-8e7f-9a0b1c2d3e4f",
    "replayGainTrackGain": -7.5,
    "replayGainTrackPeak": 0.9877,
    "replayGainAlbumGain": -6.8,
    "replayGainAlbumPeak": 0.9999
  },
  "trackNumber": 1,
  "discNumber": 1,
  "script": "Latn",
  "key": "CMajor",
  "bpm": 72,
  "work": {
    "musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
    "title": "Bohemian Rhapsody",
    "type": "Song",
    "languages": [
      { "languageCode": "en", "languageName": "English", "nativeName": "English" }
    ],
    "iswcs": ["T-010489707-6"]
  },
  "musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
  "musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
  "moods": [
    { "name": "dramatic" },
    { "name": "anxious" }
  ],
  "isrcs": [
    { "value": "GBUM71029604" }
  ],
  "contributors": [
    { "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
    { "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
  ],
  "ratings": [
    {
      "value": 4.5,
      "maxValue": 5,
      "source": "MusicBrainz",
      "voteCount": 2345
    },
    {
      "value": 4.8,
      "maxValue": 5,
      "source": "LastFm",
      "voteCount": 1234
    }
  ]
}

Update Track Response

200 Ok
{
  "id": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
  "albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
  "libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
  "path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
  "metadata": {
    "title": "Bohemian Rhapsody",
    "originalTitle": "Bohemian Rhapsody",
    "description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
    "disambiguation": "album version",
    "releaseInfo": { "originalReleaseDate": "1975-10-31", "originalReleaseYear": 1975, "reReleaseDate": "2011-11-21", "reReleaseYear": 2011, "releaseCountry": "GB", "releaseVersion": "Original" },
    "language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
    "originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
    "tags": [ { "name": "classic" }, { "name": "epic" } ],
    "genres": [ { "name": "Rock" }, { "name": "Progressive Rock" } ],
    "isVideo": false,
    "durationInSeconds": 354,
    "sampleRate": 44100,
    "channels": 2,
    "bitDepth": 16,
    "audioCodec": "FLAC",
    "bitrate": 980,
    "acoustId": "f0e1d2c3-b4a5-4c6d-8e7f-9a0b1c2d3e4f",
    "replayGainTrackGain": -7.5,
    "replayGainTrackPeak": 0.9877,
    "replayGainAlbumGain": -6.8,
    "replayGainAlbumPeak": 0.9999
  },
  "trackNumber": 1,
  "discNumber": 1,
  "script": "Latn",
  "key": "CMajor",
  "bpm": 72,
  "work": {
    "musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
    "title": "Bohemian Rhapsody",
    "type": "Song",
    "languages": [
      { "languageCode": "en", "languageName": "English", "nativeName": "English" }
    ],
    "iswcs": ["T-010489707-6"]
  },
  "musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
  "musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
  "createdOnUtc": "2025-01-01T12:00:00.0000000Z",
  "updatedOnUtc": "2025-01-20T14:45:00.0000000Z",
  "moods": [
    {
      "name": "dramatic"
    },
    {
      "name": "anxious"
    }
  ],
  "isrcs": [
    {
      "value": "GBUM71029604"
    }
  ],
  "contributors": [
    {
      "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
      "role": "Vocals"
    },
    {
      "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
      "role": "Guitar"
    }
  ],
  "ratings": [
    {
      "value": 4.5,
      "maxValue": 5,
      "source": "MusicBrainz",
      "voteCount": 2345
    },
    {
      "value": 4.8,
      "maxValue": 5,
      "source": "LastFm",
      "voteCount": 1234
    }
  ]
}

Delete Track

DELETE api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/{trackId}
200 Ok

Deletes the track identified by the route.