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.
bandcampWrapped
tmcw
bandcampWrapped
Bandcamp Wrapped It's Spotify Wrapped, but for Bandcamp! . Bandcamp is for people who buy their music and probably most of them hoard MP3s. Like me. And this val helps those people turn their Bandcamp purchases of 2024 into HTML or Markdown suitable for blog posts on their blogs, which is probably a segment that has some overlap with the people who are wacky enough to buy their music instead of streaming it from some service. Because Bandcamp doesn't have an API, this hinges on you going to your purchases page, copying the purchases, and pasting it in. Thanks to the ability of the system clipboard to contain HTML , the same technology that makes copy-and-pasted text have unpredictable and annoying font and boldness choices also lets this parse and reformat that purchases page into something shareable. I would love for this to support embeds as well, but I haven't found a strategy yet: Bandcamp embeds use album IDs in the URLs, which are not exposed in the content on the purchases page. I'd have to scrape Bandcamp for that, which would probably inevitably be blocked by some 'bot protection' system. Also read about this on macwright.com .
HTTP
insectIdentifier
Mashimi
insectIdentifier
@jsxImportSource https://esm.sh/react
HTTP
spotifyPlaylistSearch
trob
spotifyPlaylistSearch
@jsxImportSource https://esm.sh/react
HTTP
OptimalSlogans
gabefletch
OptimalSlogans
An interactive, runnable TypeScript val by gabefletch
HTTP
spotify
MichaelNollox
spotify
Remix of: ejfox/spotify
HTTP
spotify
ejfox
spotify
// Thank you for the feedback! You're right, we need to handle cases where playlist images might be missing.
HTTP
BuyukInsan
cingozilyas
BuyukInsan
@jsxImportSource npm:react
HTTP
arctangent2024
aleaf
arctangent2024
@jsxImportSource https://esm.sh/react
HTTP
playMeASong
dthyresson
playMeASong
Play me a song Search and if we find it, it'll open the song in Spotify! Feeling Lucky? Play a random song . Like a band? Play one of their tracks.
HTTP
getSpotifyTrackUrl
dthyresson
getSpotifyTrackUrl
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.
processTrackBlobsJob
dthyresson
processTrackBlobsJob
processTracksBlobsJob Periodically fetch all Spotify tracks from Blob storage and update the tracks database with a subset of display information. Keys take the format: spotify_track_id:4tVhBXOhSlqYCL2IjyoUNu .
Cron
tracksAPI
dthyresson
tracksAPI
Remix of: dthyresson/graphQLYoga
HTTP
playRandomSong
dthyresson
playRandomSong
Play a Random Song ... from a set of Spotify tracks that have been played by me or others using the playMeASong val. Queries a random record of a tracks table and redirects to it's Spotify url. Usage // random const track = await getRandomTrack(); // random for artist const track = await getRandomTrack("Pixies");
HTTP
resetFavoriteSongSearches
dthyresson
resetFavoriteSongSearches
Reset Favorite Song Searches Cron to clear and reset favoritre Spotify song searches periodically.
Cron
me
dthyresson
me
me Welcome to my Val town! I'm DT , a GP at Preston-Werner Ventures where I invest in early stage startups. I also work on RedwoodJS . I enjoy ☕️ and collecting 🖍 street art, 🧷 punk/new wave/rock poster art and ephemera (Madchester, The Haçienda, and Factory Records), vintage 🥁 🤖 drum machines & 🎹 synths. Have a look at my Vals: GraphQL Spotify Misc
HTTP
spotify
hunty
spotify
Remix of: stevekrouse/spotify
HTTP