A Library for the Spotify web API

I just finished creating a library for the Spotify web API!

It uses combine to make chaining asynchronous requests a breeze and is designed to integrate well with SwiftUI. I would really appreciate some feedback.

2 Likes

Cool. I just took a brief look at the code and it seems nicely written and documented. Have you thought about sorting your URL query parameters to improve caching?

Also, is there a reason it only supports Darwin platforms?

Thank you for taking the time to look over my code, Karl. The reason it only supports Apple platforms is because it uses Apple's Combine framework, which, as far as I can tell, is only supported on Apple platforms. It may be possible for me to reimplement the library using another framework like RxSwift so that it can be used for linux platforms.

I'm also very intrigued by your suggestion that sorting URL query parameters improves caching. How do you know this? And who's doing the caching? Spotify?

It’s a well-known good practice. Here’s the CloudFlare page about it: https://support.cloudflare.com/hc/en-us/articles/206776797-Understanding-Query-String-Sort . Most network caches work the same way - they have to be conservative and assume that differently-ordered query strings are processed differently by the server, even though almost no servers do that (if the keys are unique). Those caches could be at the OS level, or at Spotify, or somewhere in between.

That’s a shame. If anybody was to recommend that Swift developers stay away from Combine, or to hope that it dies a quick and painful death (just like, hypothetically...), I guess they’d point to examples like this where cool software is made unavailable on certain platforms for no real reason.

In the mean time, you might try OpenCombine to support non-Apple platforms. AFAIK the API is compatible with Combine so it shouldn’t require you to make large code changes - mostly just conditionally importing the correct framework.

This is a very cool use of Combine! Cheers!

Your library looks awesome. I'm sure it'll be really useful for developers. Can you tell us a bit more about it? I'm relatively new to this forum, so I'm still getting up to speed. This library looks like it could be really helpful and I'm sure a lot of people would be interested in it. Have you shared it with the Spotify developers? I'm sure they'd love to hear about it. Also, if you're looking for more information about Spotify, I just found this great article about how much they pay per stream: https://songlifty.com/how-much-does-spotify-pay-per-streаm/. It's worth a read if you're curious. Anyway, I just wanted to say congrats on your work

1 Like

Engaging the community for feedback is a great way to gather insights and refine your library based on real-world usage.