FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
dthyresson
dthyressongetSpotifyTrackUrl
Public
Like
getSpotifyTrackUrl
Home
Code
2
README.md
S
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
Code
/
Search
README.md

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

Create val
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.

Migrated from folder: Spotify/getSpotifyTrackUrl

Code
README.md
S
main.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.