Back to APIs list

Spotify API examples & templates

Use these vals as a playground to view and fork Spotify API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
MichaelNollox avatar
spotify
@MichaelNollox
HTTP (preview)
Forked from ejfox/spotify
ejfox avatar
spotify
@ejfox
HTTP (preview)
// Thank you for the feedback! You're right, we need to handle cases where playlist images might be missing.
dthyresson avatar
getSpotifyTrackUrl
@dthyresson
Script
getSpotifyTrackUrl Get a Spotify Track Url using the Spotify Web API given an artist and a song title. Track info is cached by the query and also the spotify track id, so your popular queries won't have to fetch from Spotify over and over. Examples import { getSpotifyTrackUrl } from "https://esm.town/v/dthyresson/getSpotifyTrackUrl"; const reni = await getSpotifyTrackUrl("Stone Roses", "Fools Gold"); const ian = await getSpotifyTrackUrl("Joy Division", "Love Will Tear Us Apart"); const kim = await getSpotifyTrackUrl("Pixies", "Velouria"); console.log(reni) console.log(ian) console.log(kim) Info Uses getSpotifyAccessToken which requires you to set environment variables from your Spotify Developers account. SPOTIFY_CLIENT_ID SPOTIFY_CLIENT_SECRET Your access token is cached by getSpotifyAccessToken to avoid fetching over and over.
dthyresson avatar
getSpotifyAccessToken
@dthyresson
Script
getSpotifyAccess Token Request an access token for use with the Spotify Web API. Requires environment variables from your Spotify Developers account. SPOTIFY_CLIENT_ID SPOTIFY_CLIENT_SECRET Uses Blob storage to cache the spotify_accessToken based on when the expires_in value in the Spotify Access Token response. Example import { getSpotifyAccessToken } from "https://esm.town/v/dthyresson/getSpotifyAccessToken"; const accessToken = await getSpotifyAccessToken(); console.debug(accessToken)
hunty avatar
spotify
@hunty
HTTP
Forked from stevekrouse/spotify
stevekrouse avatar
spotifyCreatePlaylist
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyTracks
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyAPI
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyArchiveDiscoverWeekly
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyAddToPlaylist
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotify
@stevekrouse
HTTP
// await sqlite.execute("CREATE TABLE spot (id text primary key, data text)")
stevekrouse avatar
spotifyDiscoverWeeklyPlaylist
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
discoverWeeklyTracks
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyAchiveDiscoverWeekly
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
niek avatar
spotify
@niek
HTTP
Forked from hunty/spotify
stevekrouse avatar
spotifyDiscoverWeeklyTracks
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse