API Directory › 🎬 Movies, TV & Music › Spotify Web API
OAuthHTTPSCORS

Spotify Web API

Access Spotify's catalog, playlists and playback data.

Auth
OAuth
HTTPS
Yes
CORS
Yes
Open Spotify Web API docs ↗

What it does

The Spotify Web API exposes the Spotify catalogue and, with user consent, a listener’s library and playback: search tracks, albums, artists and playlists, read metadata and popularity, manage playlists, and control playback on the user’s devices.

Base URL

https://api.spotify.com/v1

Authentication

OAuth 2.0. For catalogue-only access use the Client Credentials flow: POST to https://accounts.spotify.com/api/token with grant_type=client_credentials and HTTP Basic (client_id:client_secret) to get a 1-hour bearer token. User data (library, playback) needs the Authorization Code flow with scopes.

Code examples

curl (get a token, then search)
TOKEN=$(curl -s -X POST https://accounts.spotify.com/api/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -d grant_type=client_credentials | jq -r .access_token)

curl -s "https://api.spotify.com/v1/search?q=daft+punk&type=artist&limit=1" \
  -H "Authorization: Bearer $TOKEN"
Python
import requests

tok = requests.post("https://accounts.spotify.com/api/token",
    data={"grant_type": "client_credentials"},
    auth=(CLIENT_ID, CLIENT_SECRET), timeout=10).json()["access_token"]

r = requests.get("https://api.spotify.com/v1/search",
    params={"q": "Rosalia", "type": "artist", "limit": 1},
    headers={"Authorization": f"Bearer {tok}"}, timeout=10)
print(r.json()["artists"]["items"][0]["name"])

Rate limits & quotas

Spotify does not publish a number — the limit is calculated over a rolling ~30-second window and scales with your app. Over it you get HTTP 429 with a Retry-After header (seconds). Apps start in development mode (25 users max) until you request an extension. Several analysis endpoints (audio-features, recommendations, related-artists) were deprecated for newly created apps — check current docs.

Key response fields

tracks.items[].id / uriSpotify ID and spotify:track:… URI
artists.items[].popularity0–100 popularity score
album.images[]Cover art at several sizes
preview_url30-second MP3 preview (may be null)
Retry-AfterHeader: seconds to wait after a 429

Common errors

401Token missing, expired (1h) or wrong flow for the endpoint.
403Valid token but missing scope, or the user is not Premium (playback control).
429Rate limited — sleep Retry-After seconds.
404Unknown ID, or (playback) no active device.

When to use it (and alternatives)

The choice for anything tied to real Spotify accounts and playback. For catalogue metadata and previews without OAuth ceremony, Deezer and iTunes Search are simpler; for open music metadata use MusicBrainz.

FAQ

Do I need a user to log in just to search?

No — the Client Credentials flow gives you an app token for all catalogue and search endpoints. Login is only required to touch a specific user’s library or playback.

Why did my audio-features request start returning 403/404?

Spotify deprecated several data endpoints for apps created after late 2024. If your app is affected, those endpoints are unavailable regardless of scopes.

How long does a token last?

One hour. Cache it and refresh (re-run Client Credentials, or use the refresh token for user flows) shortly before expiry rather than on every request.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

JSON Formatter

Related Movies, TV & Music APIs

← Back

More Movies, TV & Music APIs · All 196 APIs