Creates a database of Spotify tracks and artists. Creates a set of REST services for adding tracks and querying the database populated from the Spotify API.
- Code repository: https://github.com/gregsandell/spotify-track-artist
- Accompanying video: https://youtu.be/mnME9QfN2JA
- Challenge instructions: see the
doc
directory
sqlite3
should be installed somewhere on your system. For Mac users: if it's not already present at/usr/bin/sqlite3
, try installing with HomeBrew.- Choose a location for your Sqlite3 DB file. You can bring one into existnece simply with
sqlite3 myDB.db
and quitting (type.quit
). - In the file
config/config.json
update the value for thestorage
key to the absolute path of your sqlite3 DB file. - Create a
.env
file in the root of the project. The expected contents are in a later section. - Build the project:
npm i
- Create the database tables:
npm run migrate
- Start the REST server: npm run server
- Test the queries with your favorite app (Postman, Curl, etc.)
To restore the DB to it's blank state: npm run migrate:undo
To seed the data with tracks and artists to explore with REST services: npm run seed
To remove the seed data (this will remove all track and artist data): npm run seed:undo
path | method | query params | body params |
---|---|---|---|
/api/add-track | POST | ISRC (string) idx* (int) |
|
/api/search-artist | GET | q (string) artist substring search term | |
/api/search-isrc | GET | q (string) an exact ISRC | |
/api/search-song | GET | q (string) song substring search term |
* Spotify returns a track with an array of several items, idx is the index (0 to n-1) to be used.
Key | Value |
---|---|
STORAGE | Absolute path to a sqlite3 database file |
SPOTIFY_AUTH | Basic <base64 string> The base64 string should adhere to the requirements from the Authorization Code Flow section of the Spotify Authorization Guide, namely: client_id:client_secret |
SPOTIFY_BASE_AUTH_URL | https://accounts.spotify.com/ |
SPOTIFY_BASE_URL | https://api.spotify.com/ |
SPOTIFY_TOKEN_ENDPOINT | api/token |
SPOTIFY_SEARCH_ENDPOINT | v1/search |
PORT | Defaults to 5000 or set to your choice |