Is there an Apple Music API which returns a users recently played tracks
Replies
No, not it's job.
Use avfoundation/avplayer
https://developer.apple.com/documentation/avfoundation/avplayer
No, there is not one for recently played tracks, but there is one for recently played albums. It's kind of strange, in my opinion.
Check out get recently played.
See also this post: https://forums.developer.apple.com/message/274653
For a deeper dive into that endpoint see https://developer.apple.com/forums/thread/669720?answerId=666540022#666540022
There is an endpoint now https://developer.apple.com/documentation/applemusicapi/get_recently_played_tracks
-
Unfortunately this API seems to have a number of frustrating limitations:
1. There's no timestamp for when the track was played 2. Tracks that are played via Autoplay or a radio station are not reported 3. Tracks seem to be added immediately when playback starts rather than at completion (or some fixed delay)
-
Also as far as I can tell, there is no support for this /recent/played/tracks in MusicKit JS, despite there being support for /recent/played. Very frustrating. Wish they would just release it as a node library instead of having us load a script to use it.