# YouTube to MP3 & M4A Audio Downloader (`ttechx/youtube-to-mp3-downloader`) Actor

Turn YouTube videos, Shorts and music into MP3 (128-320 kbps) or M4A with title, artist and cover art. Cut any part, convert up to 1,000 links per run, get direct download links. Pay per minute of audio; failures are free.

- **URL**: https://apify.com/ttechx/youtube-to-mp3-downloader.md
- **Developed by:** [TTech](https://apify.com/ttechx) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 audio minutes

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/actors/running/actors-in-store.md#pay-per-event

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

### What is YouTube to MP3 & M4A Audio Downloader?

YouTube to MP3 & M4A Audio Downloader turns **YouTube videos, Shorts and YouTube Music tracks into MP3 or
M4A files**. Paste links, click **Start**, and get a **direct download link** for every file,
with the **title, artist and cover art** already in it.

No software to install, no browser extension, no ads. Convert one song or a thousand in one run,
or call it from your own code, Make, Zapier or n8n. You pay only per minute of audio you get;
anything that fails is free.

To try it, open the Actor, keep the example link and click **Start**.

### Features

- **MP3 at 128, 192 or 320 kbps**, or **M4A** (YouTube's own AAC audio, not re-encoded, so
  nothing is lost; the rare video without it is encoded to AAC at 128 kbps).
- **Tagged files.** Each file carries the song's title, the artist and the video thumbnail as
  cover art, so it shows up properly in music players.
- **Direct download links.** Every result has a link that works from any device or server for 6
  hours. Optionally, the files are also saved in the run's storage.
- **Fast and reliable.** Songs are usually ready in 15 to 40 seconds, many in under a second if
  someone converted them recently. If YouTube refuses one route, the Actor tries another by itself.
- **Cut any part.** Keep only, say, minutes 10:00 to 16:00 of a podcast, and pay only for those
  6 minutes.
- **Bulk conversion.** Up to 1,000 links per run, 16 converted at once. Repeated links are
  converted once.
- **Videos up to 3 hours.** Longer ones are skipped, free.
- **Fair billing.** Per started minute of audio. Private, deleted or live videos, videos over 3
  hours, and links that are not videos, cost nothing.

### How to convert YouTube to MP3

1. Paste one or more YouTube links (or video ids) into **YouTube links**, one per line.
2. Choose **MP3** or **M4A**, and for MP3 the bitrate. 192 kbps is the sweet spot.
3. To keep only a part, fill in **Start at** and **End at** (for example `10:00` and `16:00`).
4. Click **Start**. Each file appears in the **Output** tab as soon as it is ready.
5. Click a **Download** link, or export the list as JSON, CSV or Excel.

Accepted links: `youtube.com/watch?v=…`, `youtu.be/…`, `youtube.com/shorts/…`,
`youtube.com/live/…` (after the stream has ended), `music.youtube.com/watch?v=…`, or the bare
11-character video id. Channel and playlist links are not supported yet.

### Input

| Field | What it does | Default |
|---|---|---|
| **YouTube links** | Videos to convert, one per line (up to 1,000 per run) | required |
| **Format** | `mp3` or `m4a` | `mp3` |
| **MP3 bitrate** | 128, 192 or 320 kbps (MP3 only; the price is the same) | 192 |
| **Start at** | Keep the audio from this point: `10:00`, `1:02:03` or seconds (`600`). Applies to every link | the beginning |
| **End at** | Keep the audio up to this point | the end |
| **Also save the files in the run's storage** | Keep a copy of each file (up to 50 MB) in the run's key-value store | off |

```json
{
    "urls": ["https://www.youtube.com/watch?v=K4DyBUG242c", "https://youtu.be/3nQNiWdeH2Q"],
    "format": "mp3",
    "bitrate": "192"
}
```

### Output

One item per link, in the dataset (the **Output** tab):

```json
{
    "url": "https://www.youtube.com/watch?v=K4DyBUG242c",
    "videoId": "K4DyBUG242c",
    "status": "ok",
    "title": "Cartoon, Jéja - On & On (feat. Daniel Levi) | Electronic Pop | NCS - Copyright Free Music",
    "artist": "NoCopyrightSounds",
    "durationSeconds": 208,
    "billedMinutes": 0,
    "format": "mp3",
    "bitrate": 192,
    "fileSizeBytes": 5012909,
    "downloadUrl": "https://…/dl/pinned/K4DyBUG242c/192k.mp3?exp=…&sig=…",
    "downloadUrlExpiresAt": "2026-11-21T03:00:00.000Z",
    "storedFileUrl": null,
    "thumbnailUrl": "https://i.ytimg.com/vi/K4DyBUG242c/hqdefault.jpg",
    "errorCode": null,
    "error": null
}
```

`durationSeconds` and `billedMinutes` are those of the file you get (of the cut, when you cut).
The example video above (the input's prefill) is free in every format when not cut, so it
shows `billedMinutes` 0; every other video is billed by its minutes.

A link that could not be converted has `"status": "failed"`, an `errorCode` and a readable
`error`, and is not charged:

| `errorCode` | Meaning |
|---|---|
| `PRIVATE`, `UNAVAILABLE`, `MEMBERS_ONLY`, `AGE_RESTRICTED`, `RESTRICTED` | YouTube does not show the video to the public |
| `LIVE` | A live stream or premiere that has not ended |
| `TOO_LONG` | Longer than 3 hours (not supported) |
| `REGION` | Blocked in the countries we convert from |
| `BAD_INPUT` | Not a YouTube video link or id, or **Start at** is past the end of the video |
| `REFUSED`, `EXTRACT`, `DOWNLOAD`, `TIMEOUT`, `UNAVAILABLE_SERVICE`, `INTERNAL` | Temporary; run the link again later |

The download link works for 6 hours from any device. To get a fresh link later, run the same
video again: within 7 days of the last conversion it is answered from cache in about a second.

### How much does it cost?

You pay per **started minute of audio** delivered, whatever the format or bitrate.

| Event | Price |
|---|---|
| Minute of audio (`audio-minute`) | $0.0005 |
| File saved in the run's storage (`file-saved`, only with the option on) | $0.001 |

| Example | Cost |
|---|---|
| One 4-minute song | $0.002 |
| 1,000 songs of about 4 minutes | about $2 |
| A 1-hour podcast | $0.03 |
| Minutes 10:00 to 16:00 of a 30-minute video | $0.003 |
| A private, deleted or too-long video | free |

Set a **maximum charge per run** in the run options; the Actor stops cleanly when it is reached.
On Apify's Free plan the Actor converts 25 files a month; any paid Apify plan has no limit.

### Use it from code

Start a run and get the results in one call with the Apify API:

```bash
curl -X POST "https://api.apify.com/v2/acts/ttechx~youtube-to-mp3-downloader/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://www.youtube.com/watch?v=K4DyBUG242c"], "format": "mp3", "bitrate": "192"}'
```

The same works from the Apify Python and JavaScript clients, and from the Apify apps for Make,
Zapier and n8n. Typical uses: podcast and lecture audio for offline listening, audio for
transcription and AI pipelines, music libraries for apps, and voice-over or sample collection
from your own channel.

### FAQ

**Is it legal to download audio from YouTube?**
Only download content you own or have permission to use, such as your own uploads, Creative
Commons works or material whose owner allows it. YouTube's Terms of Service and copyright law
apply to how you use the files; you are responsible for that use.

**Why 192 kbps and not 320?**
YouTube streams audio at about 130 kbps. 192 kbps MP3 keeps all of it; 320 kbps only makes the
file larger. For the best quality at the smallest size, choose M4A.

**How long are files kept?**
The download link works for 6 hours. Our copy is kept for 7 days, so asking for the same video
again within that time is instant. With **Also save the files** on, a copy also stays in the
run's storage for as long as Apify keeps it.

**What about long videos?**
Videos up to 3 hours are converted; longer ones are skipped for free. To get part of a long
video, use **Start at** and **End at**.

**Something failed or looks wrong?**
Temporary failures are free; run the link again a little later. For anything else, open an issue
in the **Issues** tab or write to [@ttech_support_official](https://t.me/ttech_support_official)
on Telegram.

# Actor input Schema

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

Videos, Shorts or YouTube Music tracks: links (youtube.com/watch?v=…, youtu.be/…, /shorts/…, music.youtube.com/…) or 11-character video ids. One per line. Up to 1,000 per run; repeats are converted once.

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

MP3 plays everywhere. M4A is YouTube's own AAC audio, not re-encoded: the best quality for its size.

## `bitrate` (type: `string`):

For MP3 only. YouTube's audio is about 130 kbps, so 192 keeps all of it; 320 makes bigger files without better sound. The price does not depend on the bitrate.

## `start` (type: `string`):

Cut: keep the audio from this point, like 10:00, 1:02:03 or 600 (seconds). Applies to every link. Leave empty to start at the beginning. You pay only for the minutes you keep.

## `end` (type: `string`):

Cut: keep the audio up to this point, like 16:00. Leave empty to keep it to the end.

## `saveToKeyValueStore` (type: `boolean`):

Every result has a download link that works for 6 hours. Turn this on to also keep each file (up to 50 MB) in the run's key-value store, for as long as Apify keeps the run's storage. Charged per saved file.

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=K4DyBUG242c"
  ],
  "format": "mp3",
  "bitrate": "192",
  "saveToKeyValueStore": false
}
```

# Actor output Schema

## `files` (type: `string`):

Every video with its download link, title, length and size, or its error.

## `storedFiles` (type: `string`):

The files saved in the run's key-value store (only with 'Also save the files' on).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

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

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://www.youtube.com/watch?v=K4DyBUG242c"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ttechx/youtube-to-mp3-downloader").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://www.youtube.com/watch?v=K4DyBUG242c"] }

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

```

## MCP server setup

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

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/UX3RJvUSOrCUKLNlo/builds/WQuI4IPDuJhEaCIju/openapi.json
