Spotify API has the answer for this question. I have used it with Python/Pandas to measure how happy their songs are and write a short article about it as a project for my Data Studio class for the Master of Science in Data Journalism program at Columbia University.
You can read the full code here. Happiness was measured by the song "valence", which is a value from 0 to 1 that considers how positive a song is, according to Spotify. Only studio albums were considered. Live albums and single were removed from the analysis.
Read the project here.