# YouTube Music Downloader (`maximedupre/youtube-music-downloader`) Actor

Download audio from YouTube Music and YouTube URLs. Save MP3, M4A, AAC, Opus, FLAC, WAV, Vorbis, or ALAC files to Apify storage with title, channel, duration, thumbnail, upload date, likes, comments, and file size.

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

## Pricing

$2.65 / 1,000 downloaded tracks

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

### 🎧 Download YouTube Music audio files

YouTube Music Downloader downloads audio from direct [YouTube Music](https://music.youtube.com/) and YouTube URLs, saves the audio file to Apify storage, and returns a clean dataset row for every successfully saved track. Add track or video URLs, choose an output format such as MP3, M4A, AAC, Opus, FLAC, WAV, Vorbis, or ALAC, and export the results from Apify as JSON, CSV, Excel, XML, or through the API.

Use it when you already have the YouTube Music or YouTube URLs you want to process and need downloadable audio files with useful source metadata. The actor does not require a YouTube API key, YouTube login, cookies, or user-provided proxy setup.

### ✅ What this YouTube Music Downloader does

- Accepts direct YouTube Music watch URLs, YouTube watch URLs, Shorts URLs, and youtu.be links.
- Saves one audio file for each successfully processed track or video.
- Supports MP3, M4A, AAC, Opus, FLAC, WAV, Vorbis, ALAC, and Auto format selection.
- Returns title, channel or artist name, duration, thumbnail, upload date, likes, comments, file size, and the saved audio URL when available.
- Skips unavailable, private, invalid, or failed URLs without creating misleading output rows.
- Charges only for URLs that produce a saved downloadable audio file.

This actor is built for direct URL workflows. Playlist expansion, radio queues, search, recommendations, and logged-in private content are not part of the current contract.

### 📊 Data you can export

Each successful download creates one dataset row. The most important fields are:

- `submittedUrl` - the exact input URL that produced the row.
- `videoId` - the YouTube video ID.
- `title` - the source-backed track or video title.
- `channelName` and `channelUrl` - artist or channel details when available.
- `durationSeconds` - track length in seconds when available.
- `thumbnailUrl` - best available thumbnail URL.
- `audioUrl` - Apify storage URL for the saved audio file.
- `audioFormat` - the actual saved file format.
- `audioBitrateKbps`, `fileSizeBytes`, `uploadDate`, `likeCount`, and `commentCount` - additional source or file metadata when available.

Because `submittedUrl` is included in every row, you can match outputs back to your original input list without needing a separate source URL field.

### 🚀 How to run

1. Open the actor on Apify.
2. Add one or more direct YouTube Music or YouTube URLs.
3. Choose the audio format and target quality.
4. Start the run.
5. Open the dataset to download the metadata, and use `audioUrl` to access each saved audio file.

You can also run the actor through Apify API, schedules, webhooks, or integrations when you want to process recurring batches of known URLs.

### 🔧 Input

| Field | Required | Description |
| --- | --- | --- |
| `urls` | Yes | Direct YouTube Music, YouTube watch, Shorts, or youtu.be URLs. |
| `format` | No | Audio file type to save. Default is MP3. Auto also uses MP3. |
| `quality` | No | Target bitrate or best available source quality. |

Use direct track or video links. If a submitted URL cannot be downloaded, it is skipped and no dataset row is emitted for that URL.

### 📦 Output example

```json
{
  "submittedUrl": "https://music.youtube.com/watch?v=avP3YCQiJPc",
  "videoId": "avP3YCQiJPc",
  "title": "Kun Anta",
  "channelName": "Humood AlKhudher",
  "channelUrl": "https://www.youtube.com/channel/UCexample",
  "durationSeconds": 241,
  "thumbnailUrl": "https://i.ytimg.com/vi/avP3YCQiJPc/maxresdefault.jpg",
  "audioUrl": "https://api.apify.com/v2/key-value-stores/store-id/records/avP3YCQiJPc.mp3",
  "audioFormat": "mp3",
  "audioBitrateKbps": 128,
  "fileSizeBytes": 3891200,
  "uploadDate": "2022-05-31",
  "likeCount": 73100,
  "commentCount": 818
}
````

Optional metadata can be `null` when YouTube does not provide it for a specific URL.

### 💰 Pricing

This actor uses pay-per-event pricing. You are charged $0.00265 only for each submitted YouTube Music or YouTube URL that is saved as a downloadable audio file.

Invalid URLs, private videos, unavailable videos, and failed downloads do not create output rows and are not charged as downloaded tracks.

### ⚠️ Limits and responsible use

Use this actor only for content you own, have permission to process, or are otherwise allowed to download in your jurisdiction and under the source site's terms.

The actor works with public, directly accessible YouTube Music and YouTube URLs. It does not log into YouTube, bypass private access, expand playlists or radio stations, or process URLs that require a user session.

### ❓ FAQ

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

No. The actor works from public direct URLs and does not ask for YouTube credentials.

**Can it download normal YouTube videos too?**

Yes, when the submitted YouTube watch, Shorts, or youtu.be URL exposes downloadable audio. The output is an audio file plus source metadata, not a video file.

**Does it expand YouTube Music playlists or radio URLs?**

No. Submit the direct track or video URLs you want to download. Playlist and radio expansion are intentionally outside this actor's current scope.

**What happens when a URL fails?**

The URL is skipped. The actor does not emit a partial row for failed downloads and does not charge the downloaded-track event for that URL.

**Which audio format should I choose?**

MP3 is the default and works well for most workflows. Use M4A, AAC, Opus, FLAC, WAV, Vorbis, or ALAC when your downstream tool needs that format.

### 📝 Changelog

- 0.1: Initial release.

### 🆘 Support

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

### 🔗 Other actors

- [Spotify Downloader ↗](https://apify.com/maximedupre/spotify-downloader) - Resolve Spotify track URLs and searches into metadata, preview URLs, and MP3 media links.
- [SoundCloud MP3 Downloader ↗](https://apify.com/maximedupre/soundcloud-mp3-downloader) - Find public SoundCloud track media links and metadata.
- [TikTok Video Downloader ↗](https://apify.com/maximedupre/tiktok-video-downloader) - Save public TikTok videos or audio tracks to Apify storage.
- [Streamable Video Downloader ↗](https://apify.com/maximedupre/streamable-video-downloader) - Extract media links and metadata from public Streamable URLs.
- [YouTube Region Restriction Checker ↗](https://apify.com/maximedupre/youtube-region-restriction-checker) - Check where public YouTube videos can be viewed by country.

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

# Actor input Schema

## `urls` (type: `array`):

Add direct YouTube Music track URLs, YouTube watch URLs, Shorts, or youtu.be links.

## `format` (type: `string`):

Choose the audio file type to save for each accepted track. Auto uses MP3.

## `quality` (type: `string`):

Choose a target bitrate or use the best available source quality.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://music.youtube.com/watch?v=avP3YCQiJPc"
    }
  ],
  "format": "mp3",
  "quality": "best"
}
```

# Actor output Schema

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

Open the dataset with one row per successfully downloaded track, including the audio file URL, submitted URL, title, artist/channel, duration, thumbnail, and available source counts.

# 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 = {
    "urls": [
        {
            "url": "https://music.youtube.com/watch?v=avP3YCQiJPc"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("maximedupre/youtube-music-downloader").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 = { "urls": [{ "url": "https://music.youtube.com/watch?v=avP3YCQiJPc" }] }

# Run the Actor and wait for it to finish
run = client.actor("maximedupre/youtube-music-downloader").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 '{
  "urls": [
    {
      "url": "https://music.youtube.com/watch?v=avP3YCQiJPc"
    }
  ]
}' |
apify call maximedupre/youtube-music-downloader --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Music Downloader",
        "description": "Download audio from YouTube Music and YouTube URLs. Save MP3, M4A, AAC, Opus, FLAC, WAV, Vorbis, or ALAC files to Apify storage with title, channel, duration, thumbnail, upload date, likes, comments, and file size.",
        "version": "0.1",
        "x-build-id": "TBpxxuNgX354UEjR6"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/maximedupre~youtube-music-downloader/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-maximedupre-youtube-music-downloader",
                "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-downloader/runs": {
            "post": {
                "operationId": "runs-sync-maximedupre-youtube-music-downloader",
                "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-downloader/run-sync": {
            "post": {
                "operationId": "run-sync-maximedupre-youtube-music-downloader",
                "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": [
                    "urls"
                ],
                "properties": {
                    "urls": {
                        "title": "Music URLs",
                        "type": "array",
                        "description": "Add direct YouTube Music track URLs, YouTube watch URLs, Shorts, or youtu.be links.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "title": "URL",
                                    "type": "string",
                                    "description": "A direct YouTube Music or YouTube URL.",
                                    "minLength": 1
                                }
                            }
                        }
                    },
                    "format": {
                        "title": "Audio format",
                        "enum": [
                            "mp3",
                            "m4a",
                            "aac",
                            "opus",
                            "flac",
                            "wav",
                            "vorbis",
                            "alac",
                            "auto"
                        ],
                        "type": "string",
                        "description": "Choose the audio file type to save for each accepted track. Auto uses MP3.",
                        "default": "mp3"
                    },
                    "quality": {
                        "title": "Audio quality",
                        "enum": [
                            "best",
                            "320",
                            "256",
                            "128",
                            "64"
                        ],
                        "type": "string",
                        "description": "Choose a target bitrate or use the best available source quality.",
                        "default": "best"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
