HuntAPI
Guías prácticas

Extract Audio from a Video

Download only the audio track from any video URL as an MP3 file using HuntAPI — ideal for podcast archiving, transcription pipelines, or content repurposing.

Overview

By passing quality: "audio" to the HuntAPI downloader, you get an MP3 extract instead of the full video. This playbook builds a complete audio extraction pipeline including job submission, polling, and saving.

Prerequisites

  • A HuntAPI key — get one at app.huntapi.com
  • Install dependencies for your language:
pip install requests

Steps

Submit an audio extraction job

Use the same /v1/video/download endpoint with quality=audio.

import requests

API_KEY   = "YOUR_API_KEY"
VIDEO_URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

response = requests.get(
    "https://api.huntapi.com/v1/video/download",
    headers={"x-api-key": API_KEY},
    params={"url": VIDEO_URL, "quality": "audio"},
)
data   = response.json()
job_id = data["job_id"]
print(f"Audio job submitted: {job_id}")

Poll for completion

Check the job status every 5 seconds until status == "done".

import time

def wait_for_job(job_id: str) -> dict:
    for _ in range(60):
        r      = requests.get(f"https://api.huntapi.com/v1/job/{job_id}",
            headers={"x-api-key": API_KEY})
        result = r.json()
        status = result["status"]
        print(f"  [{status}]")
        if status == "done":
            return result
        if status == "error":
            raise RuntimeError(result.get("error", "Unknown error"))
        time.sleep(5)
    raise TimeoutError("Job timed out")

result       = wait_for_job(job_id)
download_url = result["download_url"]

Save the audio file

Download the MP3 and save it to disk.

output_file = "audio.mp3"
with requests.get(download_url, stream=True) as r:
    r.raise_for_status()
    with open(output_file, "wb") as f:
        for chunk in r.iter_content(chunk_size=8192):
            f.write(chunk)

print(f"Audio saved to {output_file} ({os.path.getsize(output_file) // 1024} KB)")

The extracted audio is delivered as an MP3. You can pipe it directly to a transcription service (e.g. OpenAI Whisper or Deepgram) for automatic subtitling or search indexing.

En esta página