Is there an Apple Music API which returns a users recently played tracks
Apple Music API - return a users recently played tracks
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
Had a look at it today. Still as @TheCD said. Small correction though, the recently played endpoint returns albums, playlists, and stations. Still no songs though.
For a deeper dive into that endpoint see https://developer.apple.com/forums/thread/669720?answerId=666540022#666540022
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