Search code examples
apple-musicapple-musickit

History : song played at


Is there a way to obtain the playing timestamp when I'm fetching users' history (recent-played) through Apple Music API ?

I'm trying to fetch 1 month's listening history but it didn't seem to be possible.


Solution

  • You can't specifically get the last month, however you can get the most recently played resources: https://developer.apple.com/documentation/applemusicapi/get_recently_played_resources

    You could then run that API request each hour and build up a history list of your own over time, so you'd know what was played within each hour of the day by performing a diff on the responses. You wouldn't have a timestamp as the API won't return that

    However I would expect that this all may fall foul of Apple's TOS with regards to user privacy, I'd suggest you do more investigation if you want to do it.