How I tracked the top Nigerian artists using the Spotify API

How I tracked the top Nigerian artists using the Spotify API

ยท

3 min read

A couple of days back, an additional spark of flame was added to the normal conflagration that is the Naija internet space. Davido alleged that Burna Boy was one of the new cats in the music industry.

As expected, their respective fanbases armed themselves and clashed on the internet. This wasn't a one-off thing, but the latest skirmish in the long-running battle royale to determine the King of the Nigerian music industry hill.

While I was just a casual observer of this latest clash, it did make me wonder, "Wouldn't it be cool if there was a verifiable way of checking which artist was the top based on raw, hard data?"

So, off I went to Spotify, to see if they had a ranking for top Nigerian artists. Alas, there was nothing of such.

I also scoured the web and also didn't find anything satisfactory.

So, I decided to create my own, and Afrobeatstats was born.

Working with the Spotify API

I didn't have the resources to independently compile a list of top artists. But I figured I didn't have to do that. I decided to stand on the shoulders of giants, the Spotify API in this instance.

Incidentally, to the best of my knowledge, the Spotify API doesn't really let you search for artists by country. So I had to use a proxy for Nigerian music. And what better proxy than Afrobeats?

Now, one way to judge the current top artists would have been the current monthly listeners, but I couldn't find a way to access this with the Spotify API.

So, I used the next best thing -- the popularity metric.

According to Spotify

So, how do they calculate the popularity of individual tracks?

So, I used the Spotify API to get all Afrobeats artists on its platform. Then I sorted them by popularity to get the top artists. I saved the result to a JSON.

Front End Troubles

To be honest, I don't have much of an eye for art, so designing the front end was going to be a hassle. I went to work, trying to code the HTML from scratch, and this is what I got:

Atrocious right? I know.

So, I asked around for help, and heard there was another giant I could stand on -- Bootstrap.

So, I got to work with Bootstrap, made some modifications, and this is what I ended up with:

Much better.

Seems like Rema is the current GOAT ๐Ÿ‘€. It seems featuring Selena Gomez would do wonders for your horns and beards.

Also seems the new cats are well-represented in the rankings, which makes sense because they're the ones releasing recent hits.

Deployment

I created AfroBeatStats as my Foundations project for my ALX Software Engineering course.

ALX had already provided us with some servers, and even a free domain name. So, I deployed it to one of those servers.

You can have a look at the web app at olyray.tech/afrobeatstats

You can also look at the code repository on my GitHub at https://github.com/Olyray/AfroBeatStats

I learned a lot doing this project. Especially the fact that in the programming world, standing on the shoulders of giants would really help you see a far distance.

If you have any comments, criticisms, or suggestions, you can always reach me on Twitter or LinkedIn.

ย