# YouTube Music Scraper (`maximedupre/youtube-music-scraper`) Actor

Scrape public YouTube Music search results and URLs. Export songs, videos, albums, artists, playlists, podcasts, and profiles with titles, creators, IDs, metrics, thumbnails, and source URLs.

- **URL**: https://apify.com/maximedupre/youtube-music-scraper.md
- **Developed by:** [Maxime Dupré](https://apify.com/maximedupre) (community)
- **Categories:** Social media, Marketing, Integrations
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.65 / 1,000 scraped 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/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

### 🎵 Scrape YouTube Music data

YouTube Music Scraper collects public [YouTube Music](https://music.youtube.com/) data from search queries and known YouTube Music URLs. Use it to export songs, videos, albums, artists, playlists, podcasts, and profiles with source IDs, titles, creators, album or playlist context, durations, counts, thumbnails, and canonical URLs.

Start with a few search terms like `jazz`, `lofi beats`, or `workout music`, choose the content type you want, and set the maximum results per query. You can also submit public YouTube Music watch or playlist URLs when you already know the targets you want to enrich. The actor does not ask for a YouTube login, cookies, a YouTube API key, or source credentials.

This actor is for YouTube Music data collection and research. It is not a YouTube Music downloader and does not save audio or video files.

### ✅ What this YouTube Music Scraper does

- Searches YouTube Music by keyword for songs, videos, albums, artists, playlists, podcasts, or profiles.
- Processes public YouTube Music URLs for known tracks, videos, albums, and playlists when source data is available.
- Returns one dataset row for each accepted YouTube Music entity.
- Includes source IDs such as video IDs, playlist IDs, browse IDs, channel IDs, and profile handles when YouTube Music exposes them.
- Adds creator, album, playlist, duration, release date, play count, view count, subscriber count, song count, and thumbnail fields when available.
- Keeps unavailable source facts as `null` or empty arrays instead of inventing data.
- Charges only for successful YouTube Music results that are saved to the dataset.

### 📊 YouTube Music data you can export

Each row is shaped for exports, API calls, schedules, webhooks, and downstream joins. Key fields include:

- `matchedInput` - the search query or YouTube Music URL that produced the row.
- `contentType` - `song`, `video`, `album`, `artist`, `playlist`, `podcast`, or `profile`.
- `sourcePosition` - search result position, or `null` for direct URL results.
- `title` and `url` - the display name and canonical YouTube Music URL.
- `ids` - source-native IDs such as `videoId`, `playlistId`, `browseId`, `channelId`, and `profileHandle`.
- `creators` - artists, uploaders, channels, or playlist creators when exposed.
- `album` and `playlist` - music context for tracks, albums, playlists, and podcasts.
- `metrics` - play, view, like, subscriber, and song counts when exposed.
- `thumbnails` - source image URLs with dimensions when available.

`mediaFormats`, `description`, `tags`, and `heatmap` are included in the schema for source-backed detail data. They can be empty when YouTube Music does not expose those facts through the public source responses used by the actor.

### 🚀 How to run

1. Open YouTube Music Scraper on Apify.
2. Add one or more search queries, YouTube Music URLs, or both.
3. Pick the content type for keyword search.
4. Set the maximum results per query.
5. Start the run and export the dataset as JSON, CSV, Excel, XML, RSS, or through the Apify API.

For recurring monitoring, run the actor on an Apify schedule or connect the dataset to your own workflow with webhooks or API calls.

### 🔧 Input

| Field | Required | Description |
| --- | --- | --- |
| `keywords` | No | Search terms used to find YouTube Music entities. Add at least one keyword or URL. |
| `youtubeMusicUrls` | No | Public YouTube Music watch, album, or playlist URLs to enrich. |
| `searchType` | No | Content type for keyword search: songs, videos, albums, artists, playlists, podcasts, or profiles. Default is songs. |
| `maxResultsPerQuery` | No | Maximum search results per keyword. Default is 750. Maximum is 1000. |

Search settings apply to keyword runs. URL runs process the submitted URL list.

### 📦 Output example

```json
{
  "matchedInput": "jazz",
  "contentType": "song",
  "sourcePosition": 1,
  "title": "Autumn Leaves",
  "url": "https://music.youtube.com/watch?v=zTVlrOk9a8M",
  "ids": {
    "videoId": "zTVlrOk9a8M",
    "playlistId": "RDAMVMzTVlrOk9a8M",
    "browseId": null,
    "channelId": null,
    "profileHandle": null
  },
  "creators": [
    {
      "name": "Chet Baker",
      "channelId": null,
      "url": null
    }
  ],
  "album": {
    "title": "This Is Jazz #2",
    "playlistId": null,
    "browseId": null,
    "url": null
  },
  "playlist": null,
  "durationSeconds": 423,
  "releaseDate": null,
  "metrics": {
    "playCount": 31000000,
    "viewCount": null,
    "likeCount": null,
    "subscriberCount": null,
    "songCount": null
  },
  "thumbnails": [],
  "description": null,
  "tags": [],
  "mediaFormats": [],
  "heatmap": []
}
````

Some fields are `null` or empty when YouTube Music does not expose that fact for a specific result.

### 💰 Pricing

This actor uses pay-per-event pricing. You are charged $0.00265 for each successful YouTube Music result saved to the dataset.

Empty searches, unsupported URLs, skipped source items, and diagnostic messages do not create charged result rows.

### ⚠️ Limits and caveats

YouTube Music can expose different fields for different result types. Songs often include artists, albums, duration, and play counts. Artists may include subscriber counts. Playlists and podcasts may include song counts and playlist IDs. Missing source facts are returned as `null` or empty arrays.

Direct stream or media format URLs are not guaranteed. This actor only returns media format metadata when it is available from public source responses; it does not log in, bypass private access, or download media files.

Use the actor for public YouTube Music data you are allowed to process under the source site's terms and your local rules.

### ❓ FAQ

**Is this a YouTube Music downloader?**

No. This actor exports YouTube Music metadata. Use YouTube Music Downloader if you need saved audio files from direct track or video URLs.

**Do I need a YouTube API key, cookies, or login?**

No. The actor works from public YouTube Music surfaces and does not ask for source credentials.

**Can I search playlists, podcasts, artists, and albums?**

Yes. Set `searchType` to the content type you want for keyword search.

**Can I submit known YouTube Music URLs?**

Yes. Add public YouTube Music watch, album, or playlist URLs in `youtubeMusicUrls`. URL results return source-backed details when the public page data exposes them.

**Why are some metric fields null?**

YouTube Music does not expose every count for every entity type. The actor keeps missing source facts as `null` instead of guessing.

### 📝 Changelog

- 0.1: Initial release.

### 🆘 Support

For issues, questions, or feature requests, [file a ticket](https://console.apify.com/actors/maximedupre~youtube-music-scraper/issues) and I'll fix or implement it in less than 24h 🫡

### 🔗 Other actors

- [YouTube Music Downloader ↗](https://apify.com/maximedupre/youtube-music-downloader) - Download audio files from direct YouTube Music and YouTube URLs.
- [YouTube Channel Search Scraper ↗](https://apify.com/maximedupre/youtube-channel-search-scraper) - Find public YouTube channels from keywords or search URLs.
- [YouTube Trending Videos Scraper ↗](https://apify.com/maximedupre/youtube-trending-videos-scraper) - Track trending YouTube videos and their public metadata.
- [YouTube Tags Extractor ↗](https://apify.com/maximedupre/youtube-tags-extractor) - Extract tags and metadata from public YouTube videos.
- [SoundCloud Scraper ↗](https://apify.com/maximedupre/soundcloud-scraper) - Scrape public SoundCloud tracks, artists, playlists, albums, and comments.

**Made with ❤️ by Maxime Dupré**

# Actor input Schema

## `keywords` (type: `array`):

Find YouTube Music results from keywords such as genres, artists, moods, or topics.

## `youtubeMusicUrls` (type: `array`):

Enrich known YouTube Music tracks, videos, albums, or playlists.

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

Choose which YouTube Music search results to collect for each query.

## `maxResultsPerQuery` (type: `integer`):

Caps search results for each query. URLs are processed from the submitted list.

## Actor input object example

```json
{
  "keywords": [
    "jazz",
    "lofi beats",
    "workout music"
  ],
  "youtubeMusicUrls": [
    {
      "url": "https://music.youtube.com/watch?v=BXmEJL1mnuU"
    }
  ],
  "searchType": "songs",
  "maxResultsPerQuery": 750
}
```

# Actor output Schema

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

Open the dataset to view songs, videos, albums, artists, playlists, podcasts, and profiles.

# 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 = {
    "keywords": [
        "jazz",
        "lofi beats",
        "workout music"
    ],
    "youtubeMusicUrls": [
        {
            "url": "https://music.youtube.com/watch?v=BXmEJL1mnuU"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("maximedupre/youtube-music-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 = {
    "keywords": [
        "jazz",
        "lofi beats",
        "workout music",
    ],
    "youtubeMusicUrls": [{ "url": "https://music.youtube.com/watch?v=BXmEJL1mnuU" }],
}

# Run the Actor and wait for it to finish
run = client.actor("maximedupre/youtube-music-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 '{
  "keywords": [
    "jazz",
    "lofi beats",
    "workout music"
  ],
  "youtubeMusicUrls": [
    {
      "url": "https://music.youtube.com/watch?v=BXmEJL1mnuU"
    }
  ]
}' |
apify call maximedupre/youtube-music-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Music Scraper",
        "description": "Scrape public YouTube Music search results and URLs. Export songs, videos, albums, artists, playlists, podcasts, and profiles with titles, creators, IDs, metrics, thumbnails, and source URLs.",
        "version": "0.1",
        "x-build-id": "ArsowWfzw2SgekXTP"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/maximedupre~youtube-music-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-maximedupre-youtube-music-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/maximedupre~youtube-music-scraper/runs": {
            "post": {
                "operationId": "runs-sync-maximedupre-youtube-music-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/maximedupre~youtube-music-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-maximedupre-youtube-music-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",
                "properties": {
                    "keywords": {
                        "title": "Search queries",
                        "type": "array",
                        "description": "Find YouTube Music results from keywords such as genres, artists, moods, or topics.",
                        "items": {
                            "type": "string",
                            "minLength": 1
                        }
                    },
                    "youtubeMusicUrls": {
                        "title": "YouTube Music URLs",
                        "type": "array",
                        "description": "Enrich known YouTube Music tracks, videos, albums, or playlists.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "title": "URL",
                                    "type": "string",
                                    "description": "A public YouTube Music URL.",
                                    "minLength": 1
                                }
                            }
                        }
                    },
                    "searchType": {
                        "title": "Content type",
                        "enum": [
                            "songs",
                            "videos",
                            "albums",
                            "artists",
                            "playlists",
                            "podcasts",
                            "profiles"
                        ],
                        "type": "string",
                        "description": "Choose which YouTube Music search results to collect for each query.",
                        "default": "songs"
                    },
                    "maxResultsPerQuery": {
                        "title": "Maximum results per query",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Caps search results for each query. URLs are processed from the submitted list.",
                        "default": 750
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
