Skip to content
DocumentationAPI Reference

Getting Started

Set up your Spotify Developer account and make your first API call

This tutorial walks you through setting up your Spotify Developer account, creating an application, and making your first API call to retrieve artist data.

  • A Spotify account (free or Premium)
  • Basic knowledge of JavaScript/Node.js
  • Node.js 18+ installed

  1. Log into the Developer Dashboard

    Go to the Spotify Developer Dashboard and log in with your Spotify account.

  2. Create a new app

    Click “Create app” and fill in the details:

    • App name: Your application’s name
    • App description: Brief description of what you’re building
    • Redirect URI: http://localhost:3000/callback (for development)
    • APIs used: Select “Web API”
  3. Get your credentials

    After creating the app, you’ll see your Client ID on the app dashboard. Click “View client secret” to reveal your Client Secret.


Let’s make a simple API call to get information about an artist.

Terminal window
# First, get an access token
curl -X POST "https://accounts.spotify.com/api/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
# Use the token to get artist info (Taylor Swift)
curl "https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

First, install the Spotted SDK:

Terminal window
npm install spotted-ts

Create a new file spotify-test.js:

import Spotted from "spotted-ts";
// Initialize the client (uses SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET env vars)
const client = new Spotted();
// Get Taylor Swift's artist profile
async function main() {
const artist = await client.artists.retrieve("06HL4z0CvFAxyc27GXpf02");
console.log(`
Artist: ${artist.name}
Followers: ${artist.followers.total.toLocaleString()}
Genres: ${artist.genres.join(", ")}
Popularity: ${artist.popularity}/100
`);
}
main();

Run it:

Terminal window
node spotify-test.js

You should see output like:

Artist: Taylor Swift
Followers: 100,000,000+
Genres: pop, pop dance
Popularity: 100/100

Here’s what a typical artist object looks like:

{
"id": "06HL4z0CvFAxyc27GXpf02",
"name": "Taylor Swift",
"type": "artist",
"uri": "spotify:artist:06HL4z0CvFAxyc27GXpf02",
"followers": {
"total": 100000000
},
"genres": ["pop", "pop dance"],
"images": [
{
"url": "https://i.scdn.co/image/...",
"height": 640,
"width": 640
}
],
"popularity": 100,
"external_urls": {
"spotify": "https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"
}
}
FieldDescription
idUnique Spotify ID for the artist
uriSpotify URI (used for playback and linking)
nameArtist name
followers.totalNumber of followers
genresArray of genre tags
popularity0-100 popularity score
imagesArray of profile images in different sizes

Now let’s search for tracks:

import Spotted from "spotted-ts";
const client = new Spotted();
// Search for "Blinding Lights"
async function main() {
const results = await client.search.query({
q: "Blinding Lights",
type: ["track"],
limit: 10,
});
console.log("Search Results:");
results.tracks.items.forEach((track, i) => {
console.log(`${i + 1}. ${track.name} by ${track.artists[0].name}`);
});
}
main();

Here’s a complete example that combines multiple API calls using the SDK:

import Spotted from "spotted-ts";
const client = new Spotted();
async function exploreArtist(artistId) {
// Get artist info
const artist = await client.artists.retrieve(artistId);
console.log(`\n🎤 ${artist.name}`);
console.log(` Followers: ${artist.followers.total.toLocaleString()}`);
console.log(` Genres: ${artist.genres.slice(0, 3).join(", ")}`);
// Get top tracks
const { tracks } = await client.artists.getTopTracks(artistId, {
market: "US",
});
console.log(`\n🎵 Top Tracks:`);
tracks.slice(0, 5).forEach((track, i) => {
console.log(` ${i + 1}. ${track.name} (${track.album.name})`);
});
// Get albums (using async iterator)
console.log(`\n💿 Recent Albums:`);
let albumCount = 0;
for await (const album of client.artists.listAlbums(artistId, {
include_groups: "album",
})) {
if (albumCount >= 5) break;
console.log(` • ${album.name} (${album.release_date.slice(0, 4)})`);
albumCount++;
}
// Get related artists
const { artists: related } = await client.artists.getRelatedArtists(artistId);
console.log(`\n👥 Similar Artists:`);
console.log(
` ${related
.slice(0, 5)
.map((a) => a.name)
.join(", ")}`,
);
}
// Explore The Weeknd
exploreArtist("1Xyo4u8uXC1ZmMpatF05PJ");

Output:

🎤 The Weeknd
Followers: 75,000,000+
Genres: canadian contemporary r&b, canadian pop, pop
🎵 Top Tracks:
1. Blinding Lights (After Hours)
2. Starboy (Starboy)
3. Save Your Tears (After Hours)
4. Die For You (Starboy)
5. The Hills (Beauty Behind the Madness)
💿 Recent Albums:
• Dawn FM (2022)
• After Hours (2020)
• Starboy (2016)
• Beauty Behind the Madness (2015)
• Kiss Land (2013)
👥 Similar Artists:
Dua Lipa, Post Malone, Drake, Doja Cat, Harry Styles

Now that you’ve made your first API calls, explore these guides to build more advanced features: