# Spotify Play Count Scraper (`khadinakbar/spotify-play-count-scraper`) Actor

Scrape Spotify play counts (stream counts) for every track on any track, album, playlist, or artist. One flat row per track. HTTP-only, no API key.

- **URL**: https://apify.com/khadinakbar/spotify-play-count-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, MCP servers, Developer tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 track play counts

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Spotify Play Count Scraper

Get the **play count (stream count) of every track** on any Spotify track, album, playlist, or artist — as one flat row per track. Paste a URL, URI, or bare ID and the actor auto-detects the type, expands albums and playlists track-by-track, and returns a clean table you can drop straight into a spreadsheet, royalty model, or chart tracker. HTTP-only, no login, no API key.

### What you get

One row per track, every row carrying its play count:

| Field | Example | Notes |
|---|---|---|
| `trackName` | `Never Gonna Give You Up` | |
| `playcount` | `1605446789` | The stream count (integer) |
| `playcountFormatted` | `1,605,446,789` | Human-readable |
| `artistNames` | `Rick Astley` | Comma-joined; `artists[]` also provided |
| `albumName` / `albumId` / `albumUrl` | `Whenever You Need Somebody` | |
| `trackUrl` / `trackUri` / `trackId` | `https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT` | |
| `durationMs` / `durationText` | `213573` / `3:34` | |
| `explicit` / `trackNumber` / `discNumber` | `false` / `1` / `1` | |
| `releaseDate` | `1987-11-12T00:00:00Z` | |
| `sourceType` / `sourceId` / `sourceName` / `sourceUrl` | `album` / … | Which input the row came from |
| `dataSource` / `scrapedAt` | `partner` / ISO 8601 | |

### When to use it

- **Royalty / revenue modelling** — pull every track's streams for an album or catalog and multiply by your per-stream rate.
- **Chart & A&R tracking** — snapshot play counts for a playlist or an artist's top tracks over time.
- **Competitive research** — compare stream counts across releases.
- **Agent / MCP workflows** — a narrow tool: items in, flat play-count rows out.

