Illustrates how to use Spotify's audio analysis web API to fetch the audio analysis for a Spotify track.
- Run
npm install
to install the tool's dependencies. - Create the configuration file for authenticating with Spotify:
- Get a "client ID" and a "client secret" by following Spotify's "Create an app" instructions.
- Create a file called
./creds/spotify.js
and populate it with your "client ID" and "client secret". The file should be formatted like this:export const clientId = 'YOUR_ID_HERE'; export const clientSecret = 'YOUR_SECRET_HERE';
node main.js <spotify-track-id> <spotify-analysis-output.json>
For example, the Spotify track ID for Gangnam Style is 03UrZgTINDqvnUMbbIMhql
so you can fetch Spotify's audio analysis for it and store it in gangnamStyleAnalysis.json
with this command:
node main.js 03UrZgTINDqvnUMbbIMhql gangnamStyleAnalysis.json
- Find the song of interest in the Spotify web app.
- Click the "..." to the right of the song title. ((1) in the screenshot)
- In the context menu that appears:
- Choose "Share"
- Choose "Copy Song Link" ((2) in the screenshot)
- The track's URL should now be on your clipboard. For example, for Gangnam Style my clipboard contained
https://open.spotify.com/track/03UrZgTINDqvnUMbbIMhql?si=e148916771984610
- The last path component of the URL is the track's ID. For example, for Gangnam Style it is
03UrZgTINDqvnUMbbIMhql
.
Here's a screenshot illustrating the steps within the Spotify web app: