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.
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
Spotify Playback A val to setting up some endpoints for Spotify play state.
anthonyec avatar
spotify
@anthonyec
HTTP
// Uncomment this line for one run of the Val to create the DB lol
niek avatar
spotify
@niek
HTTP
// Uncomment this line for one run of the Val to create the DB lol
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
spotifyArchiveDiscoverWeekly
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyAPI
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyAddToPlaylist
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyDiscoverWeeklyPlaylist
@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
discoverWeeklyTracks
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
dthyresson avatar
playMeASong
@dthyresson
HTTP
Play me a song Search and if we find it, it'll open the song in Spotify!
stevekrouse avatar
spotifyAchiveDiscoverWeekly
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
spotifyDiscoverWeeklyTracks
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse