Find an API

Search public APIs with auth details & Postman guides

← All APIs

Spotify Web API

api.spotify.com · Media

Media OAuth2 Free Tier Music Streaming Media

Spotify music data — search tracks, albums, artists, playlists, audio features, and recommendations. Control playback for Premium users. Free with OAuth2.

Authentication

OAuth 2.0 OAuth2 with Client Credentials or Authorization Code flow. Register at developer.spotify.com. Client Credentials grants read access to catalog; Authorization Code needed for user data.

Sample Requests

GET Search tracks

Search for a song on Spotify.

https://api.spotify.com/v1/search?q=Bohemian Rhapsody&type=track&limit=3

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
Authorization Bearer YOUR_TOKEN
curl -X GET "https://api.spotify.com/v1/search?q=Bohemian%20Rhapsody&type=track&limit=3" \
  -H "Authorization: Bearer YOUR_TOKEN"
import requests
params = {
    "q": "Bohemian Rhapsody",
    "type": "track",
    "limit": "3"
}
headers = {
    "Authorization": "Bearer YOUR_TOKEN"
}
response = requests.get(
    "https://api.spotify.com/v1/search",
    params=params,
    headers=headers,
)
print(response.json())
const url = new URL('https://api.spotify.com/v1/search');
url.searchParams.set('q', 'Bohemian Rhapsody');
url.searchParams.set('type', 'track');
url.searchParams.set('limit', '3');

const response = await fetch(url, {
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN'
  },
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
)

func main() {
	baseURL, _ := url.Parse("https://api.spotify.com/v1/search")
	q := baseURL.Query()
	q.Set("q", "Bohemian Rhapsody")
	q.Set("type", "track")
	q.Set("limit", "3")
	baseURL.RawQuery = q.Encode()
	targetURL := baseURL.String()
	req, _ := http.NewRequest("GET", targetURL, nil)
	req.Header.Set("Authorization", "Bearer YOUR_TOKEN")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.spotify.com/v1/search")
uri.query = URI.encode_www_form({
  "q" => "Bohemian Rhapsody",
  "type" => "track",
  "limit" => "3"
})

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_TOKEN"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.spotify.com/v1/search?" . http_build_query([
    "q" => "Bohemian Rhapsody",
    "type" => "track",
    "limit" => "3"
]);
$opts = ["http" => [
    "method" => "GET",
    "header" => implode("\r\n", [
        "Authorization: Bearer YOUR_TOKEN"
    ]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET Get audio features

Get audio analysis (tempo, energy, valence) for a track.

https://api.spotify.com/v1/audio-features/6rqhFgbbKwnb9MLmUQDhG6

Hover any highlighted part to learn what it does

Headers — extra info sent with the request
Authorization Bearer YOUR_TOKEN
curl -X GET "https://api.spotify.com/v1/audio-features/6rqhFgbbKwnb9MLmUQDhG6" \
  -H "Authorization: Bearer YOUR_TOKEN"
import requests
headers = {
    "Authorization": "Bearer YOUR_TOKEN"
}
response = requests.get(
    "https://api.spotify.com/v1/audio-features/6rqhFgbbKwnb9MLmUQDhG6",
    headers=headers,
)
print(response.json())
const url = 'https://api.spotify.com/v1/audio-features/6rqhFgbbKwnb9MLmUQDhG6';

const response = await fetch(url, {
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN'
  },
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	targetURL := "https://api.spotify.com/v1/audio-features/6rqhFgbbKwnb9MLmUQDhG6"
	req, _ := http.NewRequest("GET", targetURL, nil)
	req.Header.Set("Authorization", "Bearer YOUR_TOKEN")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://api.spotify.com/v1/audio-features/6rqhFgbbKwnb9MLmUQDhG6")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_TOKEN"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://api.spotify.com/v1/audio-features/6rqhFgbbKwnb9MLmUQDhG6";
$opts = ["http" => [
    "method" => "GET",
    "header" => implode("\r\n", [
        "Authorization: Bearer YOUR_TOKEN"
    ]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));

Postman Setup Guide

Get Postman ↗
  1. Register at developer.spotify.com → Create App
  2. Get access token: POST https://accounts.spotify.com/api/token with client_id:client_secret base64 encoded
  3. Set Authorization: Bearer YOUR_TOKEN
  4. Search: GET /v1/search?q=the+beatles&type=artist,track&limit=5
  5. Token expires in 1 hour — re-request for continued use

What can you build with Spotify Web API?

Spotify Web API is a Media API. Developers commonly use media APIs for:

  • storing and delivering images, video, and audio
  • building digital asset management and media libraries
  • transcoding and optimising media for the web
  • adding video streaming and playback to your app
  • automating content tagging and metadata extraction

OAuth 2.0. OAuth lets your app act on behalf of a user. You redirect them to authorise access, receive a token, then use that token in requests. Best for accessing user-owned data. Spotify Web API is free to use up to a usage limit, making it a low-risk choice to experiment with.

New to APIs? Read our beginner's guide

Open documentation ↗