Spotify integration without code: player, playlists and music search

The Spotify integration in nana800 is a block that controls the player, searches tracks, albums, artists and playlists, creates playlists and adds tracks to them. To connect it you need an access token from your own app in Spotify for Developers, and player control also needs a Spotify Premium account. Every action costs $0.002, and your balance is topped up to $3.50 for free every month.

Build it in the builder
  • Block run: $0.002
  • Free every month: $3.50
  • No card needed

What you can do

  • Play, pause, skip tracks, change the volume and add a track to the queue (Spotify Premium needed)
  • See what is playing now and get recently played tracks
  • Search tracks, albums, artists and playlists, including filters like artist:Queen year:1975
  • Create playlists, add tracks at a chosen position and remove tracks
  • Get details of a track, album or artist, the albums of an artist, your playlists and their tracks
  • Read your liked tracks and the artists you follow
  • Accept a track as an open.spotify.com link, a URI or an ID, for example from a message to a Telegram bot

Blocks in the builder

  • Spotify action

    Action · $0.002 per run

    One operation of your choice: player, tracks, albums, artists, playlists or library. Works with an access token of your Spotify app, valid for 1 hour. Returns the object found or a list and the total number of results.

How to set it up

  1. 1

    Create a Spotify app

    Open Spotify for Developers and click Create app. Enter any Redirect URI, for example http://127.0.0.1:8888/callback. In User Management add the email of your Spotify account: in development mode only the people added there can use the app, up to 5 of them.

  2. 2

    Get an access token

    Get a token through the Authorization Code flow with the Client ID and Client Secret from the app settings. Request the scopes for the player, playlists and library: the full list is in the block instructions in the builder. The token is valid for 1 hour.

  3. 3

    Add the Spotify block

    Create a scheme in the builder and add the Spotify block. Paste the token into the access token field and pick an operation, for example add_to_playlist. Set the playlist and the track as an open.spotify.com link, a URI or just an ID. Leave the position empty to add the track at the end.

  4. 4

    Turn the scheme on and test it with the button

    Add the button trigger, turn the scheme on and press the button. Check the playlist in Spotify or the block result: on failure, error_message explains what went wrong, for example an expired token. The button itself is free. You pay only for the Spotify block run.

  5. 5

    Set up token refresh

    If the scheme has to work longer than an hour, put a request block before the Spotify block that gets a new token from Spotify with your refresh token, which Spotify issues together with the first token. Put the new token from the answer of that block into the access token field.

  6. 6

    Add the working trigger

    Add the trigger you need, for example Telegram message from user to bot, so guests can send song links to your bot for a shared playlist, and keep the scheme on. While it is on, it costs $0.0042 per hour.

Frequently asked questions

Every block operation costs $0.002: a search, adding a track, a pause or anything else. An enabled scheme costs $0.0042 per hour. Your balance is topped up to $3.50 for free every month, no card needed. A scheme kept on around the clock for a month spends most of that on scheme hours.

Create an app in Spotify for Developers, add your email in User Management and get a token through the Authorization Code flow with the Client ID and Client Secret of the app. The token is valid for 1 hour, after that the block returns an expired token error. If Spotify answers Forbidden, check that your account is in User Management and that the app owner has Premium.

The player can be controlled only with a Spotify Premium account and while Spotify is open on some device, such as a phone or a computer. Also check that the token has the user-read-playback-state and user-modify-playback-state scopes.

Spotify closed get_audio_features, get_related_artists, get_new_releases and get_artist_top_tracks for new apps. Older apps with extended access may still use them, otherwise the block returns an error with an explanation. Instead, use search_albums with the query tag:new for new releases and search_tracks with artist: and a name for top tracks.

A search returns up to 10 results per request, 5 by default. Other lists, such as playlist tracks or liked tracks, return up to 50. To get the next page, fill in the skip results field: 10 with a limit of 10 returns results 11 to 20. Spotify shows playlist tracks only for your own playlists and those you collaborate on.

Build your first scheme for free

Sign-up is free and needs no card. Every month the balance is topped up to $3.50 for free, enough for about 3,500 runs of basic blocks.

Build it in the builder