Blog / API guides

Spotify Scraper or API: What You Get

A Spotify scraper is a program that loads Spotify's web pages for artists, albums, playlists and charts and reads names, track lists and figures out of what comes back. You maintain the fetching, the parsing and the fixes when it breaks. The other route is 18 Spotify endpoints that return the same public catalogue data as JSON, with no login. Eleven cost 1 credit a call, and seven are priced by the call, from 1–2 up to 1–100 credits. This post compares the two for playlist, chart and artist tracking, budgets a job against those ranges, and gives a verdict per use case.

What does building a Spotify scraper involve?

A Spotify scraper is a fetcher, a set of parsers and a monitor, and the parsers multiply: an artist page, an album, a playlist and a chart each have their own layout. The fetcher requests those pages for the IDs you track. Each parser finds the track names, positions, durations or follower figures in the HTML or in data embedded in it. The monitor compares runs, because a long playlist that comes back half-parsed looks like a real change unless you check counts.

Music pages are often rendered in the browser, so a plain HTTP fetch may return a shell with little data in it, and you end up running a headless browser with its own memory use and crashes. Long lists load in parts, so the scraper has to follow each part to the end. Any large site also has to tell people from automated traffic, so expect slow responses and blocked requests at volume. If that happens, stop; getting around a site's protections isn't something we'd recommend.

The upkeep never ends. A layout change on any one page type breaks that parser, and you find out from the monitor or from a gap in your data. Read Spotify's terms before you build a collector, and get legal advice for commercial use.

Which Spotify endpoints replace a scraper?

The Spotify API on Perceptlayer has 18 endpoints, all GET, authenticated with one API key in the X-API-Key header and no Spotify login. Eleven cost 1 credit per successful call. Seven are priced by the call, which the credits table shows as a range: the cost depends on the call, such as pages fetched or items returned. Every successful response reports what it cost in X-Credits-Used, and a failed call costs nothing.

Endpoint Credits Required Optional
playlist 1 id none
playlist-tracks 1–10 id limit, all
charts 1–10 key limit, all
artist 1–2 id none
artist-top-tracks 1 id none
artist-discography 1 id limit, offset
artist-related 1 id none
album 1–2 id none
album-tracks 1–20 id limit, all
track 1 id none
get-many 1–100 none ids[], type
search 1 q limit, offset
search-suggestions 1 q none
show 1 id none
show-episodes 1–20 id limit, all
episode 1 id none
track-colors 1 image_uri none
discovery-audio-mix-seed 1 track_id none

IDs go up to 200 characters and q up to 300. The accepted key values for charts and type values for get-many aren't listed in the reference, and no defaults or page sizes are documented, so check them in the playground. A search request looks like this:

curl "https://api.perceptlayer.com/v1/spotify/search?q=daft+punk&limit=5" \
  -H "X-API-Key: $API_KEY"

We haven't recorded a response from the Spotify endpoints, so this post doesn't show one or list response fields. Run the calls you plan to use in the playground on the Spotify API page and read the responses there before you design storage. Data is collected from publicly available sources and returned as found at the time of the call.

How do a scraper and the endpoints compare?

A scraper costs engineering time per page type and carries blocking and terms risk; the endpoints cost credits, some at a fixed 1 and some by the call. The table compares them for a recurring job, such as tracking a set of playlists and charts each week.

DIY Spotify scraper Spotify endpoints
Setup Fetcher, often a headless browser, one parser per page type, monitoring API key in the X-API-Key header
Input Page URLs you build from IDs id, q, key, track_id or image_uri
Long lists Follow every part of the page yourself limit and all on list endpoints; limit and offset on search and artist-discography
When a page changes That page type's parser breaks Same path and parameters; no parser of yours to fix
Blocks and challenges Yours to handle Not yours; a failed call returns an error code and costs 0
Speed As fast as you can fetch without being blocked 1 request a second free, at least 5 a second paid
Cost Hosting, browser time and your time 1 credit for eleven endpoints; a range for seven, reported per call in X-Credits-Used

How do you budget the priced endpoints?

Budget each priced endpoint at the top of its range, then measure. A tracking job's cost is targets × calls per target × runs × credits per call, and for a ranged endpoint the last factor is somewhere in the range. Planning at the upper bound means a run can't surprise you; logging X-Credits-Used per call shows the real figure after the first run.

Job Calls a month Credits a month
200 playlists, playlist-tracks weekly 200 × 4 = 800 800 to 8,000
5 charts, charts daily 5 × 30 = 150 150 to 1,500
500 artists, artist-top-tracks weekly 500 × 4 = 2,000 2,000
All three 2,950 2,950 to 11,500

