
Rapidapi and cloudflare workers based subscription API for spotify metadata - sloev
https://rapidapi.com/sloev/api/spotiflite
======
sloev
hi, i just released an api version of the opensource "spotiflite" spotify
metadata scraper
([https://github.com/sloev/spotiflite](https://github.com/sloev/spotiflite))
that lets you fetch metadata for an artist.

I thought it could be a fun exercise to see how easy it is now-a-days to setup
a subscription paid api "without pulling up my credit card from the pocket"

so here is the steps i took:

 _1\. setup a free api using cloudflare workers:_

I started by creating the api on cloudflare workers since they are by far the
cheepest and their fremium model makes it possibly to publish an api without a
credit card.

Key learnings for me was:

* env vars can be created in the UI and then they get injected as vars in your js script.

* use the url.pathname to have multiple paths in one api

* Use custom headers from your apigateway provider to only respond to those requests.

The sourcecode for the cloudflare worker is here
[https://github.com/sloev/spotiflite/blob/master/cloudflare/w...](https://github.com/sloev/spotiflite/blob/master/cloudflare/worker.js)

 _2\. use rapidapi.com as api gateway_

After i had created my api i needed a place to publish it and "receive moneyz
cuz lulz" so i choose rapidapi cuz they dont need any credit cards either and
have a simple way to setup.

With rapidapi i created an endpoint pointing to my new api with my new path:
"artist-meta" and then i specified some ~random~ price ranges include a free
option and pressed publish.

All in all, publishing an api and get moneyz for requests is more easy now
than ever.

