For the complete documentation index, see llms.txt. This page is also available as Markdown.

Downloader

Download YouTube audio and video content by video ID, with video quality configurable up to 8K, delivered directly to your cloud storage.

The youtube_download source delivers the audio/video content of a YouTube video of your choice. Please note that due to the potentially large data volume this source is only available via the asynchronous Push-Pull integration and the Cloud Storage feature.

How YouTube Downloader works

  1. Submit via API:

    • One or more YouTube video IDs;

    • Cloud storage details.

  2. Get the API response with the confirmation that your request to download a video has been successfully accepted.

  3. Get the videos in the specified cloud storage location as soon as they're processed by our system.

Input parameter values

Parameter
Description
Default value

source

Sets the scraper. Use youtube_download.

–

query

YouTube video ID.

–

storage_type

Storage type of the cloud service (gcs, s3 or s3_compatible)

–

storage_url

The bucket name (for AWS S3) or the URL (for other S3-compatible storage) of the cloud storage location you would like the result uploaded to.

–

callback_url

Your callback endpoint URL. More info

–

context: download_type

Specifies whether to download audio, video, or both - audio_video.

audio_video

context: video_quality

Sets video quality: best, worst, or a resolution: 144, 360, 480, 720, 1080, 1440, 2160(4K), 4320(8K).

720

context: audio_language

Specifies which audio track to download. Accepts default or original (the video's original audio track).

default

context: start_at

Timestamp for partial video download (clip) to start in hh:mm:ss format. Learn more.

–

context: end_at

Timestamp for partial video download (clip) to end in hh:mm:ss format. Must be later than start_at. Learn more.

–

– mandatory parameter

Submitting a single job

Endpoint

Input

Provide the job parameters in a JSON payload as shown in the example below:

Batch job

You can submit up to 5,000 video IDs within a single batch request.

Endpoint

Input

The API will respond with a JSON object, containing the job information for each job created. The job status will be pending until the download is completed.

Checking job status

If you provided a valid callback URL when submitting your job, we will notify you upon completion by sending a JSON payload to the specified callback URL.

However, if you submitted a job without using callback service, you can check the job status manually. Retrieve the URL from the href field in the rel:self section of the response message received after job submission. The URL for checking the job status will resemble the following: http://data.oxylabs.io/v1/queries/12345678900987654321. Querying this URL will return the job information, including its current status.

Endpoint

Partial download (trimming)

To download a specific segment or clip instead of the full video, add 2 additional parameters to your context array:

  • start_at – start timestamp of the trimmed clip in hh:mm:ss format.

  • end_at – end timestamp of the trimmed clip in hh:mm:ss format.

If both parameters are omitted, the request behaves as a standard full-video download.

If start_at or end_at fail validation, the HTTP 400 error is returned with a message field.

Condition
Error message

start_at is not in hh:mm:ss format

Invalid start_at value in context. Supported format: hh:mm:ss.

end_at is not in hh:mm:ss format

Invalid end_at value in context. Supported format: hh:mm:ss.

end_at is not later than start_at

Invalid end_at value in context. Must be later than start_at.

Cloud storage

You can get your YouTube videos delivered to Google Cloud Storage, Amazon S3, Alibaba OSS, or other S3-compatible cloud storage.

Content files will appear in your cloud storage location and will be named according to one of the following naming schemas:

  • {video_id}_{job_id}.mp4 – for video

  • {video_id}_{job_id}.m4a – for audio

Storage parameters

Parameter
Description
Valid values

storage_type

Your cloud storage type.

gcs (Google Cloud Storage);

s3 (AWS S3); s3_compatible (other S3-compatible storage solutions).

storage_url

Your cloud storage URL

Any s3 or gcs bucket name;

Any s3-compatible storage URL.

Google Cloud Storage setup

To get your job results uploaded to your Google Cloud Storage bucket, please set up special permissions for our service as shown in our Google Cloud Storage documentation.

Amazon S3 setup

To get your job results uploaded to your Amazon S3 bucket, please set up access permissions for our service. To do that, go to https://s3.console.aws.amazon.com/ → S3 → Storage → Bucket Name ``(if you don't have one, create a new one) → Permissions → Bucket Policy. You can find all required steps in our Amazon S3 cloud documentation.

Use the bucket policy below (don't forget to change the bucket name under YOUR_BUCKET_NAME):

This policy allows us to write to your bucket, give access to uploaded files to you, and know the location of the bucket.

Alibaba Cloud OSS setup

In order to save results to your Alibaba Cloud Object Storage Service (OSS), you must create the ACCESS_KEY_ID and ACCESS_KEY_SECRET and use them to form the storage URL. Follow the instructions outlined in our Alibaba Cloud OSS documentation .

S3-compatible storage setup

If you'd like to get your results delivered to other S3-compatible storage location, you'll have to include your bucket's ACCESS_KEY:SECRET auth string in the storage_url value in the payload:

Error codes

Code
Status
Description

11201

VIDEO_DELETED

Video is deleted.

11202

VIDEO_UNAVAILABLE

Video is unavailable.

11203

VIDEO_PRIVATE

Video is set to private by uploader and only they and explicitly invited people can see it.

11204

VIDEO_GEO_RESTRICTED

Video is geo-restricted.

11205

VIDEO_LIVE

Video is live now.

11206

VIDEO_AGE_RESTRICTED

Video is age restricted.

11207

VIDEO_MEMBER_ONLY

Video is for channel members only, and viewers have to pay the monthly subscription fee.

11208

VIDEO_PREMIUM_ONLY

Video requires the YouTube Premium subscription.

11209

VIDEO_LIVE_OR_TOO_LONG

Video is either live or too long to download.

11210

VIDEO_TOO_LONG

Video is too long to download.

11211

VIDEO_SIGN_IN_REQUIRED

Sign in is required.

Last updated

Was this helpful?