# YouTube API Video/Short Downloader (`codsec/youtube-downloader-api`) Actor

Download YouTube videos/audio in high quality. 720p HD, 1080p FullHD, 4k,

- **URL**: https://apify.com/codsec/youtube-downloader-api.md
- **Developed by:** [MrWhite](https://apify.com/codsec) (community)
- **Categories:** Social media, Videos, Integrations
- **Features:** Limited permissions
- **Stats:** 13 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## YouTube Downloader API — Apify Actor

Start a YouTube download (video or audio). Poll processing status until final links are ready.

### How it works

1. **`download`**: send a YouTube ID or URL and a format. Returns a `processing id`.
2. **`getVideo`**: query by `processingId`. When `status=completed`, read the `downloads` array.

No extra auth beyond your Apify token for Executions API calls.

***

### Input

| Field         | Type   | Required | Notes                                                                                 |
|---------------|--------|----------|---------------------------------------------------------------------------------------|
| `action`      | string | yes      | `"download"` or `"getVideo"`                                                          |
| `videoId`     | string | when `action=download` | YouTube ID or full URL (`watch?v=…`, `youtu.be/…`, `shorts/…`)             |
| `format`      | string | when `action=download` | One of `144,240,360,480,720,1080,1440,4k,mp3,wav,ogg,webm`                           |
| `processingId`| string | when `action=getVideo` | ID returned by `download`                                                             |

Examples the actor accepts:

- `https://www.youtube.com/watch?v=XZK9aQiAN1Y`
- `https://youtu.be/XZK9aQiAN1Y`
- `https://www.youtube.com/shorts/XZK9aQiAN1Y`
- `XZK9aQiAN1Y`

***

### Output

**Success (`download`)**

````json
{
  "success": true,
  "id": "cxbmlzn0zzU5s6pkBnK2asR",
  "title": "Matte Black Sheepey Twin Turbo Audi R8 hits Downtown",
  "thumbnail": "https://i.ytimg.com/vi/XZK9aQiAN1Y/hqdefault.jpg"
}



# Actor input Schema

## `action` (type: `string`):

Choose the operation: start a download or check processing status.
## `videoId` (type: `string`):

YouTube video ID or full URL (watch?v=, youtu.be, shorts).
## `format` (type: `string`):

Output format. Video: 144–4k. Audio: mp3, wav, ogg, webm.
## `processingId` (type: `string`):

ID returned by the download to check processing status.

## Actor input object example

```json
{
  "action": "download",
  "videoId": "https://www.youtube.com/shorts/RkPlWBV3gU0",
  "format": "720",
  "processingId": "vOaXwv8Gsb5B3mt3YnFYUa5"
}
````

# 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 = {
    "videoId": "https://www.youtube.com/shorts/RkPlWBV3gU0",
    "processingId": "vOaXwv8Gsb5B3mt3YnFYUa5"
};

// Run the Actor and wait for it to finish
const run = await client.actor("codsec/youtube-downloader-api").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 = {
    "videoId": "https://www.youtube.com/shorts/RkPlWBV3gU0",
    "processingId": "vOaXwv8Gsb5B3mt3YnFYUa5",
}

# Run the Actor and wait for it to finish
run = client.actor("codsec/youtube-downloader-api").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 '{
  "videoId": "https://www.youtube.com/shorts/RkPlWBV3gU0",
  "processingId": "vOaXwv8Gsb5B3mt3YnFYUa5"
}' |
apify call codsec/youtube-downloader-api --silent --output-dataset

```

## MCP server setup

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

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/iJoInp9W9blqdh3AK/builds/m1rTMV9eZhhe8n1gr/openapi.json
