Download MP3s from YouTube with Python
Use YouTube Video Downloader to download MP3s from YouTube with Python. Want to add YouTube audio downloads to your own Python project? Just pass your video URLs to the Actor with the Apify API client and get MP3 files back in bulk.

Sign up on Apify01
Create a free Apify account (no credit card needed) and find YouTube Video Downloader in Apify Store.
Initialize the API using your token02
Once you have an account, add your API token. You’ll find it on the Integrations page in Apify Console.
Define input and copy it in JSON03
Open YouTube Video Downloader in Apify Console, add the YouTube video URLs you want as MP3s, and set the format to MP3. Then copy the input as JSON from the Input tab and paste it into your code.
Integrate Apify into your codebase04
Call YouTube Video Downloader from your Python project with the Apify Python client or the API endpoints. Run the sample code below and your MP3 files land in Apify Storage, or in your own S3, Google Cloud Storage, or Azure bucket ↓.
Monitor your YouTube Video Downloader runs05
Open your Apify Console dashboard and watch YouTube Video Downloader runs execute in real time. You can also download the run logs, set up schedules so runs repeat on their own, and use webhooks to trigger the next step in your pipeline as soon as a download finishes.
Get your Python project up and running
Start your Python project by executing this code snippet in your go-to environment.
1from apify_client import ApifyClient2
3# Initialize the ApifyClient with your Apify API token4# Replace '<YOUR_API_TOKEN>' with your token.5client = ApifyClient("<YOUR_API_TOKEN>")6
7# Prepare the Actor input8run_input = { "videos": [{ "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }] }9
10# Run the Actor and wait for it to finish11run = client.actor("streamers/youtube-video-downloader").call(run_input=run_input)12
13# Fetch and print Actor results from the run's dataset (if there are any)14print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")15for item in client.dataset(run.default_dataset_id).iterate_items():16 print(item)17
18# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-startEnjoy $5 of free platform usage every month to explore and kickstart your projects.
Get started on Apify instantly without the hassle of entering your credit card information.
Join our Discord community to ask questions, share ideas, and connect with developers.
Ready to start downloading YouTube MP3s?
You just need a free Apify account
You give YouTube Video Downloader a list of YouTube video URLs and pick an output format. It fetches each video, extracts the audio track, converts it to MP3 or another format you choose, and saves the file to Apify Storage or your own cloud storage bucket. You can start all of that from Python with the Apify API client.
Yes. Every Actor on Apify has a REST API, and the Apify Python client wraps it. Pass your video URLs as input, start the run, then read the output from the run's dataset or key-value store. The sample code above is a working starting point.
MP3 is the usual choice, and you can also pick AAC, FLAC, M4A, OGG, OPUS, or WAV. Video formats are available too - MP4, AVI, MKV, MOV, and WebM - with quality settings from 144p up to 2160p.
Yes, web scraping is legal for gathering public information from websites. But be careful with personal or confidential data, as well as intellectual property, because laws and regulations might protect them. It's good practice to check the website's rules or terms of service to know what's allowed. If you're not sure, getting legal advice can help ensure you're using web scraping correctly and within the law.
Actors are serverless cloud programs that run on the Apify platform and do computing jobs. They’re called Actors because, like human actors, they perform actions based on a script. They can perform anything from simple actions (such as filling out a web form or sending an email) to complex operations (such as crawling an entire website or removing duplicates from a large dataset). Actor runs can be as short or as long as necessary. They could last seconds, hours, or even run infinitely.