Skip to main content

Custom APIs

Advanced users can customize API responses when music services lack required features.

Authentication (Optional)

ConfigurationLocationKeyDescription
AuthorizationRequest HeaderAuthorization

API List

Get Lyrics

Method: GET

ConfigurationLocationKeyDescription
Base URLURL-Example: https://example.com/lyrics
Track TitleURL ParamstitleFinal URL: https://example.com/lyrics?title={title}
ArtistURL Paramsartist
AlbumURL Paramsalbum
File Path (Optional)URL ParamspathAvailable for Subsonic/Navidrome. May be empty for other protocols.
Duration (Optional)URL ParamsdurationIn seconds. Supported since v1.1.3.
Offset (Optional)URL ParamsoffsetStart line index (0-based). Supported since v1.1.6 (fixed to 0).
Limit (Optional)URL ParamslimitSupported since v1.1.6 (fixed to 10).

Response

Return lyrics content directly if found. Return empty or 404 if not found.

For pagination (v1.1.6+), set Content-Type: application/json and return:

  [
{
"id": "<Unique ID for deduplication>",
"title": "<May differ from query>",
"artist": "<May differ from query>",
"lyrics": "<Lyrics content>"
},
...
]

Confirm Lyrics

Applicable to version 1.2.0 and above.

Triggered ​after a user manually clicks the ​Save button on the lyrics switching interface.

Request method: POST

Configuration ItemLocationKeyDescription
Base URLURL-Example: https://example.com/lyrics/confirm
Content Typeheaderscontent-typeapplication/json

Request Body:

{
"path": "File path",
"title": "Song title",
"artist": "Artist",
"album": "Album",
"lyrics": "Lyrics content to confirm",
"lyricsId": "Lyrics ID (may be null)"
}

Response Code: If the response code is not 20x, display "Lyrics confirmation exception" to the user. No message is shown if there's no exception.

note

Starting from v1.3.1, adjusting the lyrics offset and clicking the checkmark button will also trigger the lyrics confirmation interface. In this case, the request data will ​exclude the lyricsId field.

Get Cover Art

Request method: GET

Configuration ItemLocationKeyDescription
Base URLURL-Example: https://example.com/covers
Song title (optional)URL ParamstitleFinal URL: https://example.com/covers?title=SongTitle
Artist nameURL Paramsartist
Album name (optional)URL Paramsalbum
File path (optional)URL ParamspathOnly exists when querying song cover art. Supported from v1.3.3

Through this interface, the app can attempt to obtain different types of cover art by controlling parameters:

  • All three parameters: Get song cover art
  • No song title: Get album cover art
  • Only artist name: Get artist image

Response Body
File stream.

Song Details

Applicable to version 1.2.4 and above. Used to redirect to the music service's song link in the browser.

Configuration ItemLocationKeyDescription
Base URLURL-Example: https://example.com/details
Song pathURL ParamspathFinal URL: https://example.com/details?path=SongPath
TargetURL ParamstargetCurrently fixed as detail

Example configuration:

Path Replacement
Used when your music service is deployed via Docker: the detected path might differ from the actual music file path. By replacing the first matching string through ​Path Replacement, it can be converted to a path recognizable by the Docker service, i.e.:

// Actual path
/volume1/music/ff.flac
// Replaced path
/app/media/ff.flac

Simple Service

Configuring Nginx to Load LRC Files from Same Directory @ZaneYork

Directly configure the API address in the app as your_server_address + /lyrics/.

default.conf
    # Redirect requests for flac/mp3 resources to corresponding LRC files
location ~* \.(flac|mp3)$ {
rewrite ^/(.*)\.(flac|mp3)$ https://$host:8443/$1.lrc redirect;
}
location /lyrics/ {
# Fix space characters being converted to plus signs in request paths
if ($args ~ ^(?<first>.*)\+(?<second>.*)$) {
rewrite ^(.*)$ "$1?$first%20$second?" last;
}
# %2Fmusic%2F represents your Navidrome song root directory (URL-encoded /)
if ($query_string ~* "path=%2Fmusic%2F(.+)\.(mp3|flac)$") {
set $argv1 $1;
rewrite .* https://$host:8443/lyrics/$argv1.lrc? redirect;
}

# Nginx proxy logic for static resources in song directory omitted
}

Serving LRC Files with PHP (Same Filename) @lingluos

A PHP-based method to return LRC files on Linux systems. Requires the LRC file to have the exact same name as the audio file.

Assume index.php is placed in /var/www/html/lyrics, and LRC files are stored in /var/www/html/lyrics/lrc.

index.php
<?php
if (isset($_GET['path'])) {
$path = $_GET['path'];
$lrcName = rawurlencode(substr($path, strrpos($path, '/') + 1, -5) . '.lrc');

// Replace "your_domain" with your domain and path (default folder when accessing via Nginx port)
$apiUrl = "http://your_domain/lyrics/lrc/{$lrcName}";

// Print the API request URL (uncomment below and comment the header redirect
// if consistently getting 400 errors to verify LRC file accessibility)
// echo $apiUrl;

header("Location: $apiUrl");
exit;
} else {
echo '400 Missing file path';
}
?>

In theory, simply enter http://your_domain/lyrics/ in the custom API lyrics interface to display the lyrics.

As a side note, if the lyrics appear garbled, try converting the LRC file encoding to UTF-8.