# Spotify Music Knowledge Graph Scraper (`w3crawler/spotify-music-knowledge-graph-scraper`) Actor

Build a transparent one-hop provenance graph from a public Spotify artist, track, album, or playlist page.

- **URL**: https://apify.com/w3crawler/spotify-music-knowledge-graph-scraper.md
- **Developed by:** [w3crawler](https://apify.com/w3crawler) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 music knowledge graphs

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/actors/running/actors-in-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 Knowledge Graph Scraper

Build a bounded **public-page evidence graph** from a Spotify seed entity. The Actor records entity nodes, one rendered-page evidence node per visited page, and directional edges for links that are visibly present. It does not call a similarity API or invent relationships: every edge either points to a link rendered on the page or connects a page to its evidence node.

### Get started

1. Open the [Actor Store page](https://apify.com/w3crawler/spotify-music-knowledge-graph-scraper) and select **Try for free** or open the **Input** tab.
2. Enter a public Spotify artist, track, album, or playlist URL, or a 22-character ID, in `seedUrl`.
3. Set `seedType` only when `seedUrl` is a bare ID; use `depth: 1` for a one-hop graph and `2` for a small second-hop sample.
4. Start the Actor, open the dataset, and export the saved nodes and edges as JSON, CSV, or Excel. Open **Run summary** (`OUTPUT_SUMMARY`) to check the outcome and counts.

### Input

`seedUrl` is required. Unsupported field names and out-of-range values are rejected before requests start.

| Field | Type | Required? | Default | Meaning |
| --- | --- | --- | --- | --- |
| `seedUrl` | string | Required | Not supplied | Public Spotify artist, track, album, or playlist URL, or a 22-character ID. |
| `seedType` | string enum | Optional | `artist` | Entity type for a bare ID only; URLs determine their own type. Allowed: `artist`, `track`, `album`, `playlist`. |
| `depth` | integer | Optional | `1` | Bounded public-link traversal, 1–2. Depth 2 visits only a small set of stable links observed on the seed page. |
| `market` | string | Optional | `US` | Two-letter market context recorded in graph rows. The public page is not market-forced. |
| `timeoutSecs` | integer | Optional | `30` | Maximum seconds for each public page request, 5–60. |
| `maxResponseBytes` | integer | Optional | `2000000` | Safety limit for each downloaded public page, 100000–5000000 bytes. |

Full default input (supply `seedUrl` before running):

```json
{
  "seedType": "artist",
  "depth": 1,
  "market": "US",
  "timeoutSecs": 30,
  "maxResponseBytes": 2000000
}
```

The Actor reads anonymous, public Spotify entity pages. It does not log in, call the official Web API or a similarity service, capture tokens, download audio, solve CAPTCHAs, or synthesize edges.

### Output

The dataset contains `node` and `edge` rows. Optional values are omitted rather than inferred, and no diagnostic or placeholder rows are written.

| Field | Type | Availability | Meaning |
| --- | --- | --- | --- |
| `recordId` | string | Always | Stable key for the node or edge record. |
| `recordType` | string | Always | `node` or `edge`. |
| `sourceUrl` | string | Always | Public page that exposed the node or edge. Observed field not declared in `dataset_schema.json`. |
| `scrapedAt` | string | Always | Time the record was saved, in ISO UTC. |
| `depth` | integer | Always | Traversal depth: 0 for the seed entity, 1 for direct neighbors/evidence, 2 for second-hop records. |
| `market` | string | Always | Requested market context; the public page is not market-forced. |
| `visibleLinkCount` | integer | Always | Unique visible links observed on the source page. Observed field not declared in `dataset_schema.json`. |
| `nodeId` | string | Node rows | Node key in the form `<type>:<id>`, or the generated evidence-node key. |
| `entityType` | string | Node rows | `artist`, `track`, `album`, `playlist`, or `publicRenderedPageEvidence`. |
| `entityId` | string | Node rows | Public entity ID, or the generated evidence identifier. |
| `name` | string | Node rows | Entity name, or the fixed evidence-node label. |
| `spotifyUrl` | string | Node rows | Public entity URL, or the page URL for an evidence node. |
| `description` | string | Node rows when `og:description` is exposed | Public page description. It was not present in the saved run. |
| `releaseDate` | string | Node rows when the page exposes it | Public release date metadata. It was not present in the saved run. |
| `imageUrl` | string | Node rows when `og:image` is exposed | Artwork URL. It was not present in the saved entity nodes. |
| `observedFromId` | string | Neighbor node rows | Page node that exposed the link. The seed node has no parent. |
| `edgeId` | string | Edge rows | Stable edge key, including the relationship. |
| `fromId` | string | Edge rows | Source node ID. |
| `toId` | string | Edge rows | Target node ID. |
| `relationship` | string | Edge rows | `visible_link` for a rendered entity link, or `supported_by` for the generated page-evidence edge. |

#### Full JSON output

The examples below are real saved rows from the 2026-10-25 verification run: one entity node and one visible-link edge.

```json
{
  "recordId": "spotify_graph_node_track_3C0nOe05EIt1390bVABLyN",
  "recordType": "node",
  "sourceUrl": "https://open.spotify.com/artist/0TnOYISbd1XYRBk9myaseg",
  "scrapedAt": "2026-10-25T20:54:19.327Z",
  "depth": 1,
  "market": "US",
  "visibleLinkCount": 40,
  "nodeId": "track:3C0nOe05EIt1390bVABLyN",
  "entityType": "track",
  "entityId": "3C0nOe05EIt1390bVABLyN",
  "name": "On The Floor",
  "spotifyUrl": "https://open.spotify.com/track/3C0nOe05EIt1390bVABLyN",
  "observedFromId": "artist:0TnOYISbd1XYRBk9myaseg"
}
```

```json
{
  "recordId": "spotify_graph_edge_artist_0TnOYISbd1XYRBk9myaseg_track_3C0nOe05EIt1390bVABLyN",
  "recordType": "edge",
  "sourceUrl": "https://open.spotify.com/artist/0TnOYISbd1XYRBk9myaseg",
  "scrapedAt": "2026-10-25T20:54:19.327Z",
  "depth": 1,
  "market": "US",
  "visibleLinkCount": 40,
  "edgeId": "artist:0TnOYISbd1XYRBk9myaseg->visible_link->track:3C0nOe05EIt1390bVABLyN",
  "fromId": "artist:0TnOYISbd1XYRBk9myaseg",
  "toId": "track:3C0nOe05EIt1390bVABLyN",
  "relationship": "visible_link"
}
```

### Run summary

**Run summary** is stored in the run's key-value store under `OUTPUT_SUMMARY`; the same object is also written to `OUTPUT`. It reports graph scope, visited entities, and node/edge counts.

| Field | Meaning |
| --- | --- |
| `recordType` | Always `runSummary`. |
| `status` | Actor outcome: `SUCCEEDED` or `FAILED`. |
| `seedId` | Seed entity ID. |
| `seedType` | Seed entity type. |
| `requestedDepth` | Requested traversal depth. |
| `maxSecondHopNeighbors` | Maximum first-hop neighbors visited at depth 2; fixed at 8. |
| `market` | Market context recorded for the run. |
| `graphMode` | Fixed value `bounded_public_rendered_links_and_provenance`. |
| `relationshipScope` | One-hop or bounded depth-2 scope recorded for the run. |
| `visitedEntityCount` | Visited entity nodes, excluding generated evidence nodes. |
| `nodeRecordCount` | All node rows, including evidence nodes. |
| `edgeRecordCount` | All edge rows, including `supported_by` evidence edges. |
| `visibleLinkEdgeCount` | Edge rows with `relationship: "visible_link"`. |
| `recordsStored` | Node and edge rows saved to the dataset. |
| `errorRecordCount` | Page or extraction failures recorded. |
| `startedAt` | Run start time, in ISO UTC. |
| `completedAt` | Time the summary was written, in ISO UTC. |
| `durationMs` | Run duration in milliseconds. |
| `runStatus` | Canonical run status; matches `status`. |
| `dataStatus` | Completeness of saved rows: `COMPLETE`, `PARTIAL`, `NO_RESULTS`, or `FAILED`. |
| `failureCount` | Operational failures and failed dataset writes. |
| `outputWriteFailureCount` | Summary or optional key-value writes that failed. |

| Status | Data status | Meaning |
| --- | --- | --- |
| `SUCCEEDED` | `COMPLETE` | The graph was saved without an extraction problem. |
| `SUCCEEDED` | `PARTIAL` | At least one row was saved, but a later page or output write failed. Saved rows remain available. |
| `SUCCEEDED` | `NO_RESULTS` | The run completed cleanly without a usable graph. |
| `FAILED` | `FAILED` | The run failed before any usable row was saved. |

Example `OUTPUT_SUMMARY` from the saved run (also written to `OUTPUT`):

```json
{
  "recordType": "runSummary",
  "status": "SUCCEEDED",
  "seedId": "0TnOYISbd1XYRBk9myaseg",
  "seedType": "artist",
  "requestedDepth": 1,
  "maxSecondHopNeighbors": 8,
  "market": "US",
  "graphMode": "bounded_public_rendered_links_and_provenance",
  "relationshipScope": "one_hop_visible_public_links_and_evidence",
  "visitedEntityCount": 41,
  "nodeRecordCount": 42,
  "edgeRecordCount": 41,
  "visibleLinkEdgeCount": 40,
  "recordsStored": 83,
  "errorRecordCount": 0,
  "startedAt": "2026-10-25T20:54:09.933Z",
  "completedAt": "2026-10-25T20:54:19.806Z",
  "durationMs": 9873,
  "runStatus": "SUCCEEDED",
  "dataStatus": "COMPLETE",
  "failureCount": 0,
  "outputWriteFailureCount": 0
}
```

### Coverage and limitations

This is an evidence graph, not Spotify's private relatedness graph. A `visible_link` edge means the target link appeared on the source page during a bounded scroll pass; it does not prove musical similarity, influence, or endorsement. Every visited page also produces one `publicRenderedPageEvidence` node and one `supported_by` edge, which is why `nodeRecordCount` and `edgeRecordCount` are larger than `visitedEntityCount` and `visibleLinkEdgeCount`.

At `depth: 1`, only the seed page and its visible links are read. At `depth: 2`, the Actor visits at most eight first-hop entity nodes and records their visible links; it does not recurse further. A page contributes at most 40 unique neighbor links to the graph, duplicates are merged by record ID, and `visibleLinkCount` describes the source page rather than the row's target. Descriptions, release dates, artwork, and listener data are page-dependent and may be absent. Failed pages are counted in the summary and logged, never synthesized into edges.

### Usage and support

Apify compute and storage costs vary with browser time, scroll passes, and the number of visited pages; depth 2 is substantially heavier because it opens up to eight additional entity pages. Start with `depth: 1`, inspect the node and edge counts, then use depth 2 only for a focused seed. See the Actor's Pricing tab for current account rates.

Use the [Actor Issues page](https://apify.com/w3crawler/spotify-music-knowledge-graph-scraper/issues) to report a problem. Include the run ID, the input used, and the `OUTPUT_SUMMARY`; do not include tokens, cookies, or private data. This Actor is an independent community tool and is not affiliated with, endorsed by, or sponsored by Spotify. Use it only for public data and in accordance with Spotify's terms, robots guidance, and applicable law.

# Changelog

This Actor's version history is a separate document: https://apify.com/w3crawler/spotify-music-knowledge-graph-scraper/changelog.md

# Actor input Schema

## `seedUrl` (type: `string`):

Public Spotify artist, track, album, or playlist URL, or a 22-character ID.

## `seedType` (type: `string`):

Used only when seedUrl is a bare 22-character ID; URLs determine their own type.

## `depth` (type: `integer`):

Bounded public-link traversal. Depth 2 visits only a small set of stable links observed on the seed page.

## `market` (type: `string`):

Two-letter market context retained in graph records.

## `timeoutSecs` (type: `integer`):

Maximum seconds for the public page request.

## `maxResponseBytes` (type: `integer`):

Safety limit for the downloaded public page.

## Actor input object example

```json
{
  "seedUrl": "https://open.spotify.com/track/3RiPr603aXAoi4GHyXx0uy",
  "seedType": "artist",
  "depth": 1,
  "market": "US",
  "timeoutSecs": 30,
  "maxResponseBytes": 2000000
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `runSummary` (type: `string`):

Run status and counters stored by the Actor.

## `compatibilitySummary` (type: `string`):

No description

## `sourceMetadata` (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 = {
    "seedUrl": "https://open.spotify.com/track/3RiPr603aXAoi4GHyXx0uy"
};

// Run the Actor and wait for it to finish
const run = await client.actor("w3crawler/spotify-music-knowledge-graph-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 = { "seedUrl": "https://open.spotify.com/track/3RiPr603aXAoi4GHyXx0uy" }

# Run the Actor and wait for it to finish
run = client.actor("w3crawler/spotify-music-knowledge-graph-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 '{
  "seedUrl": "https://open.spotify.com/track/3RiPr603aXAoi4GHyXx0uy"
}' |
apify call w3crawler/spotify-music-knowledge-graph-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,w3crawler/spotify-music-knowledge-graph-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/sX0NiCnGdot4P1fnh/builds/zy0dYu5KRQgSGOr2g/openapi.json
