# Spotify Music Catalog, Stats & Playlist Extractor (`xyrelith-data/spotify-music-catalog-stats-playlist-extractor`) Actor

Export public Spotify catalog data without a login or developer key: artist audience stats, album and track play counts, full playlists and keyword search. Paste mixed Spotify URLs or URIs, or search the catalog, then export nested entity rows or one flat row per track.

- **URL**: https://apify.com/xyrelith-data/spotify-music-catalog-stats-playlist-extractor.md
- **Developed by:** [Xyrelith Data](https://apify.com/xyrelith-data) (community)
- **Categories:** Social media, Automation, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Spotify Music Catalog, Stats & Playlist Extractor

Export public Spotify music data without a Spotify account, cookies or developer API key. This
actor reads the same anonymous catalog the Spotify web player uses and returns clean records for
artists, albums, tracks and playlists — including monthly listeners, exact play counts, top cities
and full track lists.

### Two ways to run it

**Search the catalog.** Enter a keyword, choose tracks, artists, albums, playlists or a balanced
mix of all four, and set how many rows you want. Search results are enriched into full records, not
shallow search cards.

**Scrape Spotify links or URIs.** Paste any mix of artist, album, track and playlist links in one
list. Examples:

- `https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02`
- `spotify:album:2fenSS68JI1h4Fo296JfGr`
- `https://open.spotify.com/intl-de/track/11dFghVXANMlKmJXsNCbNl`
- `spotify:playlist:37i9dQZF1DXcBWIGoYBM5M`

An artist link can optionally expand into every album, single/EP, compilation, appears-on release
and related artist as separate dataset rows.

### Output layouts

- **One row per entity** keeps an artist, album, track or playlist in one record and nests its
  track list. Use this for JSON integrations and browsing.
- **One row per track** emits album tracks, playlist tracks and artist top tracks as flat records
  with `parentType`, `parentId`, `playlistPosition` or `rowPosition` and `addedAt` where relevant.
  Use this for CSV/Excel play-count tables.

### Inputs

| Input | Type | Default | What it does |
|---|---|---|---|
| `mode` | select | `"search"` | Search the catalog or scrape pasted links. |
| `searchQuery` | text | `"Taylor Swift"` | Keyword used in search mode. |
| `searchType` | select | `"track"` | Track, artist, album, playlist or a balanced all-types mix. |
| `spotifyUrls` | string list | `[]` | Mixed Spotify URLs or URIs for link mode. |
| `maxItems` | integer | `100` | Hard cap on dataset rows for the whole run. |
| `maxItemsPerInput` | integer | `100` | Row cap for each pasted link (link mode only). |
| `maxTracksPerPlaylist` | integer | `500` | Playlist track cap, paged 100 at a time. |
| `outputLayout` | select | `"entity"` | Nested entity rows or flat track rows. |
| `includeTrackPlayCounts` | boolean | `true` | Include exact per-track play counts and totals. |
| `includeArtistTopCities` | boolean | `true` | Include the artist's top listener cities. |
| `expandArtistAlbums` | boolean | `false` | Emit every album for an artist link. |
| `expandArtistSingles` | boolean | `false` | Emit every single and EP for an artist link. |
| `expandArtistCompilations` | boolean | `false` | Emit every compilation for an artist link. |
| `expandArtistAppearsOn` | boolean | `false` | Emit every release the artist appears on. |
| `expandArtistRelated` | boolean | `false` | Emit full records for related artists. |

`mode` is the only required input. Every other field has a working default.

### Fields per record

| Record | Fields |
|---|---|
| Artist | `artistId`, `name`, `url`, `uri`, `verified`, `followers`, `monthlyListeners`, `worldRank`, `topCities`, `topTracks`, `biography`, `externalLinks`, `avatarUrl`, `headerImageUrl`, `galleryImageUrls`, `albumCount`, `singleCount`, `compilationCount`, `popularReleaseCount`, `latestRelease`, `relatedArtists`, `relatedArtistTotal`, `appearsOnCount`, `artistPlaylists`, `discoveredOnPlaylists`, `featuringPlaylists` |
| Album | `albumId`, `name`, `type`, `releaseDate`, `label`, `copyrights`, `artists`, `coverUrl`, `totalTracks`, `tracks`, `discs`, `totalPlayCount`, `totalDurationMs`, `moreAlbumsByArtist`, `releases`, `isPlayable`, `isPreRelease`, `sharingUrl` |
| Track | `trackId`, `name`, `artists`, `albumId`, `albumName`, `albumType`, `releaseDate`, `durationMs`, `explicit`, `playCount`, `trackNumber`, `discNumber`, `mediaType`, `contentRating`, `isPlayable`, `coverUrl`, `copyrights` |
| Playlist | `playlistId`, `name`, `description`, `ownerName`, `ownerUsername`, `ownerUrl`, `ownerAvatarUrl`, `followers`, `totalTracks`, `coverUrl`, `format`, `isEditorial`, `tracks`, `totalPlayCount`, `totalDurationMs`, `sharingUrl` |

Every dataset row also carries `recordType`, `sourceUrl` and `scrapedAt`. Nested track objects
include `trackId`, `name`, `url`, `artists`, `album*`, `releaseDate`, `durationMs`, `explicit`,
`trackNumber`, `discNumber`, `playCount`, `mediaType`, `contentRating` and `isPlayable` when
Spotify publishes them. Search rows add `searchQuery`, `searchType` and `searchRank`.

### Examples

Search tracks:

```json
{
  "mode": "search",
  "searchQuery": "Taylor Swift",
  "searchType": "track",
  "maxItems": 20
}
```

Scrape a mixed list and expand an artist:

```json
{
  "mode": "byUrls",
  "spotifyUrls": [
    "spotify:artist:06HL4z0CvFAxyc27GXpf02",
    "spotify:playlist:37i9dQZF1DX4UtSsGT1Sbe"
  ],
  "expandArtistAlbums": true,
  "expandArtistSingles": true,
  "maxTracksPerPlaylist": 1000,
  "outputLayout": "entity",
  "maxItems": 200
}
```

Flat playlist table:

```json
{
  "mode": "byUrls",
  "spotifyUrls": ["spotify:playlist:37i9dQZF1DXcBWIGoYBM5M"],
  "outputLayout": "track",
  "maxTracksPerPlaylist": 500
}
```

### How it works

The actor obtains a short-lived anonymous session from Spotify's public embed page, falling back to
the public token endpoint. It then calls Spotify's own persisted GraphQL operations for search,
artist overview, album tracks, single tracks and playlist pages. Persisted-query hashes are
refreshed from the current web-player bundle at startup, with bundled fallbacks for the operations
the bundle loads lazily. No user login, cookie, proxy setup or developer app is needed.

### Notes and honest limits

- Spotify search returns at most about 1,000 results per entity type. Narrow the keyword, or run
  several searches, to reach deeper catalogs.
- Spotify exposes at most 50 appears-on releases on an artist profile. The artist record still
  reports the full `appearsOnCount` from Spotify's catalog count.
- The catalog follows the runner's network location. There is no input that changes Spotify's
  market: extra market/locale variables and headers were tested and do not alter results. The actor
  reports Spotify's own `isPlayable` flag for each track and album.
- Playlists are paged 100 tracks at a time and can be read far beyond 1,000 tracks. Raise
  `maxTracksPerPlaylist` for very long playlists; `totalTracks` always reports the full length even
  when the emitted track list is capped.
- Some artists genuinely lack a public biography, header image, top-city data or external links.
  Those fields are omitted for that record rather than filled with placeholders.
- Audio features, lyrics, private listener demographics and email addresses are not part of the
  anonymous public payload and are not included.

### Data source

Public Spotify web-player catalog responses. The actor is read-only, does not log in, and never
writes to Spotify.

# Actor input Schema

## `mode` (type: `string`):

Choose how to find Spotify entities.

## `searchQuery` (type: `string`):

Keyword search text, for example an artist, song, album or playlist name. Spotify returns its own relevance order.

## `searchType` (type: `string`):

Which Spotify entity type to search. Choose All to search tracks, artists, albums and playlists in one run.

## `spotifyUrls` (type: `array`):

Paste any mix of Spotify artist, album, track and playlist links or URIs. Examples: https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02, spotify:track:11dFghVXANMlKmJXsNCbNl, https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M.

## `maxItems` (type: `integer`):

Hard cap on emitted dataset rows for the whole run.

## `maxItemsPerInput` (type: `integer`):

Cap on emitted rows for each pasted URL/URI. Applies to artist expansions, album track rows and playlist track rows. It does not apply to search mode.

## `maxTracksPerPlaylist` (type: `integer`):

How many playlist tracks to include. Spotify is paged 100 tracks at a time, so any playlist length can be covered; the playlist record still reports the full totalTracks count.

## `outputLayout` (type: `string`):

Entity layout keeps one row per artist/album/track/playlist with nested track lists. Track layout emits one flat row per track, ready for play-count spreadsheets.

## `includeTrackPlayCounts` (type: `boolean`):

Include exact Spotify play counts on tracks, plus album and playlist play-count totals. Turn off for a lighter record.

## `includeArtistTopCities` (type: `boolean`):

Include the artist's top listener cities with listener counts (mode=search type=artist or mode=byUrls with an artist link).

## `expandArtistAlbums` (type: `boolean`):

When an artist URL is scraped, also emit one album record for every album in the discography.

## `expandArtistSingles` (type: `boolean`):

When an artist URL is scraped, also emit one album record for every single and EP.

## `expandArtistCompilations` (type: `boolean`):

When an artist URL is scraped, also emit one album record for every compilation.

## `expandArtistAppearsOn` (type: `boolean`):

When an artist URL is scraped, also emit one album record for every release the artist appears on.

## `expandArtistRelated` (type: `boolean`):

When an artist URL is scraped, also emit full artist records for Spotify's related artists.

## Actor input object example

```json
{
  "mode": "search",
  "searchQuery": "Taylor Swift",
  "searchType": "track",
  "spotifyUrls": [],
  "maxItems": 3,
  "maxItemsPerInput": 5,
  "maxTracksPerPlaylist": 50,
  "outputLayout": "entity",
  "includeTrackPlayCounts": true,
  "includeArtistTopCities": false,
  "expandArtistAlbums": false,
  "expandArtistSingles": false,
  "expandArtistCompilations": false,
  "expandArtistAppearsOn": false,
  "expandArtistRelated": false
}
```

# Actor output Schema

## `music` (type: `string`):

Dataset containing every scraped artist, album, track or playlist record.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "search",
    "searchQuery": "Taylor Swift",
    "searchType": "track",
    "spotifyUrls": [],
    "maxItems": 3,
    "maxItemsPerInput": 5,
    "maxTracksPerPlaylist": 50,
    "outputLayout": "entity",
    "includeTrackPlayCounts": true,
    "includeArtistTopCities": false,
    "expandArtistAlbums": false,
    "expandArtistSingles": false,
    "expandArtistCompilations": false,
    "expandArtistAppearsOn": false,
    "expandArtistRelated": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("xyrelith-data/spotify-music-catalog-stats-playlist-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "search",
    "searchQuery": "Taylor Swift",
    "searchType": "track",
    "spotifyUrls": [],
    "maxItems": 3,
    "maxItemsPerInput": 5,
    "maxTracksPerPlaylist": 50,
    "outputLayout": "entity",
    "includeTrackPlayCounts": True,
    "includeArtistTopCities": False,
    "expandArtistAlbums": False,
    "expandArtistSingles": False,
    "expandArtistCompilations": False,
    "expandArtistAppearsOn": False,
    "expandArtistRelated": False,
}

# Run the Actor and wait for it to finish
run = client.actor("xyrelith-data/spotify-music-catalog-stats-playlist-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "search",
  "searchQuery": "Taylor Swift",
  "searchType": "track",
  "spotifyUrls": [],
  "maxItems": 3,
  "maxItemsPerInput": 5,
  "maxTracksPerPlaylist": 50,
  "outputLayout": "entity",
  "includeTrackPlayCounts": true,
  "includeArtistTopCities": false,
  "expandArtistAlbums": false,
  "expandArtistSingles": false,
  "expandArtistCompilations": false,
  "expandArtistAppearsOn": false,
  "expandArtistRelated": false
}' |
apify call xyrelith-data/spotify-music-catalog-stats-playlist-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,xyrelith-data/spotify-music-catalog-stats-playlist-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/OsDelWTVZAfNZgo5y/builds/eIT8XmUw0gn2EcumX/openapi.json
