# Spotify Scraper (`web-scraper/spotify-scraper`) Actor

Extracts detailed data from any Spotify track, album, or artist URL. Returns play counts, metadata, top tracks, and more—perfect for music analysis or automation. No API key needed. Just input a Spotify URL and get structured results.

- **URL**: https://apify.com/web-scraper/spotify-scraper.md
- **Developed by:** [Web\_scraper](https://apify.com/web-scraper) (community)
- **Categories:** Automation, Social media, Other
- **Stats:** 340 total users, 4 monthly users, 15.1% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Metadata Scraper – APIfy Actor

This actor extracts structured metadata from **Spotify Track, Album, or Artist pages** using the public URL.

***

### 🚀 How It Works

Provide a **Spotify URL** of a track, album, or artist. The actor will detect the type and return structured metadata in JSON format.

***

### 📅 Input

#### `url` (string, required)

A valid Spotify URL of one of the following types:

- `https://open.spotify.com/track/...`
- `https://open.spotify.com/album/...`
- `https://open.spotify.com/artist/...`

***

### ✅ Output

The output depends on the input URL type. Only one of the following keys will be present in the output JSON: `track`, `artist`, or `album`.

***

#### 🎵 Track Example

```json
{
  "track": {
    "id": "7KA4W4McWYRpgf0fWsJZWB",
    "name": "See You Again (feat. Kali Uchis)",
    "durationMs": 180386,
    "popularity": 93,
    "previewUrl": "https://p.scdn.co/mp3-preview/c703198293891e3b276800ea6b187cf7951d3d7d?cid=d8a5ed...",
    "playCount": 2425737307,
    "album": {
      "id": "2nkto6YNI4rUYTLqEwWJ3o",
      "name": "Flower Boy",
      "releaseDate": "2017-07-21",
      "image": "https://i.scdn.co/image/ab67616d0000b2738940ac99f49e44f59e6f7fb3",
      "url": "https://open.spotify.com/album/2nkto6YNI4rUYTLqEwWJ3o"
    },
    "artists": [
      {
        "id": "4V8LLVI7PbaPR0K2TGSxFF",
        "name": "Tyler, The Creator",
        "url": "https://open.spotify.com/artist/4V8LLVI7PbaPR0K2TGSxFF"
      },
      {
        "id": "1U1el3k54VvEUzo3ybLPlM",
        "name": "Kali Uchis",
        "url": "https://open.spotify.com/artist/1U1el3k54VvEUzo3ybLPlM"
      }
    ],
    "externalUrl": "https://open.spotify.com/track/7KA4W4McWYRpgf0fWsJZWB"
  }
}
```

***

#### 👤 Artist Example

```json
{
  "artist": {
    "name": "Robonoise",
    "followers": 291,
    "genres": [],
    "popularity": 24,
    "url": "https://open.spotify.com/artist/7mfdZRvtBIXta6xfFUz3rg",
    "topTracks": [
      {
        "id": "73T9pkx51ocb0qBZxlr68V",
        "name": "Echoes",
        "releaseDate": "2025-01-06",
        "totalTracks": 1,
        "url": "https://open.spotify.com/album/73T9pkx51ocb0qBZxlr68V",
        "image": "https://i.scdn.co/image/ab67616d0000b2732a93436b981953f58f824439"
      }
    ]
  }
}
```

***

#### 📁 Album Example

```json
{
  "album": [
    {
      "id": "1yIz4Y0M9akXGFz4ybSSBO",
      "name": "Alarm",
      "durationMs": 160000,
      "previewUrl": null,
      "trackNumber": 1
    },
    {
      "id": "1OvZ5PTCP98eM2zaJB2QJm",
      "name": "Dance",
      "durationMs": 160000,
      "previewUrl": "https://p.scdn.co/mp3-preview/aa6697bd04a05c18e64bd283cb8eb2b33e335277?cid=...",
      "trackNumber": 11
    }
    // ...more tracks
  ]
}
```

***

### 📌 Notes

- This actor parses Spotify’s web pages (not using the official Spotify API), so it does not require any authentication.
- For tracks, it attempts to scrape estimated **play count** where available.

***

### 📤 Example Usage (JavaScript)

```javascript
const { Actor } = require('apify');

await Actor.call('your-username/spotify-scraper', {
  url: 'https://open.spotify.com/track/7KA4W4McWYRpgf0fWsJZWB'
});
```

***

### 📋 Use Cases

- Music metadata enrichment
- Playlist analysis tools
- Artist monitoring dashboards
- Competitor insight for labels or producers

***

### 🛠️ Tech Stack

- [Apify SDK](https://sdk.apify.com/)
- [Puppeteer](https://pptr.dev/) for page parsing
- JSON-based schema output

***

### 📮 Feedback or Issues?

Feel free to open an issue on the Apify platform or fork the actor to customize it further.

***

# Actor input Schema

## `url` (type: `string`):

The URL of website you want to get the data from.

## Actor input object example

```json
{
  "url": "https://open.spotify.com/artist/7Ln80lUS6He07XvHI8qqHH"
}
```

# 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 = {
    "url": "https://open.spotify.com/artist/7Ln80lUS6He07XvHI8qqHH"
};

// Run the Actor and wait for it to finish
const run = await client.actor("web-scraper/spotify-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 = { "url": "https://open.spotify.com/artist/7Ln80lUS6He07XvHI8qqHH" }

# Run the Actor and wait for it to finish
run = client.actor("web-scraper/spotify-scraper").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 '{
  "url": "https://open.spotify.com/artist/7Ln80lUS6He07XvHI8qqHH"
}' |
apify call web-scraper/spotify-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,web-scraper/spotify-scraper"
        }
    }
}

```

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/vJZ1EOCOEVCsENnWh/builds/Ofq4PwcbpkgscNvUH/openapi.json
