You're just interacting with the API, you're not gonna have any legal issues. I have some experience with Spotify's API (not MusicKit), so I'm gonna try guessing how it works based on that.
There's an API endpoint called audio_features[0] that tells you things about the song (tempo, danceability, acousticness, major/minor key...), so while you can't get full versions of every song, you can approximate how they sound like based on Spotify's audio analysis of them.
So, build a database of audio_features while respecting API limits, find the most similar ones based on about a dozen variables, and you're good to go.
There's an API endpoint called audio_features[0] that tells you things about the song (tempo, danceability, acousticness, major/minor key...), so while you can't get full versions of every song, you can approximate how they sound like based on Spotify's audio analysis of them.
So, build a database of audio_features while respecting API limits, find the most similar ones based on about a dozen variables, and you're good to go.
[0] https://developer.spotify.com/documentation/web-api/referenc...