External 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 の説明
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