YouTube to MP3 API: Extract Audio as MP3, M4A, FLAC or WAV

6 min read Summarize with Claude ChatGPT Gemini Perplexity
YouTube to MP3 API: Extract Audio as MP3, M4A, FLAC or WAV

The request

JSON
{
  "url": "https://www.youtube.com/watch?v=VIDEO_ID",
  "audio_only": true,
  "audio_format": "mp3"
}

If you set audio_only without a format, you get MP3. The finished job reports "type": "audio" along with the link and size. audio_format is only accepted together with audio_only, and the API returns a 400 error if you send it on a video request.

Which format to choose

FormatWhat you getBest for
originalYouTube's own audio stream, usually Opus or AAC, with no re-encodingTranscription, archives, anything where quality matters
m4aAAC in an M4A fileApple devices, podcasts, small files
opusOpus, the codec YouTube uses for most of its best audioSmall files at good quality, web playback
mp3MP3Plays everywhere. The safe default
wavUncompressed PCMEditing software that prefers WAV
flacLossless compression of the decoded audioWorkflows that require FLAC

One thing to know: YouTube only stores compressed audio. Converting it to WAV or FLAC preserves exactly what YouTube had, but can't restore what compression removed, and the files are several times larger. If you don't need a specific format, original gives the best quality at the smallest size.

For transcription and AI pipelines

Speech-to-text models such as Whisper accept MP3, M4A, Opus and WAV. Audio is a fraction of the size of the video, so it's faster to download, cheaper to store, and quicker to upload to a transcription service. If the video already has captions, you may not need audio at all: request the subtitles instead, as shown in downloading YouTube subtitles by API.

Steadier volume with voice_boost

Some YouTube videos carry an extra audio track that YouTube processes for stable volume, so quiet speech and loud music sit closer together. Send "voice_boost": true to prefer that track when a video has one. It helps with talks, interviews and podcasts recorded at uneven levels.

The same thing with yt-dlp

bash
yt-dlp -x --audio-format mp3 --audio-quality 0 "https://www.youtube.com/watch?v=VIDEO_ID"

yt-dlp -f "ba" "https://www.youtube.com/watch?v=VIDEO_ID"

The first converts to the best-quality MP3 and needs ffmpeg. The second downloads the best original audio stream without converting it. At scale, the usual yt-dlp problems apply: bot checks and blocks on servers, covered in 403, 429 and IP bans.

Limits that apply to audio

  • Each audio file counts as one video toward your monthly quota.
  • max_audio_size_gb and max_duration_minutes can cap a request. They can't go above your plan's limits.
  • audio_only and video_only can't be combined.

FAQ

Is there an API to convert YouTube videos to MP3?

Yes. With the VideoDL API, send the video URL with "audio_only": true and "audio_format": "mp3". The finished job returns a link to the MP3 file.

What's the best audio format for transcribing YouTube videos?

The original stream (usually Opus or AAC) or MP3. Speech-to-text tools accept both, and they're far smaller than WAV. Converting to WAV or FLAC doesn't improve transcription.

Does converting YouTube audio to FLAC improve quality?

No. YouTube only stores compressed audio, so FLAC or WAV keeps exactly what YouTube had but can't restore detail. The files just get larger.

How do I download only the audio with yt-dlp?

Use yt-dlp -x --audio-format mp3 URL to convert to MP3, or yt-dlp -f ba URL to save the best original audio stream without converting it.

What does voice_boost do?

It prefers YouTube's stable-volume audio track when a video has one, which evens out quiet speech and loud sections. It's useful for talks and interviews.

Audio from YouTube, by API

MP3, M4A, Opus, FLAC, WAV or the original stream, delivered as a link or to your cloud. From $12/month.