At the lower bound the job fits the Starter pack's 10,000 credits three times over; at the upper bound it needs the Build pack's 50,000, which covers four months of it. The 100 free credits you get once on signup cover at least 10 playlist-tracks or charts calls at the top of their range, enough to measure what yours cost. X-Credits-Remaining on every response lets a job stop before the balance runs out, and at zero calls return insufficient_credits (402) with nothing more debited. See pricing for what credits cost and the credits docs for how they're debited.

Which calls cost 1 credit no matter what?

Eleven endpoints have a flat 1 credit: playlist, artist-top-tracks, artist-discography, artist-related, track, search, search-suggestions, show, episode, track-colors and discovery-audio-mix-seed. That includes search and artist-discography, which page with limit and offset, so each page is 1 credit. A job built only on these costs exactly its call count. If a ranged call's real cost turns out high for your lists, check whether a flat endpoint answers the same question, such as artist-top-tracks for an artist's leading tracks.

Which route should you choose?

Choose by how often you need the data and which endpoints the job leans on, because that decides whether upkeep or credits dominate and how predictable the bill is. The verdicts below assume a recurring, read-only job over public catalogue data. For a look at three playlists once, open them in a browser and skip both.

  • Playlist monitoring (track adds, removals and positions over time): use playlist-tracks weekly and diff the results. Budget 1–10 credits per playlist per run and measure after the first run.
  • Chart tracking: use charts with the key for each chart, daily. Confirm the key values in the playground first, then budget 1–10 credits per chart per run.
  • Artist and catalogue research (top tracks, releases, related artists): artist-top-tracks, artist-discography and artist-related cost a flat 1 credit, so the bill equals the call count.
  • Podcast catalogues: show costs 1, show-episodes 1–20. Pull episodes only for the shows you analyse.
  • Anything involving a user's library, playback or playlists they own: neither route. These endpoints don't act on a user's behalf, and a scraper of public pages can't either.
  • An agent answering music questions: give it the endpoints through the MCP server, as the AI agents docs describe. get_endpoint costs nothing and lets it check an endpoint before call_endpoint spends credits.

For the same comparison on video, see YouTube Scraper or API; other media sources are under Apps and media. To measure your own costs, run playlist-tracks on one playlist in the playground on the Spotify API page and read X-Credits-Used, then get a free API key.

APIs in this post

Frequently asked questions

Is scraping Spotify allowed?

That depends on Spotify's terms, the law where you operate and what you do with the data, so read the terms and get legal advice for commercial use. Don't get around blocks or other protections. Public catalogue data such as track lists and chart positions is a different risk from personal data; leave listeners' details out of anything you keep.

How many credits does a Spotify call cost?

Eleven of the 18 Spotify endpoints cost 1 credit per successful call. album and artist cost 1–2, playlist-tracks and charts 1–10, album-tracks and show-episodes 1–20, and get-many 1–100, depending on the call. Every successful response reports the actual cost in X-Credits-Used, and failed calls cost nothing.

How do I keep the cost of priced endpoints predictable?

Plan each priced call at the top of its range, so 200 weekly playlist-tracks calls are budgeted at 8,000 credits a month. Log X-Credits-Used per call after the first run to see the real cost, and stop the job when X-Credits-Remaining drops below one run's budget. At zero the API returns 402 and debits nothing.

Do the Spotify endpoints need a Spotify account or login?

No. You authenticate with one API key in the X-API-Key header, and the endpoints read public catalogue data: artists, albums, tracks, playlists, charts and podcasts. They don't act on a user's behalf, so there's no library, playback or playlist editing. Keys start with sk_live_ and work across the whole catalogue.

What happens when I hit the rate limit?

A rate-limited call returns 429 with a Retry-After header giving the seconds to wait, and costs nothing. Free accounts run at 1 request a second (60 a minute), and paying accounts at least 5 a second. Limits are per account, shared by all its keys. The rate limits docs list each pack's rate, and the errors docs every code.

  1. Spotify API: Official Web API vs Public Music Data

    The Spotify Web API needs an OAuth app and limits new apps; 18 public-data endpoints cover artists, top tracks, playlists and charts, most at 1 credit a call.

  2. Genius API: Songs, Artists and Charts as JSON

    Get Genius song metadata as JSON: release date, album, artist IDs, stats.pageviews and Spotify and Apple Music IDs from one song call, 1 credit each.

  3. SoundCloud API: Tracks and Playlists as JSON

    Search SoundCloud tracks as JSON with genre, tag_list, playback_count and likes_count per track. The recorded "night drive" search reported 63,047 results.

Start with 100 free credits

No password to set. We email you a sign-in link, and your key works on every API.

No credit card. 100 free credits on signup.