# Best YouTube Video Downloader — Quality Selection, Cloud Save (`scrapeify/youtube-video-downloader`) Actor

Download YouTube videos and audio to Apify Key-Value Store. Quality selection: best, 720p, 1080p, 1440p, 4K, bestaudio, lowestaudio. yt-dlp with format negotiation. Returns Dataset manifest with videoId, title, file size, storageKey, billing. Supports YouTube Shorts.

- **URL**: https://apify.com/scrapeify/youtube-video-downloader.md
- **Developed by:** [Scrapeify](https://apify.com/scrapeify) (community)
- **Categories:** Videos, Social media, Agents
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $1,000.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

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

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

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

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

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

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


# README

## YouTube Video Downloader — Cloud Downloads with Quality Selection & Apify Storage

Download **YouTube videos and audio** directly to **Apify Key-Value Store** from a single URL. The Scrapeify YouTube Downloader wraps **yt-dlp** with Android/Web extractor arguments, Chrome-class User-Agent, optional proxy routing, and resilient info-JSON probes. Each run writes a Dataset record with video ID, title, file size, storage key, and an itemized billing breakdown — giving your automation pipeline a machine-readable manifest to retrieve the binary from cloud storage.

Built for media archival, ML preprocessing pipelines, automated transcription workflows, and any automation where you need video or audio objects in cloud storage rather than just links.

---

### Features

| Capability | Detail |
|---|---|
| **URL validation** | Accepts `youtube.com/watch`, `youtu.be`, YouTube Shorts, and common URL shapes |
| **Quality modes** | `best`, `highest`, `worst`, `lowest`, `bestaudio`, `highestaudio`, `worstaudio`, `lowestaudio`, `720p`, `1080p`, `1440p`, `2160p (4K)` |
| **Format negotiation** | yt-dlp handles merge logic — outputs mp4, webm, mkv, m4a, or mp3 depending on quality selection |
| **No playlist downloads** | `--no-playlist` enforced; processes single videos only |
| **Proxy support** | Pass-through to yt-dlp via `PROXY_URL` environment variable |
| **Binary in KV** | Content-type inferred from extension; stored in Apify Key-Value Store |
| **Machine-readable manifest** | Dataset row with `storageKey`, `fileSizeBytes`, `fileSizeGB`, `videoId`, `videoTitle` |
| **Billing breakdown** | Itemized `billing` object with per-event cost breakdown (illustrative rates) |
| **Dual code paths** | Proxy-aware `execPromise` path plus direct `getVideoInfo` probe for resilient info extraction |

---

### Use Cases

#### Automated Transcription Pipelines
Download audio tracks (`bestaudio`) and pass the KV storage URL to speech-to-text services (Whisper, AssemblyAI, Rev AI). The actor's `storageKey` gives your pipeline an unambiguous reference to the audio object in cloud storage.

#### AI & ML Preprocessing
Stage video clips before vision model analysis, multimodal LLM pipelines, or video classification training. Download at target resolution (`720p`, `1080p`) and trigger downstream processing jobs using the Dataset manifest.

#### Media Archival
Archive video content tied to URLs for compliance, research, or content preservation purposes — subject to rights clearance. The KV storage approach keeps artifacts alongside Apify run data.

#### RAG & Knowledge Pipelines
Chain: download audio → transcribe → chunk transcript → embed → index in vector database with `youtubeUrl` as citation metadata. The structured Dataset manifest provides the handoff point between the downloader and your transcription step.

#### Automated Demo & Content Workflows
Fetch specific video samples for product demos, training datasets, or content libraries. Orchestrate across multiple videos at the scheduler level using parallel Apify actor runs.

#### Creative Intelligence
Download competitor ad creatives or branded content from YouTube for frame-level analysis, competitive benchmarking, or brand safety review (rights permitting).

---

### Why Choose This Actor

- **Battle-tested extractor** — yt-dlp handles YouTube's format negotiation, codec selection, and stream merging
- **Cloud storage native** — artifacts land directly in Apify Key-Value Store where integrations expect binary objects
- **Manifest-driven** — `storageKey` + byte counts + `videoId` give downstream steps everything needed for retrieval and metering
- **Quality flexibility** — 12 quality modes from audio-only to 4K video with automatic fallback to closest available

---

### Quick Start

1. Open the Scrapeify **YouTube Downloader** on Apify Console.
2. Paste a **`youtubeUrl`** (e.g. `https://www.youtube.com/watch?v=dQw4w9WgXcQ`).
3. Select a **`quality`** from the dropdown (default: `best`).
4. After the run: open the **Dataset** for the download manifest.
5. Retrieve the binary from **Storage → Key-Value Store → `storageKey`**.

> **Tip:** Use `bestaudio` for transcription pipelines to avoid downloading unnecessary video streams. Use `1080p` or `720p` to cap storage costs for large batches.

---

### Input Schema

```json
{
  "youtubeUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "quality": "1080p"
}
````

| Field | Type | Default | Description |
|---|---|---|---|
| `youtubeUrl` | string | Demo URL | YouTube video URL. Supports `youtube.com/watch`, `youtu.be`, and Shorts. |
| `quality` | enum | `best` | Quality selector. See full options below. |

#### Quality Options

| Value | Description |
|---|---|
| `best` | Best available video + audio (auto-merge) |
| `highest` | Highest quality — alias for `best` |
| `worst` / `lowest` | Lowest quality for minimal storage |
| `bestaudio` / `highestaudio` | Best audio stream only — no video |
| `worstaudio` / `lowestaudio` | Lowest audio quality |
| `720p` | Cap at 720p height |
| `1080p` | Cap at 1080p height |
| `1440p` | Cap at 1440p height |
| `2160p` | 4K — largest files |

If requested quality is unavailable, yt-dlp falls back to the closest available option.

***

### Output Schema

#### Dataset Row (download manifest)

```json
{
  "success": true,
  "videoId": "dQw4w9WgXcQ",
  "videoTitle": "Rick Astley — Never Gonna Give You Up (Official Music Video)",
  "youtubeUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "requestedQuality": "1080p",
  "downloadedQuality": "1080p",
  "filePath": null,
  "fileSizeBytes": 125000000,
  "fileSizeGB": 0.1164,
  "storageKey": "video_dQw4w9WgXcQ_1715000000000",
  "storageSizeGB": 0.1164,
  "billing": {
    "events": [
      {
        "eventName": "actor_start",
        "eventType": "fixed",
        "description": "Cost per actor execution",
        "cost": 0.10,
        "quantity": 1,
        "unit": "event",
        "rate": 0.10,
        "rateUnit": "USD per event"
      },
      {
        "eventName": "download",
        "eventType": "usage",
        "description": "Cost per GB downloaded",
        "cost": 0.1164,
        "quantity": 0.1164,
        "unit": "GB",
        "rate": 1.00,
        "rateUnit": "USD per GB"
      },
      {
        "eventName": "storage",
        "eventType": "usage",
        "description": "Cost per GB in Apify Key-Value Store",
        "cost": 0.0582,
        "quantity": 0.1164,
        "unit": "GB",
        "rate": 0.50,
        "rateUnit": "USD per GB"
      }
    ],
    "totalCost": 0.2746,
    "costPerActorStart": 0.10,
    "costPerGBDownloaded": 1.00,
    "costPerGBStorage": 0.50,
    "dataDownloadedGB": 0.1164,
    "storageGB": 0.1164
  }
}
```

| Field | Type | Description |
|---|---|---|
| `success` | boolean | `true` if download and KV write completed |
| `videoId` | string | YouTube video ID extracted from URL |
| `videoTitle` | string | Video title from yt-dlp metadata |
| `requestedQuality` | string | Input quality parameter |
| `downloadedQuality` | string | Actual quality resolved by yt-dlp |
| `fileSizeBytes` | integer | Binary size in bytes |
| `fileSizeGB` | number | Binary size in GB (2 decimal places) |
| `storageKey` | string | Key-Value Store key for binary retrieval |
| `billing` | object | Itemized cost breakdown (illustrative rates — reconcile with Apify plan) |

**Binary retrieval:** `GET https://api.apify.com/v2/key-value-stores/{storeId}/records/{storageKey}?token={token}`

***

### API Examples

#### cURL

```bash
curl "https://api.apify.com/v2/acts/scrapeify~youtube-downloader/runs?token=$APIFY_TOKEN" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "youtubeUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "quality": "1080p"
  }'
```

#### Python

```python
import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])

run = client.actor("scrapeify/youtube-video-downloader").call(
    run_input={
        "youtubeUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        "quality": "1080p",
    }
)

## Get manifest from Dataset
items = client.dataset(run["defaultDatasetId"]).list_items().items
manifest = items[0]

if manifest["success"]:
    storage_key = manifest["storageKey"]
    store_id = run["defaultKeyValueStoreId"]
    print(f"Binary at: /key-value-stores/{store_id}/records/{storage_key}")
```

#### JavaScript / Node.js

```javascript
import { ApifyClient } from "apify-client";

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

const run = await client.actor("scrapeify/youtube-video-downloader").call({
  youtubeUrl: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  quality: "bestaudio",
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
const { storageKey, fileSizeBytes, success } = items[0];

if (success) {
  console.log(`Audio ready: ${storageKey} (${(fileSizeBytes / 1e6).toFixed(1)} MB)`);
}
```

***

### Integration Examples

#### Transcription Pipelines (Whisper / AssemblyAI)

```python
## 1. Download audio
run = client.actor("scrapeify/youtube-video-downloader").call(
    run_input={"youtubeUrl": url, "quality": "bestaudio"}
)
manifest = client.dataset(run["defaultDatasetId"]).list_items().items[0]

## 2. Retrieve binary from KV store
store_id = run["defaultKeyValueStoreId"]
audio = client.key_value_store(store_id).get_record(manifest["storageKey"])

## 3. Pass to speech-to-text service
transcript = whisper_client.transcribe(audio["value"])
```

#### n8n

HTTP node → trigger Apify run → poll run status → second HTTP node fetches KV binary via Apify API → pass to a transcription or storage node.

#### LangChain Tool

```python
from langchain.tools import tool

@tool
def download_youtube_audio(url: str) -> dict:
    """Download YouTube audio to Apify KV Store and return storage manifest."""
    run = client.actor("scrapeify/youtube-video-downloader").call(
        run_input={"youtubeUrl": url, "quality": "bestaudio"}
    )
    return client.dataset(run["defaultDatasetId"]).list_items().items[0]
```

#### CrewAI

A `MediaFetchAgent` downloads audio via this tool. A downstream `TranscriptionAgent` retrieves the binary using `storageKey` and processes it with Whisper. An `IndexingAgent` chunks and embeds the transcript for RAG retrieval.

#### Gemini File API

Download video with this actor → retrieve binary from KV store → upload to Gemini File API for multimodal analysis using the `storageKey` reference.

#### AutoGen Multi-Agent

```python
## UserProxyAgent passes URL list; DownloadAgent calls tool per URL;
## TranscriptAgent processes each manifest sequentially
```

#### RAG Knowledge Pipeline

Download → transcribe → chunk by sentence/paragraph → embed with `youtubeUrl` as citation metadata → index in Pinecone/Weaviate → enable semantic video search.

***

### Frequently Asked Questions

**1. Does this bypass YouTube Premium or DRM-protected content?**
No. The actor only downloads what yt-dlp can access without authentication — public, non-DRM-protected videos.

**2. What output formats are supported?**
yt-dlp selects the container format based on quality and merge logic. Typical outputs: mp4, webm, mkv for video; m4a, mp3 for audio.

**3. How do I retrieve the downloaded binary?**
Use the Apify API: `GET /v2/key-value-stores/{storeId}/records/{storageKey}`. The store ID is in `run.defaultKeyValueStoreId`.

**4. What is the maximum file size?**
Limited by Apify Key-Value Store item size limits. Use lower quality settings for long videos to stay within limits.

**5. Does it handle YouTube Shorts?**
Yes — Shorts URLs are supported when they validate as YouTube URLs.

**6. Can I download playlists?**
No — `--no-playlist` is enforced by design. Batch across multiple videos at the orchestration layer.

**7. How accurate is the `billing` breakdown?**
The `billing` block contains illustrative rates defined in the actor code. Reconcile actual charges with your Apify plan pricing.

**8. What causes `success: false` in the Dataset?**
Invalid URL, yt-dlp subprocess errors, network failures, or KV write failures. Check run logs for the specific error.

**9. How do I disable proxy routing?**
Clear or remove the `PROXY_URL` environment variable in the Actor settings.

**10. What yt-dlp client arguments are used?**
Android/Web extractor arguments with a Chrome-class User-Agent. This reduces bot detection errors compared to naive HTTP clients.

**11. How do I handle YouTube bot detection errors?**
Update the actor to the latest version (yt-dlp is updated regularly for extractor compatibility). Use a proxy via `PROXY_URL`. Check logs for the specific error code.

**12. Can I download audio-only for transcription?**
Yes — use `bestaudio` or `highestaudio` for the smallest file size suitable for speech-to-text.

**13. What happens with very long videos?**
Download time scales with video duration and quality. Very long videos at high quality may time out or produce large files.

**14. Are subtitles or captions included?**
Not in the primary output. Customize yt-dlp arguments in a fork if caption tracks are required.

**15. Does it support YouTube Music URLs?**
Primary support is for standard YouTube video URLs. YouTube Music URLs may or may not work — test before relying on production.

**16. Can I check file integrity after download?**
Compare `fileSizeBytes` against expected duration × bitrate as a rough sanity check. Detailed integrity checks require reading the binary.

**17. What happens to temporary files after the run?**
Temp directories are cleaned up after successful KV write. Check logs if cleanup warnings appear.

**18. How do I batch downloads across multiple videos?**
Launch parallel Apify actor runs at the orchestration layer — one video per run. Apify's actor orchestration handles concurrency.

**19. Is there a way to get video metadata without downloading?**
The info-JSON probe in the code path can surface metadata. For metadata-only workflows, omit the download step in a fork.

**20. What codecs are in the output container?**
Depends on yt-dlp merge logic for the requested quality. Common: H.264 in mp4, VP9 in webm, AAC or Opus for audio. Ensure player/processing tool codec compatibility.

**21. Can I trigger this from a webhook?**
Yes — use the Apify Runs API endpoint in any HTTP-capable webhook system (n8n, Zapier, Make, GitHub Actions).

**22. What does `downloadedQuality` mean vs `requestedQuality`?**
If the exact requested quality isn't available, yt-dlp falls back to the closest option. `downloadedQuality` reflects what was actually downloaded.

**23. Does the actor support private YouTube videos?**
No — only publicly accessible videos without authentication requirements.

**24. How do I clean up KV storage after processing?**
Delete records via Apify API after downstream processing is complete to manage storage costs.

**25. Is this suitable for high-volume batch transcription?**
Yes with orchestration. Launch parallel runs per video URL; collect manifest rows; trigger transcription pipeline per `storageKey`. Design for network and KV throughput limits.

***

### Best Practices

- **Choose quality for use case** — `bestaudio` for transcription; `720p` for general processing; `1080p` for visual analysis
- **Set region-appropriate proxies** when Google blocks egress from Apify's datacenter IPs
- **Poll run status** before reading KV — avoid race conditions in fast orchestrators
- **Clean up KV storage** after processing to manage costs on high-volume batch workflows
- **Parallelize at orchestration layer** — one video per Apify run, not one massive sequential pipeline
- **Validate `success: true`** before passing `storageKey` to downstream steps
- **Check `fileSizeGB`** in the manifest for cost estimation before scaling to large batches

***

### Performance & Scalability

| Factor | Guidance |
|---|---|
| **Throughput** | Network-bound; download speed depends on video size and egress bandwidth |
| **Parallelism** | Orchestrate parallel actor runs per URL — each run is independent |
| **Storage cost** | Monitor cumulative `fileSizeGB` across runs; clean up after processing |
| **Timeout** | Long videos at high quality may take several minutes — account for this in orchestrator timeouts |
| **Format negotiation** | yt-dlp merge adds latency for combined video+audio streams; audio-only is faster |

***

### AI & Automation Workflows

**Recommended chain for knowledge extraction:**

1. Download audio with `bestaudio` quality
2. Retrieve binary from KV store using `storageKey`
3. Transcribe with Whisper or AssemblyAI
4. Chunk transcript by sentence or paragraph
5. Embed chunks with `youtubeUrl` as citation metadata
6. Index in vector database
7. Enable semantic search and AI-generated answers with YouTube citations

**Multimodal pipeline:**

1. Download video at `720p`
2. Extract keyframes
3. Run vision model or multimodal LLM on frames
4. Combine with audio transcript for comprehensive video understanding

***

### Error Handling

| Scenario | Behavior |
|---|---|
| Invalid YouTube URL | Error thrown before download attempt |
| yt-dlp subprocess error | Logged; Dataset captures `success: false` with message |
| KV write failure | Logged; Dataset row reflects failure |
| Proxy unavailable | Falls back to direct egress if `PROXY_URL` is unset |
| Quality unavailable | yt-dlp falls back to closest available; `downloadedQuality` reflects actual |

***

### Trust & Reliability

Scrapeify maintains this actor wrapper around yt-dlp with sensible defaults for YouTube's extractor client requirements. The architecture focuses on:

- Resilient info-JSON probes for metadata extraction before download
- Proxy-aware dual code paths for format negotiation
- Explicit `success` flag and typed billing breakdown for autonomous pipeline operation
- Apify KV Store as the canonical binary artifact location

***

### Related Scrapeify Actors

Explore the full Scrapeify suite — chain these actors together for end-to-end automation pipelines:

| Actor | What it does |
|---|---|
| [Amazon Scraper](https://apify.com/scrapeify/amazon-scraper) | ASINs, prices, sponsored flags across 23 marketplaces |
| [Instagram Ad Library Scraper](https://apify.com/scrapeify/instagram-ad-library-scraper) | Instagram-only ads from Meta Ad Library |
| [Meta Ad Library Scraper](https://apify.com/scrapeify/meta-ad-library-scraper) | Facebook & Instagram ads with sort options |
| [WhatsApp Ad Scraper](https://apify.com/scrapeify/whatsapp-ad-scraper) | Click-to-WhatsApp ad creatives |
| [Meta Brand & Page ID Finder](https://apify.com/scrapeify/facebook-page-id-finder) | Resolve brand names to numeric Page IDs |
| [Google Maps Scraper](https://apify.com/scrapeify/google-maps-scraper) | Local business leads, reviews, emails, contacts |
| [Google News Scraper](https://apify.com/scrapeify/google-news-scraper) | Headlines, sources, article URLs (up to 2K) |

***

*YouTube is a trademark of Google LLC. This actor is not affiliated with or endorsed by Google or YouTube.*

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "SoftwareApplication",
      "name": "Scrapeify YouTube Video Downloader",
      "applicationCategory": "DeveloperApplication",
      "applicationSubCategory": "Media Processing API",
      "operatingSystem": "Cloud (Apify Platform)",
      "description": "Download YouTube videos and audio directly to Apify Key-Value Store. Supports quality selection (best, 720p, 1080p, 1440p, 4K, audio-only) via yt-dlp. Returns Dataset manifest with videoId, title, file size, storageKey, and itemized billing.",
      "url": "https://apify.com/scrapeify/youtube-video-downloader",
      "featureList": [
        "12 quality modes from audio-only to 4K",
        "yt-dlp format negotiation",
        "Cloud-native storage in Apify KV Store",
        "YouTube Shorts support",
        "Proxy-aware downloads",
        "Itemized billing breakdown"
      ],
      "offers": {
        "@type": "Offer",
        "category": "SaaS"
      },
      "publisher": {
        "@type": "Organization",
        "name": "Scrapeify"
      }
    },
    {
      "@type": "FAQPage",
      "mainEntity": [
        {
          "@type": "Question",
          "name": "Does this YouTube downloader bypass Premium or DRM-protected content?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "No. The actor only downloads what yt-dlp can access without authentication — public, non-DRM-protected videos."
          }
        },
        {
          "@type": "Question",
          "name": "What output formats are supported?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "yt-dlp selects the container format based on quality and merge logic. Typical outputs: mp4, webm, mkv for video; m4a, mp3 for audio."
          }
        },
        {
          "@type": "Question",
          "name": "How do I retrieve the downloaded binary?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "Use the Apify API: GET /v2/key-value-stores/{storeId}/records/{storageKey}. The store ID is in run.defaultKeyValueStoreId."
          }
        },
        {
          "@type": "Question",
          "name": "Does it handle YouTube Shorts?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "Yes — Shorts URLs are supported when they validate as YouTube URLs."
          }
        },
        {
          "@type": "Question",
          "name": "Can I download YouTube playlists?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "No. The --no-playlist flag is enforced by design. Batch across multiple videos at the orchestration layer."
          }
        },
        {
          "@type": "Question",
          "name": "Can I download audio-only for transcription?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "Yes. Use bestaudio or highestaudio quality for the smallest file size suitable for speech-to-text pipelines like Whisper or AssemblyAI."
          }
        }
      ]
    }
  ]
}
</script>

