Spotify API

⭐ Beginner's Pick Music / OAuth Intermediate HTTPS
Rolling 30-second window (~180 requests/minute in Development Mode; higher limits in Extended Quota Mode)

Overview

The Spotify Web API is one of the most popular music APIs, giving you access to Spotify's full catalog of songs, albums, artists, and playlists. You can fetch audio features, get personalized recommendations, and manage a user's library using OAuth 2.0. It's well-documented and beginner-friendly for read-only catalog access.

💡

Beginner Tip

For read-only catalog searches (artists, albums, tracks) use the Client Credentials flow — it's much simpler than the full Authorization Code flow and doesn't require a user to log in.

Available Data

track name and artist
album metadata
audio preview URLs
popularity score
genre classification
Response fields: name, artists, popularity

Example Response

JSON Response
{
  "name": "Bohemian Rhapsody",
  "artist": "Queen",
  "album": "A Night at the Opera",
  "duration_ms": 354000,
  "popularity": 92,
  "preview_url": "https://p.scdn.co/mp3-preview/..."
}

Field Reference

id Unique Spotify ID for the track, artist, or album.
name Name of the track, artist, album, or playlist.
uri Spotify URI (e.g., spotify:track:...) used to reference the item within the Spotify ecosystem.
external_urls Contains a "spotify" key with the public Spotify URL for the item.
popularity Popularity score from 0 to 100 based on recent play count.
images List of image objects (url, height, width) for album art or artist photos.

Implementation Example

// Search for tracks (requires OAuth token)
const url = "https://api.spotify.com/v1/search?q=never%20gonna%20give%20you%20up&type=track&limit=5";

const response = await fetch(url, {
  headers: {
    "Authorization": "Bearer YOUR_OAUTH_TOKEN"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();

data.tracks.items.forEach(track => {
  console.log(`${track.name} by ${track.artists[0].name} - Popularity: ${track.popularity}`);
});

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

401 Unauthorized Access token is missing, expired, or malformed.
Request a new access token from the Spotify Accounts Service (POST to https://accounts.spotify.com/api/token) and include it as a Bearer token.
403 Forbidden The endpoint requires a user-level OAuth scope that wasn't granted.
Re-authenticate with the required scope (e.g., user-library-read) in the Authorization Code flow.
429 Too Many Requests Rate limit exceeded; Spotify enforces per-application limits.
Check the Retry-After header in the response and wait that many seconds before retrying.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 20/20
🔒 Security 15/15
🛠 Developer XP 3/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS UNKNOWN
Category Music
Difficulty Intermediate
Verified: 2026-04-07

Alternatives to Spotify

Technical alternatives for different use cases.

Similar music metadata API with no OAuth required for search

Better For

Quick music search without OAuth authentication flow

Trade-off

User library access and playlist management

Rich listening history and music recommendation data

Better For

Scrobbling data and music taste analysis

Trade-off

Audio playback and streaming control

Open-source music database with community-maintained data

Better For

Accurate music metadata and ISRC/ISWC identifiers

Trade-off

Audio streaming and user-facing features

World's largest lyrics database with music metadata

Better For

Lyrics data and synchronized lyrics

Trade-off

Audio features and playlist management

Recipes Using Spotify

Build something with this API. Each recipe includes step-by-step instructions and code outlines.

Similar APIs

View All →