Külső API
The external API enables programs to access or trigger UMS functionalities with a HTTP call.
How to enable the external API
Edit UMS.conf and configure an api_key like this
api_key = secret_password
The secret_password
must have a minimum of 12 chars.
API usage
If the external API is enabled, the API is accessible with a POST call to /api/COMMAND
Folder Scanning
rescan
Intention | Rescans the complete library |
---|---|
URI | /api/folderscanner/rescan |
POST BODY | NONE |
POST BODY example / description | This command needs no body content |
Available since | 10.4.2 |
This can be slow for large libraries
Example:
curl -w "%{http_code}\n" -H "api-key: secret_password" http://localhost:5001/api/folderscanner/rescan
rescanFileOrFolder
Intention | Rescans a partial subtree of the file system. |
---|---|
URI | /api/folderscanner/rescanFileOrFolder |
POST BODY | PATH_TO_SCAN |
POST BODY example / description | example: "/music/pop/Madonna". Path must be the root or a subfolder of a shared path. |
Available since | 10.4.2 |
Example:
curl -d "PATH_TO_SCAN" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/folderscanner/rescanFileOrFolder
Liking Music (albums and songs)
like song
Song will be marked as liked.
Intention | Like a song identified by musicBrainz trackId |
---|---|
URI | <span class="s1">/api/like/likesong</span> |
POST BODY | musicBrainz_trackID |
POST BODY example / description | b8695995-45e9-405d-b4aa-e50e8760fe25 |
Available since | 10.20 |
Example:
curl -d "b8695995-45e9-405d-b4aa-e50e8760fe25" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/like/likesong
dislike song
Song will not be disliked
Intention | Dislike a song identified by musicBrainz trackId |
---|---|
URI | <span class="s1">/api/like/</span>dislikesong |
POST BODY | musicBrainz_trackID |
POST BODY example / description | b8695995-45e9-405d-b4aa-e50e8760fe25 |
Available since | 10.20 |
Example:
curl -d "b8695995-45e9-405d-b4aa-e50e8760fe25" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/like/dislikesong
is song liked
Check if song is liked.
Intention | Check if song is liked identified by musicBrainz trackId |
---|---|
URI | <span class="s1">/api/like/</span><span class="s1">issongliked</span> |
POST BODY | musicBrainz_trackID |
POST BODY example / description | b8695995-45e9-405d-b4aa-e50e8760fe25 |
RESPONSE BODY | TRUE or FALSE |
Available since | 10.20 |
Example:
curl -d "b8695995-45e9-405d-b4aa-e50e8760fe25" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/like/issongliked
This call adds the liked attribute of the album identified by musicbrainz release-id 1e0eee38-a9f6-49bf-84d0-45d0647799af
.
like album
Set album like state to true.
Intention | Likes an album identified by musicBrainz releaseID |
---|---|
URI | <span class="s1">/api/like/</span>likealbum |
POST BODY | musicBrainz_releaseID |
POST BODY example / description | 1e0eee38-a9f6-49bf-84d0-45d0647799af |
Available since | 10.20 |
Example:
curl -d "1e0eee38-a9f6-49bf-84d0-45d0647799af" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/like/likealbum
dislike album
Remove album like state.
Intention | Dislike a song identified by musicBrainz releaseID |
---|---|
URI | <span class="s1">/api/like/</span>dislikealbum |
POST BODY | musicBrainz_releaseID |
POST BODY example / description | 1e0eee38-a9f6-49bf-84d0-45d0647799af |
Available since | 10.20 |
Example:
curl -d "1e0eee38-a9f6-49bf-84d0-45d0647799af" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/like/dislikealbum
This call removed the liked attribute of the album identified by musicbrainz release-id 1e0eee38-a9f6-49bf-84d0-45d0647799af
.
is album liked
Check album like state.
Intention | Check if album is liked identified by musicBrainz releaseID |
---|---|
URI | <span class="s1">/api/like/</span>isalbumliked |
POST BODY | musicBrainz_releaseID |
POST BODY example / description | 1e0eee38-a9f6-49bf-84d0-45d0647799af |
RESPONSE BODY | "TRUE" or "FALSE" |
Available since | 10.20 |
Example:
curl -d "1e0eee38-a9f6-49bf-84d0-45d0647799af" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/like/isalbumliked
This call checks if the album identified by musicbrainz release-id 1e0eee38-a9f6-49bf-84d0-45d0647799af
is liked.
Rating
The rating API is responsible for rating songs. Rating information is saved in the internal database (cache enabled) and optionally in the file itself. If audio_update_rating_tag = true
is set in UMS.conf the IDv3 rating field also being updated in the song file (if the songs file format is supported).
While browsing the content directory server, MusicBrainzTrackID (if available) and audiotrackID are delivered as desc
metadata within the DIDL element.
set rating
Intention | Set rating in stars (0 - 5) on a song identified by musicBrainz trackId |
---|---|
URI | <span class="s1">/api/</span><span class="s1">rating/setrating</span> |
POST BODY | musicbrainzTrackId /stars |
POST BODY example / description | b8695995-45e9-405d-b4aa-e50e8760fe25/3 |
Available since | 10.20 |
Example:
curl -d "b8695995-45e9-405d-b4aa-e50e8760fe25/3" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/rating/setrating
This call sets the user rating of all songs identified by the musicbrainz track-id b8695995-45e9-405d-b4aa-e50e8760fe25
to 3
.
get rating
Reads song rating from database
Intention | Get song rating in stars (0 - 5) by musicBrainz trackID. Response body contains the rating information. |
---|---|
URI | <span class="s1">/api/</span><span class="s1">rating/getrating </span> |
POST BODY | musicbrainzTrackId |
POST BODY example / description | b8695995-45e9-405d-b4aa-e50e8760fe25 |
RESPONSE BODY example | 3 |
Available since | 10.20 |
Example:
curl -d "b8695995-45e9-405d-b4aa-e50e8760fe25" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/rating/getrating
This call reads the user rating of a song identified by the musicbrainz track-id b8695995-45e9-405d-b4aa-e50e8760fe25
.
set rating by audiotrack id
Intention | Set rating in stars (0 - 5) on a song identified by UMS internal audiotrackID |
---|---|
URI | <span class="s1">/api/</span><span class="s1">rating/setRatingByAudiotrackId </span> |
POST BODY | trackID /stars |
POST BODY example / description | 32 |
Available since | 11.0 |
Example:
curl -d "32/3" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/rating/setrating
This call sets songs user rating identified by audiotrack id 32
to 3
.
get rating by audiotrack id
Reads song rating from database
Intention | Get song rating in stars (0 - 5) by UMS internal audiotrackID. Response body contains the rating information. |
---|---|
URI | <span class="s1">/api/</span><span class="s1">rating/getRatingByAudiotrackId</span> |
POST BODY | trackId |
POST BODY example / description | 32 |
RESPONSE BODY example | 3 |
Available since | 11.0 |
Example:
curl -d "32" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/rating/getRatingByAudiotrackId
This call reads the user rating of a song identified by UMS audiotrack-id 32
.
Backup / Restore
User managed "liked album" entries can be backed up into a profile-directory subfolder named database_backup
. The filename is MUSIC_BRAINZ_RELEASE_LIKE
. In case UMS database gets deleted, just call restore.