# Actor input Schema

## `youtubeUrl` (type: `string`):

The URL of the YouTube video to download. Default: https://www.youtube.com/shorts/xaEl5JttsNk

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

Desired video quality. Options: 'highest', 'lowest', 'highestvideo', 'lowestvideo', 'highestaudio', 'lowestaudio', or specific quality like '720p', '1080p', etc. If requested quality is not available, the closest available quality will be used.

## Actor input object example

```json
{
  "youtubeUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "quality": "best"
}
```

# 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("scrapeify/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 = {}

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Best YouTube Video Downloader — Quality Selection, Cloud Save",
        "description": "Download YouTube videos and audio to Apify Key-Value Store. Quality selection: best, 720p, 1080p, 1440p, 4K, bestaudio, lowestaudio. yt-dlp with format negotiation. Returns Dataset manifest with videoId, title, file size, storageKey, billing. Supports YouTube Shorts.",
        "version": "1.0",
        "x-build-id": "5vaHTOfn7PUvYEiFy"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scrapeify~youtube-video-downloader/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scrapeify-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/scrapeify~youtube-video-downloader/runs": {
            "post": {
                "operationId": "runs-sync-scrapeify-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/scrapeify~youtube-video-downloader/run-sync": {
            "post": {
                "operationId": "run-sync-scrapeify-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",
                "properties": {
                    "youtubeUrl": {
                        "title": "YouTube URL",
                        "type": "string",
                        "description": "The URL of the YouTube video to download. Default: https://www.youtube.com/shorts/xaEl5JttsNk",
                        "default": "https://www.youtube.com/shorts/xaEl5JttsNk"
                    },
                    "quality": {
                        "title": "Video Quality",
                        "enum": [
                            "best",
                            "highest",
                            "worst",
                            "lowest",
                            "bestaudio",
                            "highestaudio",
                            "worstaudio",
                            "lowestaudio",
                            "720p",
                            "1080p",
                            "1440p",
                            "2160p"
                        ],
                        "type": "string",
                        "description": "Desired video quality. Options: 'highest', 'lowest', 'highestvideo', 'lowestvideo', 'highestaudio', 'lowestaudio', or specific quality like '720p', '1080p', etc. If requested quality is not available, the closest available quality will be used.",
                        "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
