Download Your First Video
Submit a video URL, poll for the async job result, and save the file locally — complete end-to-end walkthrough with the HuntAPI video downloader.
Overview
HuntAPI uses an asynchronous job model: you submit a URL, receive a job_id, then poll until the video is ready. This playbook walks through all three steps and downloads the finished file to disk.
Prerequisites
- A HuntAPI key — get one at app.huntapi.com
- Install dependencies for your language:
pip install requestsSteps
Submit the download job
Call GET /v1/video/download with the url parameter. The response immediately returns a job_id.
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": "best"},
)
data = response.json()
job_id = data["job_id"]
print(f"Job submitted: {job_id}")Poll until the video is ready
Check GET /v1/job/{job_id} every few seconds. When status becomes "done", the download_url field contains the file URL.
import time
def wait_for_job(job_id: str, poll_interval: int = 5, timeout: int = 300) -> dict:
start = time.time()
while time.time() - start < timeout:
r = requests.get(f"https://api.huntapi.com/v1/job/{job_id}",
headers={"x-api-key": API_KEY})
result = r.json()
status = result.get("status")
print(f" Status: {status}")
if status == "done":
return result
if status == "error":
raise RuntimeError(f"Job failed: {result.get('error')}")
time.sleep(poll_interval)
raise TimeoutError("Job did not complete within the timeout period.")
result = wait_for_job(job_id)
download_url = result["download_url"]
print(f"Ready! Download URL: {download_url}")Download the video file to disk
Stream the file from the download_url and save it locally.
filename = "video.mp4"
with requests.get(download_url, stream=True) as r:
r.raise_for_status()
with open(filename, "wb") as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
print(f"Saved to {filename}")You can pass quality: "best", "1080p", "720p", or "audio" in the initial request to control the output format before the job is submitted.
Model Context Protocol
Verbinden Sie HuntAPI mit Claude Code, Cursor, Gemini CLI, OpenAI Developer Mode und anderen MCP-Clients über Ihren API-Schlüssel.
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.