# YouTube Audio Downloader (`utils/youtube-link`) Actor

Extract high-quality audio from any YouTube video in seconds. Choose MP3, M4A, or WAV with custom bitrate. Built with smart fallback strategies and proxy rotation for reliable extraction as YouTube's detection evolves. Batch-ready, fast, actively maintained.

- **URL**: https://apify.com/utils/youtube-link.md
- **Developed by:** [Oliver Queen](https://apify.com/utils) (community)
- **Categories:** Social media, Videos, Developer tools
- **Stats:** 63 total users, 34 monthly users, 92.1% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $9.00 / 1,000 audio downloadeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

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

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## YouTube Audio Downloader

Turn any list of YouTube links into ready-to-download audio files — fully automatic, no login, no cookies.

> **You only pay for files that download successfully. Failed downloads are always free.**

***

### Why this actor

| | |
|---|---|
| **Success-only pricing** | Flat **$0.015 per audio file**. Blocked, private or failed videos cost you **nothing**. |
| **Zero setup** | No API keys, no cookies, no third-party services. Just paste links and run. |
| **Parallel everything** | Every video is split across multiple connections and up to 10 videos process at once. |
| **Self-healing** | Failed connections are rotated automatically, and failed videos get rescue retries. |
| **Migration-proof** | If Apify moves your run to another host, finished files are remembered and never re-downloaded. |
| **Per-video control** | Each link can have its own format, quality and timeframe cut. |

***

### Pricing

| Event | Price | When |
|---|---|---|
| `AUDIO_DOWNLOADED` | **$0.015 / file** | Audio downloaded successfully |
| `AUDIO_LONG_EXTRA` | **+$0.004 / 10 min block** | Files longer than 10 minutes (podcasts, mixes) |

- Failed, blocked or unavailable videos → **$0**
- No start fee, no platform-usage charge
- Cap spending with the standard `maxTotalChargeUsd` run option

*Examples: a typical 3-minute song ≈ $0.015 · a 1-hour podcast ≈ $0.039*

***

### Usage

#### Apify Console

1. Open the actor and click **Add item** under *YouTube videos*.
2. Paste a YouTube URL. Optionally pick **Format** (`mp3`), **Timeframe** (`1:30-2:45`) and **Audio Quality**.
3. Up to **10 videos** per run.
4. Hit **Run**. When it finishes, grab your files from the **Output ▸ Download** column or the `audioFiles` key-value store link.

#### API

```json
{
    "videos": [
        { "url": "https://www.youtube.com/watch?v=VIDEO_ID" },
        { "url": "https://www.youtube.com/watch?v=OTHER_ID",
          "format": "mp3",
          "timeframe": "1:30-2:45",
          "audioQuality": "low" }
    ]
}
```

Only `url` is required — empty fields fall back to the global defaults
(`Audio Quality`, `Format`, `Timeframe`).

***

### Input reference

| Field | Values | Default |
|---|---|---|
| `videos[].url` | YouTube URL or 11-char video id *(required)* | — |
| `videos[].format` | `mp3`, *(empty = original container)* | global |
| `videos[].timeframe` | `MM:SS-MM:SS` · `HH:MM:SS-HH:MM:SS` | global |
| `videos[].audioQuality` | `best` · `high` · `medium` · `low` · `aac` · `opus` | `best` |

Global settings act as defaults for every video that leaves a field empty.

***

### Output

Each run produces:

- **Dataset** — one item per video:
  `url`, `title`, `duration`, `ok`, `filename`, `downloadUrl`, `seconds`, `attempt`, `error`
- **Key-value store** — the audio files themselves (`webm`/`m4a`, or `.mp3`)
- `downloadUrl` is a permanent pre-signed link — anyone can open it in a browser,
  no Apify account needed.

The **Output** tab shows a ready-made table; the run's output links point to both stores.

***

### FAQ

**What if a video fails?** The engine already retried it through multiple connections. Anything still failing at the end is reported in the dataset with the exact error — and you are not charged.

**Is there a video limit?** 10 links per run. Need more? Chain runs via API.

**MP3 conversion?** Yes — set format to `mp3` globally or per video.

# Actor input Schema

## `videos` (type: `array`):

Add one item per video (max 10). Only URL is required — leave format/timeframe/quality empty to use the global settings below.

## `audioQuality` (type: `string`):

Global default. Audio bitrate preference. high/medium/low cap at ~192/128/64 kbps; aac/opus restrict container codec.

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

Global default. 'mp3' converts audio output. Leave empty to keep original container.

## `timeframe` (type: `string`):

Global default. Cut only a portion: MM:SS-MM:SS or HH:MM:SS-HH:MM:SS (e.g. 1:30-3:00). Empty = full.

## Actor input object example

```json
{
  "videos": [
    {
      "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    },
    {
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
  ],
  "audioQuality": "best"
}
```

# Actor output Schema

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

Per-video items with title, duration, status and download link.

## `audioFiles` (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 = {
    "videos": [
        {
            "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw"
        },
        {
            "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
        }
    ],
    "audioQuality": "best",
    "format": "",
    "timeframe": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("utils/youtube-link").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 = {
    "videos": [
        { "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw" },
        { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" },
    ],
    "audioQuality": "best",
    "format": "",
    "timeframe": "",
}

# Run the Actor and wait for it to finish
run = client.actor("utils/youtube-link").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 '{
  "videos": [
    {
      "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    },
    {
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
  ],
  "audioQuality": "best",
  "format": "",
  "timeframe": ""
}' |
apify call utils/youtube-link --silent --output-dataset

```

## MCP server setup

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

```

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/IHDsaLO64Wge9wSWx/builds/PYPLv1msKhybcQnYF/openapi.json
