외부 API
외부 API를 사용하면 프로그램이 HTTP 호출로 UMS 기능에 액세스하거나 트리거할 수 있습니다.
외부 API를 활성화하는 방법
UMS.conf를 편집하고 다음과 같이 api_key를 구성합니다
api_key = secret_password
_secret_password_은 최소 12자여야 합니다.
API 사용법
외부 API가 활성화된 경우 /api/COMMAND에 대한 POST 호출을 통해 API에 액세스할 수 있습니다
폴더 검색
다시 검색
| 의도 | 전체 라이브러리를 다시 검색합니다 |
|---|---|
| URI | /api/folderscanner/rescan |
| 본문 | 없음 |
| 본문 예시 / 설명 | 이 명령에는 본문 내용이 필요하지 않습니다 |
| 다음부터 사용 가능 | 10.4.2 |
:::정보 대형 라이브러리의 경우 속도가 느릴 수 있습니다 :::
예제:
curl -w "%{http_code}\n" -H "api-key: secret_password" http://localhost:5001/api/folderscanner/rescan
rescanFileOrFolder
| 의도 | 파일 시스템의 일부 하위 트리를 다시 검색합니다. |
|---|---|
| URI | /api/folderscanner/rescanFileOrFolder |
| 본문 | PATH_TO_SCAN |
| 본문 예시 / 설명 | 예제: "/music/pop/Madonna". 경로는 공유 경로의 루트 또는 하위 폴더여야 합니다. |
| 다음부터 사용 가능 | 10.4.2 |
예제:
curl -d "PATH_TO_SCAN" -w "%{http_code}\n" -H "api-key: secret_password" -X POST http://localhost:5001/api/folderscanner/rescanFileOrFolder
좋아하는 음악 (앨범 및 노래)
좋아하는 노래
노래는 좋아요로 표시됩니다.
| 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.
backup liked albums
Backup table MUSIC_BRAINZ_RELEASE_LIKE to filesystem
| Intention | backup liked songs to filesystem |
|---|---|
| URI | <span class="s1"><span class="s1">/api/like/</span></span>backupLikedAlbums |
| REQUEST TYPE | GET |
| RESPONSE BODY | OK or error message |
| Available since | 10.20 |
Example:
curl -w "%{http_code}\n" -H "api-key: secret_password" -X GET http://localhost:5001/api/like/backupLikedAlbums
This call will create a backup file containing liked albums.
restore liked albums
Restores table MUSIC_BRAINZ_RELEASE_LIKE from filesystem
| Intention | restore liked songs from backup file |
|---|---|
| URI | <span class="s1"><span class="s1"><span class="s1">/api/like/</span></span></span>restoreLikedAlbums |
| REQUEST TYPE | GET |
| RESPONSE BODY | OK or error message |
| Available since | 10.20 |
Example:
curl -w "%{http_code}\n" -H "api-key: secret_password" -X GET http://localhost:5001/api/like/restoreLikedAlbums
This call restores the backup file.
Playlist
enable service
Edit UMS.conf and configure a managed playlist folder by setting
<span class="s1">managed_playlist_folder</span> = PATH_TO_PLAYLIST_FOLDER
for enabling this service. By default this service is disabled. The playlist folder path should be located beneath a configured shared <span class="s1">folders</span> path for playlist changed made by this API to be visible by UMS.