# Youtube Video Downloader (`leadsbrary/youtube-video-downloader`) Actor

This is the cheapest YouTube downloader on the Store. Videos, Shorts, playlists, channels — 360p to 4K or MP3, billed per minute with no hidden fees. Same quality, lower price, every time.

- **URL**: https://apify.com/leadsbrary/youtube-video-downloader.md
- **Developed by:** [Alexandre Manguis](https://apify.com/leadsbrary) (community)
- **Categories:** Automation, Videos, Integrations
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event + usage

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

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.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/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

## YouTube Video Downloader (yt-dlp)

Download YouTube **videos, Shorts, playlists, channels and search results** as **MP4** (360p up to 4K) or **MP3** audio. Built on the battle-tested open-source [yt-dlp](https://github.com/yt-dlp/yt-dlp) engine with ffmpeg merging, running on the official Apify Python SDK.

Every downloaded file is stored in the run's **key-value store** and a direct download link is pushed to the **dataset** together with the video metadata.

### Features

- ✅ Single videos, Shorts, playlists, channels and plain-text **search terms**
- ✅ Quality selection: 360p → 4K (2160p), or **audio-only MP3** (192 kbps)
- ✅ Automatic merging of video + audio streams into a single MP4 (ffmpeg)
- ✅ Proxy support (Apify Proxy or custom proxies) with per-video IP rotation
- ✅ Optional cookies support for age-restricted / members-only videos
- ✅ Direct download links in the dataset — easy to consume via API or integrations
- ✅ File-size guard so runs never blow up on multi-GB videos

### Input example

```json
{
    "startUrls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        "https://www.youtube.com/playlist?list=PLxxxxxx",
        "lofi hip hop"
    ],
    "quality": "720p",
    "maxItems": 10,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": ["RESIDENTIAL"]
    }
}
````

### Output example (dataset item)

```json
{
    "videoId": "dQw4w9WgXcQ",
    "title": "Rick Astley - Never Gonna Give You Up",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "channel": "Rick Astley",
    "durationSeconds": 213,
    "viewCount": 1614038703,
    "uploadDate": "20091025",
    "resolution": "1280x720",
    "ext": "mp4",
    "fileSizeMb": 17.35,
    "downloadUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/dQw4w9WgXcQ.mp4",
    "thumbnail": "https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg",
    "billedMinutes": 4,
    "status": "SUCCESS"
}
```

### Pricing

Pay-per-event: billed **per minute of video actually delivered** (rounded up, 1-minute minimum), based on the resolution actually downloaded — not the resolution requested. Failed downloads are never charged.

| Quality | Price |
|---|---|
| 4K (2160p) | $0.058 / min |
| 1440p | $0.048 / min |
| 1080p | $0.024 / min |
| 720p | $0.016 / min |
| 480p | $0.012 / min |
| 360p | $0.007 / min |
| Audio (MP3) | $0.008 / min |

No flat per-run fee, no data-transfer surcharge. Requires a paid Apify plan — Free-plan runs are rejected.

### Proxies — read this

YouTube aggressively blocks datacenter IPs with the *"Sign in to confirm you're not a bot"* challenge. For reliable operation:

1. **Use RESIDENTIAL proxies** (Apify Proxy `RESIDENTIAL` group, or a custom provider such as Decodo, IPRoyal, Webshare or Bright Data via custom proxy URLs).
2. Optionally add **cookies** from a logged-in browser session (Netscape `cookies.txt` format) — this dramatically reduces bot-detection blocks and unlocks age-restricted content.

Note that the **whole media stream is downloaded through the proxy** (YouTube binds stream URLs to the requesting IP), so residential bandwidth usage roughly equals the size of the downloaded files. For large volumes, prefer lower resolutions or audio-only.

### Memory & limits

Downloaded files are buffered in memory when uploaded to the key-value store. Allocate at least **2× the expected max file size** of RAM to the run (e.g. 4096 MB for files up to ~2 GB), or lower `maxFileSizeMb`.

### Maintenance

YouTube changes its internals frequently; yt-dlp ships fixes within days. **Rebuild this Actor regularly** (Console → Builds → Start build) so the latest yt-dlp release is installed.

### Legal notice

Only download content you own, that is in the public domain / Creative Commons, or that you are otherwise authorized to download. Downloading may violate YouTube's Terms of Service. You are solely responsible for how you use this Actor.

***

### Keywords

**Keywords:** youtube downloader · download youtube video · youtube to mp4 · youtube to mp3 · youtube video downloader · youtube shorts downloader · youtube playlist downloader · youtube channel downloader · yt-dlp actor · download youtube 4k · download youtube audio · mp3 converter youtube · bulk youtube downloader · youtube video scraper · apify youtube downloader · youtube downloader api · save youtube video · youtube video to mp4 converter · download youtube search results · offline youtube downloader · HD video downloader · download youtube playlist mp3 · youtube video extractor · youtube mp3 converter online · scrape youtube videos · youtube video automation

\#YouTube #YouTubeDownloader #VideoDownloader #ytdlp #MP3 #MP4 #Apify #WebScraping #YouTubeShorts #YouTubePlaylist #VideoDownload #YouTubeToMP3

# Actor input Schema

## `startUrls` (type: `array`):

YouTube video URLs, Shorts URLs, playlist URLs, channel URLs — or plain text search terms (e.g. <code>lofi hip hop</code>). Playlists, channels and searches are expanded up to <b>Max items</b> videos each.

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

Target quality. The best available format at or below the selected resolution is downloaded. <b>Audio only (MP3)</b> extracts audio and converts it to MP3 192 kbps.

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

Maximum number of videos to download from each playlist, channel or search term. Single video URLs are not affected.

## `maxFileSizeMb` (type: `integer`):

Skip files larger than this size. Keep it below the memory allocated to the run (the file is buffered in memory during upload to the key-value store).

## `cookies` (type: `string`):

Optional. Paste the content of a <code>cookies.txt</code> file (Netscape format, exported from your browser with an extension such as <i>Get cookies.txt LOCALLY</i>). Needed for age-restricted / members-only videos and greatly reduces bot-detection blocks.

## `proxyConfiguration` (type: `object`):

Proxies to use. YouTube aggressively blocks datacenter IPs ("Sign in to confirm you're not a bot"), so <b>RESIDENTIAL proxies are strongly recommended</b> for reliable operation.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "quality": "720p",
  "maxItems": 10,
  "maxFileSizeMb": 2048,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

Dataset containing one item per downloaded video or audio file (title, channel, duration, resolution, file size, billed minutes, and direct download URL).

# 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 = {
    "startUrls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("leadsbrary/youtube-video-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 = {
    "startUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("leadsbrary/youtube-video-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 '{
  "startUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call leadsbrary/youtube-video-downloader --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Youtube Video Downloader",
        "description": "This is the cheapest YouTube downloader on the Store. Videos, Shorts, playlists, channels — 360p to 4K or MP3, billed per minute with no hidden fees. Same quality, lower price, every time.",
        "version": "0.1",
        "x-build-id": "ITonCruct2vNIKoFU"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/leadsbrary~youtube-video-downloader/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-leadsbrary-youtube-video-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/leadsbrary~youtube-video-downloader/runs": {
            "post": {
                "operationId": "runs-sync-leadsbrary-youtube-video-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/leadsbrary~youtube-video-downloader/run-sync": {
            "post": {
                "operationId": "run-sync-leadsbrary-youtube-video-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": [
                    "startUrls"
                ],
                "properties": {
                    "startUrls": {
                        "title": "Video / playlist / channel URLs or search terms",
                        "type": "array",
                        "description": "YouTube video URLs, Shorts URLs, playlist URLs, channel URLs — or plain text search terms (e.g. <code>lofi hip hop</code>). Playlists, channels and searches are expanded up to <b>Max items</b> videos each.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "quality": {
                        "title": "Quality",
                        "enum": [
                            "best",
                            "2160p",
                            "1440p",
                            "1080p",
                            "720p",
                            "480p",
                            "360p",
                            "audio"
                        ],
                        "type": "string",
                        "description": "Target quality. The best available format at or below the selected resolution is downloaded. <b>Audio only (MP3)</b> extracts audio and converts it to MP3 192 kbps.",
                        "default": "720p"
                    },
                    "maxItems": {
                        "title": "Max items per playlist / channel / search",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Maximum number of videos to download from each playlist, channel or search term. Single video URLs are not affected.",
                        "default": 10
                    },
                    "maxFileSizeMb": {
                        "title": "Max file size (MB)",
                        "minimum": 10,
                        "type": "integer",
                        "description": "Skip files larger than this size. Keep it below the memory allocated to the run (the file is buffered in memory during upload to the key-value store).",
                        "default": 2048
                    },
                    "cookies": {
                        "title": "Cookies (Netscape format)",
                        "type": "string",
                        "description": "Optional. Paste the content of a <code>cookies.txt</code> file (Netscape format, exported from your browser with an extension such as <i>Get cookies.txt LOCALLY</i>). Needed for age-restricted / members-only videos and greatly reduces bot-detection blocks."
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Proxies to use. YouTube aggressively blocks datacenter IPs (\"Sign in to confirm you're not a bot\"), so <b>RESIDENTIAL proxies are strongly recommended</b> for reliable operation."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
