# YouTube Music Song Scraper 🎵 (`easyapi/youtube-music-song-scraper`)

Scrape song details from YouTube Music search results, including title, artist, album info, duration, play counts, and more. Perfect for music data analysis and tracking.

- **URL**: https://beta-securitybyobscurity.apify.com/easyapi/youtube-music-song-scraper.md
- **Developed by:** [EasyApi](https://beta-securitybyobscurity.apify.com/easyapi) (community)
- **Categories:** Social media, Integrations, Other
- **Stats:** 7 total users, 2 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

$19.99/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.
You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

# README

## YouTube Music Song Scraper 🎵

Scrape detailed song information from YouTube Music search results. This actor helps you gather comprehensive music data including song titles, artists, albums, play counts, and more.

### Features ✨

- 🔍 Search for songs using keywords
- 📊 Get detailed song metadata
- 🎨 Multiple thumbnail sizes
- 🔗 Complete URLs for songs, artists, and albums
- ⏱️ Duration and play count information
- 📅 Timestamp for when data was scraped

### Use Cases 💡

- Music trend analysis
- Artist popularity tracking
- Playlist creation and management
- Music catalog building
- Research and data analysis

### Output 📋

The actor provides detailed information for each song, including:

- Song title and video ID
- Artist name and channel ID
- Album name and ID
- Thumbnail images in different sizes
- Song duration
- Play count statistics
- Complete URLs for all entities
- Timestamp of data collection

### Input Parameters 🎛️

| Parameter | Type | Description |
|-----------|------|-------------|
| `keywords` | Array | List of search terms to scrape songs for |
| `maxItems` | Integer | Maximum number of songs to scrape per keyword |

### Tips 💡

- Use specific keywords for more targeted results
- Adjust `maxItems` based on your data needs
- Consider rate limiting for large-scale scraping

### Limitations ⚠️

- Results depend on YouTube Music's search algorithm
- Some songs might have incomplete data
- Play counts are approximate values

Need help or have questions? Feel free to reach out through Apify's platform!

#### Input Example

A full explanation of an input example in JSON.

```json
{
    "keywords": [
        "u2"
    ],
    "maxItems": 100
}
```

#### Output sample

The results will be wrapped into a dataset which you can always find in the **Storage** tab. Here's an excerpt from the data you'd get if you apply the input parameters above:

And here is the same data but in JSON. You can choose in which format to download your data: JSON, JSONL, Excel spreadsheet, HTML table, CSV, or XML.

```json
[
    {
        "keyword": "u2",
        "data": {
            "title": "With Or Without You",
            "videoId": "oNvWDP_GkiY",
            "thumbnails": [
                {
                    "url": "https://lh3.googleusercontent.com/wJlCrdtCtp9vkjWNFurUqhxrppYKGcDcN0ZpwP0CC3z-dhtjw1yMQkFszwe4SZTMiukr7YSvWZ6Sh9Ec=w60-h60-l90-rj",
                    "width": 60,
                    "height": 60
                },
                {
                    "url": "https://lh3.googleusercontent.com/wJlCrdtCtp9vkjWNFurUqhxrppYKGcDcN0ZpwP0CC3z-dhtjw1yMQkFszwe4SZTMiukr7YSvWZ6Sh9Ec=w120-h120-l90-rj",
                    "width": 120,
                    "height": 120
                }
            ],
            "artist": {
                "name": "U2",
                "id": "UCqIQRxCUGi7hyJisyzv9zYQ",
                "url": "https://music.youtube.com/channel/UCqIQRxCUGi7hyJisyzv9zYQ"
            },
            "album": {
                "name": "The Joshua Tree (Super Deluxe)",
                "id": "MPREb_Q8UrZ760tV6",
                "url": "https://music.youtube.com/browse/MPREb_Q8UrZ760tV6"
            },
            "duration": "4:56",
            "plays": "487M plays",
            "url": "https://music.youtube.com/watch?v=oNvWDP_GkiY"
        },
        "scrapedAt": "2025-02-09T12:17:04.580Z"
    },
    ...
]
```

### Related Actors

- 🎵 [YouTube Music Albums Scraper](https://apify.com/easyapi/youtube-music-albums-scraper) - Extract comprehensive album data from YouTube Music including titles, artists and release info
- 🎵 [YouTube Music Video Scraper](https://apify.com/easyapi/youtube-music-video-scraper) - Scrape music video information from YouTube Music search results
- 🎵 [YouTube Music Playlist Scraper](https://apify.com/easyapi/youtube-music-playlist-scraper) - Extract playlist data from YouTube Music by keywords
- 🎵 [YouTube Music Artist Scraper](https://apify.com/easyapi/youtube-music-artist-scraper) - Get detailed artist information from YouTube Music search results
- 🎧 [YouTube Music Podcast Scraper](https://apify.com/easyapi/youtube-music-podcast-scraper) - Extract podcast playlists data from YouTube Music
- 🎵 [YouTube Music Profile Scraper](https://apify.com/easyapi/youtube-music-profile-scraper) - Scrape YouTube Music channel profiles and details
- 🎥 [YouTube Video Data Scraper](https://apify.com/easyapi/youtube-video-data-scraper) - Extract comprehensive metadata from YouTube videos
- 📺 [YouTube Comments Scraper](https://apify.com/easyapi/youtube-comments-scraper) - Scrape comments from YouTube videos with pagination support
- 🔍 [Youtube Search Scraper](https://apify.com/easyapi/youtube-search-scraper) - Extract search results from YouTube without logging in
- 🎵 [Spotify Songs Scraper](https://apify.com/easyapi/spotify-songs-scraper) - Extract comprehensive track information from Spotify
- 🎵 [Spotify Playlists Scraper](https://apify.com/easyapi/spotify-playlists-scraper) - Scrape playlist data from Spotify by keywords
- 🎵 [Spotify Albums Scraper](https://apify.com/easyapi/spotify-albums-scraper) - Get detailed album information from Spotify
- 🎵 [Spotify Artists Scraper](https://apify.com/easyapi/spotify-artists-scraper) - Extract artist profiles and data from Spotify
- 🎵 [Spotify Track Search](https://apify.com/easyapi/spotify-track-search) - Search and extract track data from Spotify using keywords
- 🎵 [Spotify Music MP3 Downloader](https://apify.com/easyapi/spotify-music-mp3-downloader) - Download your favorite tracks from Spotify in high quality
- 🎵 [All-in-One YouTube Music Scraper](https://apify.com/easyapi/all-in-one-youtube-music-scraper) - Comprehensive scraper for songs, videos, albums, artists and playlists on YouTube Music

# Actor input Schema

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

List of keywords to search for songs on YouTube Music

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

Maximum number of songs to scrape per keyword

## Actor input object example

```json
{
  "keywords": [
    "u2"
  ],
  "maxItems": 50
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("easyapi/youtube-music-song-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("easyapi/youtube-music-song-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 '{}' |
apify call easyapi/youtube-music-song-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Music Song Scraper 🎵",
        "description": "Scrape song details from YouTube Music search results, including title, artist, album info, duration, play counts, and more. Perfect for music data analysis and tracking.",
        "version": "0.0",
        "x-build-id": "TKIQEpjrfpYSwDOQK"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/easyapi~youtube-music-song-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-easyapi-youtube-music-song-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/easyapi~youtube-music-song-scraper/runs": {
            "post": {
                "operationId": "runs-sync-easyapi-youtube-music-song-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/easyapi~youtube-music-song-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-easyapi-youtube-music-song-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": [
                    "keywords",
                    "maxItems"
                ],
                "properties": {
                    "keywords": {
                        "title": "Search Keywords",
                        "uniqueItems": true,
                        "type": "array",
                        "description": "List of keywords to search for songs on YouTube Music",
                        "default": [
                            "u2"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxItems": {
                        "title": "Maximum Items",
                        "minimum": 1,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Maximum number of songs to scrape per keyword",
                        "default": 50
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
