MarkdownCopies this page as Markdown, ready to paste into an AI assistant.
Spotify API
5 Spotify endpoints behind one key, priced in credits per call or per result and routed to the cheapest healthy source.
On this page
Audio · 5 endpoints · from 2 credits per call
Endpoints
- POSTSpotify Album
/v1/run/spotify.albumA Spotify album by URL or ID with its tracklist, per-track play counts, album total, label and release date.5 creditsper call - POSTSpotify Artist
/v1/run/spotify.artistA Spotify artist by URL or ID: followers, monthly listeners, world rank, top cities, top tracks with play counts and releases.2 creditsper call - POSTSpotify Play Count
/v1/run/spotify.play_countLifetime stream counts for a Spotify track, every track of an album, or an artist's top tracks, from one URL.1.13 creditsper result - POSTSpotify Podcast
/v1/run/spotify.podcastA Spotify podcast show by URL or ID: name, publisher, description, artwork, episode count and languages.2 creditsper call - POSTSpotify Track
/v1/run/spotify.trackOne Spotify track by URL or ID: lifetime play count, popularity, duration, artists and album details.2 creditsper call
Calling them
Every endpoint on this page is one POST to https://api.primaryapi.com/v1/run/{sku} with your API key and a JSON body. Responses share one envelope, so code written for one endpoint handles the others. For example, spotify.album:
curl -sS -X POST "https://api.primaryapi.com/v1/run/spotify.album" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://open.spotify.com/album/4yP0hdKOZPNshxUOjY0cZj"}'const res = await fetch('https://api.primaryapi.com/v1/run/spotify.album', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRIMARYAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://open.spotify.com/album/4yP0hdKOZPNshxUOjY0cZj',
}),
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.code}: ${body.error}`);
// found:false is a successful answer ("does not exist"), not an error
console.log(body.output.found ? body.output.data : body.output.reason, body.credits);import os
import requests
res = requests.post(
"https://api.primaryapi.com/v1/run/spotify.album",
headers={"Authorization": f"Bearer {os.environ['PRIMARYAPI_API_KEY']}"},
json={
"url": "https://open.spotify.com/album/4yP0hdKOZPNshxUOjY0cZj",
},
timeout=60,
)
body = res.json()
if not res.ok:
raise RuntimeError(f"{body['code']}: {body['error']}")
# found=False is a successful answer ("does not exist"), not an error
print(body["output"]["data"] if body["output"]["found"] else body["output"]["reason"], body["credits"])New to PrimaryAPI? Start with the Quickstart, then read Making requests.