You need to programmatically fetch a downloadable link for a specific YouTube video or audio format and ship it this week. By the end of this article, you’ll make an authenticated request to retrieve a ready-to-use download task (with a progress link and thumbnail) using the YouTube Download and Info API on Zyla API Hub, wire it into your backend or automation, and invoke it from an AI agent via MCP.
What this API gives you
The YouTube Download and Info API exposes a single, focused endpoint that initializes a downloadable asset for a given YouTube URL in your chosen format. It supports regular YouTube videos (not live streams), and returns:
- A success flag indicating whether the request was accepted.
- An opaque id for the requested download.
- An image URL (the video’s thumbnail) you can display immediately in your UI.
- A progress_url to monitor the job’s progress outside of your app if needed.
Common uses include:
- Building an internal media downloader for compliance reviews or content QA.
- Adding “save to library” or “offline clip” features inside your product.
- Extracting audio tracks for transcription or analysis pipelines.
Everything runs through your Zyla account and a single API key. Zyla API Hub provides one account, one API key, and one subscription model for all APIs across the marketplace. You can browse more than 10,000 public APIs at zylalabs.com and integrate multiple services behind the same key.
Getting started on Zyla API Hub
To begin:
- Open the API’s listing on Zyla: Start 7-day trial on YouTube Download and Info API.
- Click Subscribe or Start Free Trial (when available) and obtain your API key.
- Use that key in the Authorization header on every request.
Billing is subscription + quota (not pay-per-call). For first-time use, this API offers a 7-day trial on its item page. Check the API page for current access options and pricing.
Endpoint overview and formats
The API currently provides a Download endpoint. You supply a YouTube video URL and a format, and it responds with a job identifier, thumbnail, and a progress link.
- Method: GET
- URL: https://zylalabs.com/api/11016/youtube-download-and-info-api/20761/download
- Parameters:
- url (string, required): the full YouTube watch URL (example provided below).
- format (string, required): one of the allowed video or audio formats below.
Available formats
Video formats:
- 360p
- 480p
- 720p
- 1080p
- 1440p
- 2160p
Audio formats:
- mp3
- m4a
- flac
- opus
- wav
Notes that matter in production:
- Audio download links expire after 2 hours. Incorporate this into your UX to avoid stale links.
- This endpoint supports downloading regular videos only (not live streams).
cURL request you can copy and run
Below is the official, copy-pasteable request using a YouTube URL and a 720p video format. Replace YOUR_API_KEY with your key from Zyla:
curl -s -X GET "https://zylalabs.com/api/11016/youtube-download-and-info-api/20761/download?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaGSKrC7dGcY&format=720" \
-H "Authorization: Bearer YOUR_API_KEY"
Sample JSON responses
This is the official example response. It includes a success flag, a stable id for this request, an image URL for the video thumbnail, and a progress URL you can use to check the job’s status:
{
"success": true,
"id": "2ec15939807689549d3f3115f168be6b9c868105",
"image": "https://i.ytimg.com/vi/aGSKrC7dGcY/hqdefault.jpg",
"progress_url": "https://youtube-api-progress-copy-development.up.railway.app/api/progress?id=2ec15939807689549d3f3115f168be6b9c868105"
}
Same structure you should expect for other valid requests (the values will differ at runtime):
{
"success": true,
"id": "2ec15939807689549d3f3115f168be6b9c868105",
"image": "https://i.ytimg.com/vi/aGSKrC7dGcY/hqdefault.jpg",
"progress_url": "https://youtube-api-progress-copy-development.up.railway.app/api/progress?id=2ec15939807689549d3f3115f168be6b9c868105"
}
Use this schema to wire your parsing logic. For example, show the image immediately in your UI while the download job starts, and persist the id to link your user’s action to the job:
{
"success": true,
"id": "2ec15939807689549d3f3115f168be6b9c868105",
"image": "https://i.ytimg.com/vi/aGSKrC7dGcY/hqdefault.jpg",
"progress_url": "https://youtube-api-progress-copy-development.up.railway.app/api/progress?id=2ec15939807689549d3f3115f168be6b9c868105"
}
Interpreting the response fields
- success: true means the request was accepted and a job was created.
- id: a unique identifier for the resulting job. Store it alongside your user action for traceability.
- image: a direct URL to the video’s thumbnail. Helpful for UI placeholders and queue views.
- progress_url: a link you can use externally to check processing progress. Use it to provide user-facing progress updates or internal monitoring. Audio downloads have time-sensitive links (expire after 2 hours), so coordinate user flows accordingly.
Python example: request and parse
The following Python snippet demonstrates how to call the Download endpoint, validate the response, and extract the fields you’ll actually use in your app. It matches the same request shown in the cURL example:
import os
import urllib.parse
import requests
API_KEY = os.environ.get("ZYLA_API_KEY", "YOUR_API_KEY")
BASE_URL = "https://zylalabs.com/api/11016/youtube-download-and-info-api/20761/download"
def request_download(youtube_url: str, fmt: str):
params = {
"url": youtube_url,
"format": fmt
}
headers = {
"Authorization": f"Bearer {API_KEY}"
}
# If your URL contains special characters, urlencode it when building manual URLs;
# requests will handle params dict correctly.
resp = requests.get(BASE_URL, params=params, headers=headers, timeout=30)
resp.raise_for_status()
data = resp.json()
# Minimal shape checks for robustness
if not isinstance(data, dict) or "success" not in data:
raise ValueError("Unexpected response shape")
if not data.get("success"):
# The API may return success=false for invalid inputs; handle gracefully.
# You can log data for diagnostics.
raise RuntimeError(f"Request not successful: {data}")
# Extract fields your app will use:
job_id = data.get("id")
thumbnail = data.get("image")
progress_link = data.get("progress_url")
return job_id, thumbnail, progress_link
if __name__ == "__main__":
video_url = "https://www.youtube.com/watch?v=aGSKrC7dGcY"
format_choice = "720" # Use any supported format: 360p, 480p, 720p, 1080p, 1440p, 2160p, mp3, m4a, flac, opus, wav
job_id, thumbnail, progress_link = request_download(video_url, format_choice)
print("Job ID:", job_id)
print("Thumbnail:", thumbnail)
print("Progress URL:", progress_link)
For reference, here’s the official JSON the code expects to parse:
{
"success": true,
"id": "2ec15939807689549d3f3115f168be6b9c868105",
"image": "https://i.ytimg.com/vi/aGSKrC7dGcY/hqdefault.jpg",
"progress_url": "https://youtube-api-progress-copy-development.up.railway.app/api/progress?id=2ec15939807689549d3f3115f168be6b9c868105"
}
Format selection and user experience tips
When building your UI or CLI, present only the formats your workflow can handle downstream. A few pragmatic guidelines:
- For quickest video previews, 360p or 480p are fine. For archiving or editing, 1080p and up.
- For audio-only transcription, m4a or wav are common choices. Remember: audio download links expire after 2 hours—make the final fetch promptly after you receive the job info.
- If the user selects a very high resolution (1440p/2160p), inform them that processing and file sizes will be larger.
- Display the image immediately from the image field to confirm the correct video before the download finishes.
Operational readiness: reliability, idempotency, and quotas
To ship this week without surprises:
- Tie the returned id to your own database row representing the user action (e.g., a “DownloadRequest” table). That gives you traceability.
- If you queue multiple requests for the same video/format pair, consider deduplicating by YouTube URL + format on your side before making a new API call.
- Handle non-200 HTTP responses by logging the response body and retrying only when appropriate. Don’t blindly loop retries.
- Remember the subscription + quota model on Zyla. Monitor your remaining quota from your Zyla dashboard and consider backpressure if you operate at scale.
- Because audio download links expire after 2 hours, either:
- Start the final file fetch immediately in your backend after you’ve prepared storage, or
- Prompt the user to download within the time window and provide a one-click refresh flow that re-invokes the API if needed.
Zyla unifies authentication and access across APIs, so you can add related tooling later without new keys. Explore more media services on zylalabs.com.
Real-world integration patterns
- Internal review queue: Create a small service that accepts a YouTube URL and target format. On submission, call the Download endpoint, store the id, and show the image right away. A background worker can periodically check the progress URL and notify the reviewer when the asset is ready.
- Podcast audio extraction: Offer mp3 or m4a as choices. Trigger the Download endpoint right after the user pastes a link; once the file is ready in your downstream flow, immediately send it to your transcription engine. Because of the 2-hour audio link window, daisy-chain these steps closely.
- Offline module in an LMS: For a course with embedded YouTube lessons, pre-request 480p or 720p versions. Store job ids and surface the image thumbnails in the lesson list while downloads complete in the background.
Calling the API from an AI agent via MCP
If you use an MCP-compatible client (e.g., Claude Code, Cursor, Windsurf), you can let the agent call Zyla APIs through the MCP gateway. Provide your Zyla API key in the MCP endpoint and instruct the agent to perform an authenticated GET to the Hub URL:
- MCP endpoint: MCP
- Pass your API key as: https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY
- Have the agent invoke:
- GET https://zylalabs.com/api/11016/youtube-download-and-info-api/20761/download
- Query params: url, format
- Header: Authorization: Bearer YOUR_API_KEY
In natural language, you can tell your agent: “Call the YouTube Download and Info API’s download endpoint with this YouTube URL and format 720, include Authorization: Bearer, and return the id, image, and progress_url.” The same shape as the official sample applies. Use the returned id to tag subsequent steps in your agent workflow.
Troubleshooting and validation checklist
- Auth errors: Ensure the Authorization header is exactly “Bearer YOUR_API_KEY” with a valid key from your Zyla dashboard.
- Bad input: Verify that url is a full YouTube watch URL. Ensure format is one of the listed values and properly encoded if concatenated to a URL.
- Time-sensitive audio links: If a user tries to fetch an audio object after 2 hours, re-run the request and start the download promptly.
- Unsupported content types: This endpoint handles regular videos only. If the source is a live stream, inform the user and disallow the action.
- Network reliability: Add simple backoff and log bodies for non-2xx responses to accelerate debugging.
Security considerations
- Store your Zyla API key in your secrets manager or environment variables; never hardcode it in client-side code.
- Sanitize and validate user-submitted YouTube URLs before sending them to the API.
- Never proxy your API key to untrusted frontends. Prefer server-side calls or agent-side tools in trusted environments.
Reference: official request and response
For convenience, here are the official blocks again for quick copy/paste.
Request
curl -s -X GET "https://zylalabs.com/api/11016/youtube-download-and-info-api/20761/download?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaGSKrC7dGcY&format=720" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"success": true,
"id": "2ec15939807689549d3f3115f168be6b9c868105",
"image": "https://i.ytimg.com/vi/aGSKrC7dGcY/hqdefault.jpg",
"progress_url": "https://youtube-api-progress-copy-development.up.railway.app/api/progress?id=2ec15939807689549d3f3115f168be6b9c868105"
}
FAQ
What formats can I request?
Video: 360p, 480p, 720p, 1080p, 1440p, 2160p. Audio: mp3, m4a, flac, opus, wav.
How do I authenticate?
Include the header Authorization: Bearer YOUR_API_KEY on every request. Get your key on the API’s Zyla listing after you subscribe.
Do audio links expire?
Yes. Audio download links expire after 2 hours. Start your final download promptly or re-invoke the API if needed.
Are live streams supported?
No. The endpoint supports downloading regular videos only.
How do I start a trial?
Use the item page on Zyla to begin your 7-day trial: Start 7-day trial on YouTube Download and Info API.
Ship it
You can integrate the YouTube Download and Info API in under an hour: call the Download endpoint with url and format, read id/image/progress_url, and wire a short background task to finalize your workflow. Create your account on Zyla and start the 7-day trial from the listing to get your API key and go live this week.