Public
Documentation Settings

Spotify Playlist Generator

The Spotify playlist generator collection lets you get your daily/weekly dose of fresh music. Modeled on the AMAZING Spotify Discover Weekly, within 5 minutes you'll be able to set this up, and even tweak it to your heart's content!

Workflow

  • Take a list of artists as input
  • Randomly select an artist from this list and usse Spotify's fantastic Get Related Artists and Get an Artist's top tracks APIs to mashup a playlist
  • Add these related artists back to the original list and persist back to the environment

Setup the Environment

Click on the Run in Postman button above to import the collection and environment template within your app.

  • Spotify
    • Head to Spotify Developer and register, then create a new app in the My Applications section. Add the client_id and client_secret to your environment.
    • Under the newly created app config, add the following Redirect URI - https://www.getpostman.com/oauth2/callback
    • We'll use the Authorization Code Flow to obtain the Refresh Token.
    • Open Postman, under a new request, click on the Authorization tab, select OAuth 2.0 and fill in these values:
    • Click on Request Token, go through the OAuth flow, and add the refresh_token to your environment
  • Collection Config

    Set the following variables in your environment

    • user_id: your spotify username
    • country_code: in ISO 3166-1 format
    • N: defaults to 5. Refer to the algorithm section for more details
    • artists: List of seed artists for the collection. You can find them as part of the Spotify artist link (Available in the app): e.g. for Oasis, the link looks something like https://open.spotify.com/artist/2DaxqgrOhkeH0fpeiQq2f4, choose the last section. The artists variable is an array of strings, so it'll look something like: ["2DaxqgrOhkeH0fpeiQq2f4", "2ooIqOf4X2uz4mMptXCtie"]

Run the Collection

  • To verify that everything works as expected, run the collection in the Postman app using the Collection Runner
  • The same collection executes in Newman as well. Just export the Collection and Environment files and execute the following command
Plain Text
newman -c SpotifyPLGen.json.postman_collection -e SpotifyPlGen.json.postman_environment
Loading