**Not for** podcasts or episodes (they have no play count), monthly-listener / world-rank / top-cities data, or audio downloads. For the full entity picture (artists, podcasts, search, monthly listeners), use the companion [Spotify Scraper — All-in-One](https://apify.com/khadinakbar/spotify-all-in-one-scraper).

### Input

| Field | Required | Default | Description |
|---|---|---|---|
| `spotifyUrls` | ✅ | — | List of track / album / playlist / artist URLs, `spotify:` URIs, or bare 22-char IDs (mixed freely). |
| `defaultType` | — | `track` | How to interpret bare IDs with no type prefix (`track`/`album`/`playlist`/`artist`). |
| `maxResults` | — | `1000` | Hard cap on total track rows charged + returned. Also caps cost. |
| `proxyConfiguration` | — | Apify datacenter (US) | Datacenter US works for Spotify's Partner API. Switch to residential only if you hit rate limits. |

#### Example input

```json
{
  "spotifyUrls": [
    "https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT",
    "https://open.spotify.com/album/4aawyAB9vmqN3uQ7FjRGTy",
    "spotify:playlist:37i9dQZF1DXcBWIGoYBM5M"
  ],
  "maxResults": 500
}
````

#### How each input type expands

| Input | Rows returned |
|---|---|
| **Track** | 1 row |
| **Album** | one row per track (fully paginated) |
| **Playlist** | one row per track (episodes skipped; fully paginated) |
| **Artist** | the artist's top tracks (≈10) |

### Pricing — Pay Per Event

| Event | Price |
|---|---|
| Actor start | $0.00005 |
| **Track play count** (per track row) | **$0.002** |

A 12-track album ≈ $0.024. A 500-track playlist ≈ $1.00. `maxResults` caps the worst case. Pay-Per-Usage (compute + proxy) is also available — pick at run time.

### Usage examples

#### Apify API

```bash
curl -X POST "https://api.apify.com/v2/acts/khadinakbar~spotify-play-count-scraper/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "spotifyUrls": ["https://open.spotify.com/album/4aawyAB9vmqN3uQ7FjRGTy"], "maxResults": 200 }'
```

#### JavaScript (apify-client)

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

const client = new ApifyClient({ token: 'YOUR_TOKEN' });
const run = await client.actor('khadinakbar/spotify-play-count-scraper').call({
    spotifyUrls: ['spotify:artist:0gxyHStUsqpMadRV0Di1Qt'],
    defaultType: 'artist',
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((t) => `${t.trackName}: ${t.playcountFormatted}`));
```

#### MCP (AI agents)

Exposed as `apify--spotify-play-count-scraper` via the Apify MCP server. Feed a Spotify URL/ID, get back per-track play counts as structured JSON.

### How it works

Spotify exposes per-track play counts through its internal **Partner API** (the same data the web player shows). This actor obtains a short-lived web-player token by extracting the current TOTP secret live from Spotify's own JavaScript bundle — so it **self-heals** when Spotify rotates the secret or the GraphQL operation hashes. All over plain HTTP through a residential proxy; no browser, no login, no cookies.

### Reliability notes

- **Datacenter (US) proxy works.** The Spotify Partner API tolerates Apify datacenter IPs; residential is optional for heavier jobs.
- **Honest failure.** If Spotify is unreachable (block/auth), the run fails clearly instead of silently returning an empty dataset.
- **Play counts can be null** for a small number of tracks Spotify itself doesn't expose a count for; those rows are still returned with `playcountAvailable: false`.

### Legal

Use this actor only for data you are authorized to access and in compliance with Spotify's Terms of Service and applicable law. It collects publicly visible information and performs no login or authentication bypass. You are responsible for how you use the data. Not affiliated with or endorsed by Spotify.

# Actor input Schema

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

Use this for the Spotify items whose play counts you want. Accepts open.spotify.com URLs (incl. /intl-xx/ locales), spotify: URIs, or bare 22-char IDs, mixed freely — e.g. 'https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT' or 'spotify:album:4aawyAB9vmqN3uQ7FjRGTy'. A track yields one row; an album or playlist yields one row per track (fully paginated); an artist yields its top tracks. This is NOT for podcasts/episodes — those have no play count.

## `defaultType` (type: `string`):

Only used to interpret bare 22-char IDs that lack a URL/URI prefix (e.g. '4cOdK2wGLETKBW3PvgPWqT'). Full URLs and spotify: URIs already carry their type and ignore this. Defaults to 'track'. Set to 'album', 'playlist', or 'artist' if your bare IDs are those types.

## `maxResults` (type: `integer`):

Hard cap on the total number of track rows (play counts) charged and returned across all inputs. Pagination stops the moment this is hit, so it also caps cost. Defaults to 1000. Lower it for a quick/cheap run; raise it to fully expand large playlists.

## `proxyConfiguration` (type: `object`):

Proxy used to reach Spotify. Defaults to Apify datacenter (US), which the Spotify Partner API tolerates. If you have a residential subscription and hit rate limits, switch to residential here. Leave as-is otherwise.

## Actor input object example

```json
{
  "spotifyUrls": [
    "https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M"
  ],
  "defaultType": "track",
  "maxResults": 1000,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# 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 = {
    "spotifyUrls": [
        "https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT",
        "https://open.spotify.com/album/4aawyAB9vmqN3uQ7FjRGTy"
    ],
    "maxResults": 1000,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/spotify-play-count-scraper").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 = {
    "spotifyUrls": [
        "https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT",
        "https://open.spotify.com/album/4aawyAB9vmqN3uQ7FjRGTy",
    ],
    "maxResults": 1000,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/spotify-play-count-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "spotifyUrls": [
    "https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT",
    "https://open.spotify.com/album/4aawyAB9vmqN3uQ7FjRGTy"
  ],
  "maxResults": 1000,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call khadinakbar/spotify-play-count-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=khadinakbar/spotify-play-count-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Spotify Play Count Scraper",
        "description": "Scrape Spotify play counts (stream counts) for every track on any track, album, playlist, or artist. One flat row per track. HTTP-only, no API key.",
        "version": "0.1",
        "x-build-id": "WC0oRirT06tAd8wQv"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/khadinakbar~spotify-play-count-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-khadinakbar-spotify-play-count-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/khadinakbar~spotify-play-count-scraper/runs": {
            "post": {
                "operationId": "runs-sync-khadinakbar-spotify-play-count-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/khadinakbar~spotify-play-count-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-khadinakbar-spotify-play-count-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "spotifyUrls"
                ],
                "properties": {
                    "spotifyUrls": {
                        "title": "Spotify tracks, albums, playlists, or artists",
                        "type": "array",
                        "description": "Use this for the Spotify items whose play counts you want. Accepts open.spotify.com URLs (incl. /intl-xx/ locales), spotify: URIs, or bare 22-char IDs, mixed freely — e.g. 'https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT' or 'spotify:album:4aawyAB9vmqN3uQ7FjRGTy'. A track yields one row; an album or playlist yields one row per track (fully paginated); an artist yields its top tracks. This is NOT for podcasts/episodes — those have no play count.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "defaultType": {
                        "title": "Type for bare IDs",
                        "enum": [
                            "track",
                            "album",
                            "playlist",
                            "artist"
                        ],
                        "type": "string",
                        "description": "Only used to interpret bare 22-char IDs that lack a URL/URI prefix (e.g. '4cOdK2wGLETKBW3PvgPWqT'). Full URLs and spotify: URIs already carry their type and ignore this. Defaults to 'track'. Set to 'album', 'playlist', or 'artist' if your bare IDs are those types.",
                        "default": "track"
                    },
                    "maxResults": {
                        "title": "Max track play counts",
                        "minimum": 1,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "Hard cap on the total number of track rows (play counts) charged and returned across all inputs. Pagination stops the moment this is hit, so it also caps cost. Defaults to 1000. Lower it for a quick/cheap run; raise it to fully expand large playlists.",
                        "default": 1000
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Proxy used to reach Spotify. Defaults to Apify datacenter (US), which the Spotify Partner API tolerates. If you have a residential subscription and hit rate limits, switch to residential here. Leave as-is otherwise.",
                        "default": {
                            "useApifyProxy": true
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
