getSpotifyTrackUrl
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
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.
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)
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.
Migrated from folder: Spotify/getSpotifyTrackUrl