> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/api-targets/es/video-y-redes-sociales/youtube/youtube-downloader.md).

# Descargador

La `youtube_download` fuente entrega el contenido de audio/video de un video de YouTube de su elección. Tenga en cuenta que, debido al posible gran volumen de datos, esta fuente solo está disponible a través de la integración asíncrona [**integración Push-Pull**](/products/es/web-scraper-api/integration-methods/push-pull.md) y la [**Almacenamiento en la nube**](/products/es/web-scraper-api/features/result-processing-and-storage/cloud-storage.md) función.

## Cómo funciona YouTube Downloader

1. Enviar mediante API:
   * Uno o más IDs de video de YouTube;
   * Detalles del almacenamiento en la nube.
2. Obtenga la respuesta de la API con la confirmación de que su solicitud para descargar un video se ha aceptado correctamente.
3. Obtenga los videos en la ubicación de almacenamiento en la nube especificada tan pronto como sean procesados por nuestro sistema.

{% hint style="success" %}
**Nota**:

* El descargador usa de forma predeterminada la resolución de video 720p. Si 720p no está disponible, el descargador elegirá la mejor calidad disponible por debajo de 720p. Puede anular este comportamiento usando el `context: video_quality`parámetro.
* Puede descargar videos de hasta 12 horas de duración.
* El tiempo de descarga está limitado a 1 hora.
  {% endhint %}

## Valores de los parámetros de entrada

<table><thead><tr><th width="190">Parámetro</th><th width="412">Descripción</th><th width="137">Valor predeterminado</th></tr></thead><tbody><tr><td><mark style="background-color:green;"><strong><code>source</code></strong></mark></td><td>Establece el scraper. Use <code>youtube_download</code>.</td><td>–</td></tr><tr><td><mark style="background-color:green;"><strong><code>query</code></strong></mark></td><td>ID del video de YouTube.</td><td>–</td></tr><tr><td><mark style="background-color:green;"><strong><code>storage_type</code></strong></mark></td><td>Tipo de almacenamiento del servicio en la nube (<code>gcs</code>, <code>s3</code> o <code>s3_compatible</code>)</td><td>–</td></tr><tr><td><mark style="background-color:green;"><strong><code>storage_url</code></strong></mark></td><td>El nombre del bucket (para AWS S3) o la URL (para otro almacenamiento compatible con S3) de la ubicación de almacenamiento en la nube a la que desea que se cargue el resultado.</td><td>–</td></tr><tr><td><code>callback_url</code></td><td>La URL de su endpoint de callback. <a href="/spaces/xofNngbwiAAH0MB3lMAb/pages/28181dba27c108c1684f7f17f5d8fef78bd80d90#callback"><strong>Más información</strong></a></td><td>–</td></tr><tr><td><code>context:</code><br><code>download_type</code></td><td>Especifica si se debe descargar <code>audio</code>, <code>video</code>, o ambos - <code>audio_video</code>.</td><td><code>audio_video</code></td></tr><tr><td><code>context:</code><br><code>video_quality</code></td><td>Establece la calidad del video: <code>mejor</code>, <code>peor</code>, o una resolución: <code>144</code>, <code>360</code>, <code>480</code>, <code>720</code>, <code>1080</code>, <code>1440</code>, <code>2160</code>(4K), <code>4320</code>(8K).</td><td><code>720</code></td></tr><tr><td><code>context: audio_language</code></td><td>Especifica qué pista de audio descargar. Acepta <code>predeterminado</code> o <code>original</code> (la pista de audio original del video).</td><td><code>predeterminado</code></td></tr><tr><td><code>context:</code><br><code>start_at</code></td><td>Marca de tiempo para que la descarga parcial del video (clip) comience en <code>hh:mm:ss</code> formato. <a href="#partial-download-trimming">Más información</a>.</td><td>–</td></tr><tr><td><code>context:</code><br><code>end_at</code></td><td>Marca de tiempo para que la descarga parcial del video (clip) termine en <code>hh:mm:ss</code> formato. Debe ser posterior a <code>start_at</code>. <a href="#partial-download-trimming">Más información</a>.</td><td>–</td></tr></tbody></table>

&#x20;    – parámetro obligatorio

## Enviar un trabajo individual

#### Endpoint

```
POST https://data.oxylabs.io/v1/queries
```

#### Entrada

Proporcione los parámetros del trabajo en un payload JSON como se muestra en el ejemplo siguiente:

{% tabs %}
{% tab title="cURL" %}

```sh
curl --user "user:pass1" \\
'https://data.oxylabs.io/v1/queries' \\
-H "Content-Type: application/json" \\
-d '{
    "source": "youtube_download",
    "query": "9cQBNYsCqQs",
    "storage_type": "s3",
    "storage_url": "s3://your-s3-bucket/your-folder/"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint

payload = {
    "source": "youtube_download",
    "query": "9cQBNYsCqQs",
    "context": [
        {
            "key": "download_type",
            "value": "video"
        },
        {
            "key": "video_quality",
            "value": "1080"
        }
    ],
    "storage_type": "s3",
    "storage_url": "s3://your-s3-bucket/your-folder/"
}

response = requests.request(
    'POST',
    'https://data.oxylabs.io/v1/queries',
    auth=('user', 'pass1'),
    json=payload,
)

pprint(response.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$params = array(
    'source' => 'youtube_download',
    'query' => '9cQBNYsCqQs',
    "context" => [
        [
            "key" => "download_type",
            "value" => "video",
        ],
        [
            "key" => "video_quality",
            "value" => "1080",
        ]
    ],
    'storage_type' => 's3',
    'storage_url' => 's3://your-s3-bucket/your-folder/'
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://data.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "YOUR_USERNAME" . ":" . "YOUR_PASSWORD");

$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;

namespace OxyApi
{
    class Program
    {
        static async Task Main()
        {
            const string Username = "YOUR_USERNAME";
            const string Password = "YOUR_PASSWORD";
            var payload = new Dictionary<string, object>()
            {
                { "source", "youtube_download" },
                { "query", "9cQBNYsCqQs" },
                { "context", new[] {
                    new { key = "download_type", value = "video" },
                    new { key = "video_quality", value = "1080" }
                }},
                { "storage_type", "s3" },
                { "storage_url", "your-s3-bucket/your-folder/" }
            };
            
            var client = new HttpClient();
            var requestMessage = new HttpRequestMessage(HttpMethod.Post, "https://data.oxylabs.io/v1/queries/batch");
            requestMessage.Content = JsonContent.Create(payload);
            
            var authenticationString = $"{Username}:{Password}";
            var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(authenticationString));
            requestMessage.Headers.Add("Authorization", "Basic " + base64EncodedAuthenticationString);
            
            var response = await client.SendAsync(requestMessage);
            var contents = await response.Content.ReadAsStringAsync();
            Console.WriteLine(contents);
        }
    }
}
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	const Username = "YOUR_USERNAME"
	const Password = "YOUR_PASSWORD"

	// Define the context structure
	type ContextItem struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	}

	// Create payload with the same structure as the C# example
	payload := map[string]interface{}{
		"source": "youtube_download",
		"query":  []string{"9cQBNYsCqQs", "KGOsWPF4Wfs"},
		"context": []ContextItem{
			{Key: "download_type", Value: "video"},
			{Key: "video_quality", Value: "1080"},
		},
		"storage_type": "s3",
		"storage_url":  "your-s3-bucket/your-folder/",
	}

	jsonValue, _ := json.Marshal(payload)
	client := &http.Client{}
	request, _ := http.NewRequest("POST",
		"https://data.oxylabs.io/v1/queries/batch",
		bytes.NewBuffer(jsonValue),
	)
	request.Header.Add("Content-type", "application/json")
	request.SetBasicAuth(Username, Password)
	response, _ := client.Do(request)
	responseText, _ := ioutil.ReadAll(response.Body)
	fmt.Println(string(responseText))
}
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;
import okhttp3.*;
import org.json.JSONArray;
import org.json.JSONObject;
public class Main implements Runnable {
    private static final String AUTHORIZATION_HEADER = "Authorization";
    public static final String USERNAME = "YOUR_USERNAME";
    public static final String PASSWORD = "YOUR_PASSWORD";
    public void run() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("source", "youtube_download");
        jsonObject.put("query", "9cQBNYsCqQs");
        
        // Add context structure
        JSONArray contextArray = new JSONArray();
        
        JSONObject downloadTypeContext = new JSONObject();
        downloadTypeContext.put("key", "download_type");
        downloadTypeContext.put("value", "video");
        contextArray.put(downloadTypeContext);
        
        JSONObject videoQualityContext = new JSONObject();
        videoQualityContext.put("key", "video_quality");
        videoQualityContext.put("value", "1080");
        contextArray.put(videoQualityContext);
        
        jsonObject.put("context", contextArray);
        
        jsonObject.put("storage_type", "s3");
        jsonObject.put("storage_url", "your-s3-bucket/your-folder/");
        
        Authenticator authenticator = (route, response) -> {
            String credential = Credentials.basic(USERNAME, PASSWORD);
            return response
                    .request()
                    .newBuilder()
                    .header(AUTHORIZATION_HEADER, credential)
                    .build();
        };
        var client = new OkHttpClient.Builder()
                .authenticator(authenticator)
                .build();
        var mediaType = MediaType.parse("application/json; charset=utf-8");
        var body = RequestBody.create(jsonObject.toString(), mediaType);
        var request = new Request.Builder()
                .url("https://data.oxylabs.io/v1/queries/batch")
                .post(body)
                .build();
        try (var response = client.newCall(request).execute()) {
            assert response.body() != null;
            System.out.println(response.body().string());
        } catch (Exception exception) {
            System.out.println("Error: " + exception.getMessage());
        }
        System.exit(0);
    }
    public static void main(String[] args) {
        new Thread(new Main()).start();
    }
}
```

{% endtab %}

{% tab title="Node.js" %}

```sh
import fetch from 'node-fetch';

const username = 'YOUR_USERNAME';
const password = 'YOUR_PASSWORD';
const body = {
  source: 'youtube_download',
  query: '9cQBNYsCqQs',
  context: [
    { key: "download_type", value: "video" },
    { key: "video_quality", value: "1080"},
  ],
  storage_type: 's3',
  storage_url: 's3://your-s3-bucket/your-folder/'
};
const response = await fetch('https://data.oxylabs.io/v1/queries', {
  method: 'post',
  body: JSON.stringify(body),
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Basic ' + Buffer.from(`${username}:${password}`).toString('base64'),
  }
});

console.log(await response.json());
```

{% endtab %}
{% endtabs %}

## Trabajo por lotes

Puede enviar hasta 5.000 IDs de video en una sola solicitud por lotes.

#### Endpoint

```
POST https://data.oxylabs.io/v1/queries/batch
```

{% hint style="warning" %}
**IMPORTANTE:** Con `/batch` endpoint, solo puede enviar listas de `query`valores de parámetros. Todos los demás parámetros deben tener valores singulares.
{% endhint %}

#### Entrada

{% tabs %}
{% tab title="cURL" %}

```sh
curl --user "user:pass1" \\
'https://data.oxylabs.io/v1/queries/batch' \\
-H 'Content-Type: application/json' \\
-d '{
    "source": "youtube_download",
    "query": ["9cQBNYsCqQs", "KGOsWPF4Wfs"],
        "context": [
        {
            "key": "download_type",
            "value": "video"
        },
        {
            "key": "video_quality",
            "value": "1080"
        }
    ],
    "storage_type": "s3",
    "storage_url": "your-s3-bucket/your-folder/"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json
from pprint import pprint

payload = {
    "source": "youtube_download",
    "query": ["9cQBNYsCqQs", "KGOsWPF4Wfs"],
    "context": [
        {
            "key": "download_type",
            "value": "video"
        },
        {
            "key": "video_quality",
            "value": "1080"
        }
    ],
    "storage_type": "s3",
    "storage_url": "your-s3-bucket/your-folder/"
}

response = requests.request(
    'POST',
    'https://data.oxylabs.io/v1/queries/batch',
    auth=('user', 'pass1'),
    json=payload,
)

# Print prettified response.
pprint(response.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$payload = array(
    "source" => "youtube_download",
    "query" => array("9cQBNYsCqQs", "KGOsWPF4Wfs"),
    "context" => [
        [
            "key" => "download_type",
            "value" => "video",
        ],
        [
            "key" => "video_quality",
            "value" => "1080",
        ]
    ],
    "storage_type" => "s3",
    "storage_url" => "your-s3-bucket/your-folder/"
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://data.oxylabs.io/v1/queries/batch");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");

$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;

namespace OxyApi
{
    class Program
    {
        static async Task Main()
        {
            const string Username = "YOUR_USERNAME";
            const string Password = "YOUR_PASSWORD";
            var payload = new Dictionary<string, object>()
            {
                { "source", "youtube_download" },
                { "query", new[] { "9cQBNYsCqQs", "KGOsWPF4Wfs" } },
                { "context", new[] {
                    new { key = "download_type", value = "video" },
                    new { key = "video_quality", value = "1080" }
                }},
                { "storage_type", "s3" },
                { "storage_url", "your-s3-bucket/your-folder/" }
            };
            
            var client = new HttpClient();
            var requestMessage = new HttpRequestMessage(HttpMethod.Post, "https://data.oxylabs.io/v1/queries/batch");
            requestMessage.Content = JsonContent.Create(payload);
            
            var authenticationString = $"{Username}:{Password}";
            var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(authenticationString));
            requestMessage.Headers.Add("Authorization", "Basic " + base64EncodedAuthenticationString);
            
            var response = await client.SendAsync(requestMessage);
            var contents = await response.Content.ReadAsStringAsync();
            Console.WriteLine(contents);
        }
    }
}
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	const Username = "YOUR_USERNAME"
	const Password = "YOUR_PASSWORD"

	// Define the context structure
	type ContextItem struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	}

	// Create payload with the same structure as the C# example
	payload := map[string]interface{}{
		"source": "youtube_download",
		"query":  "9cQBNYsCqQs",
		"context": []ContextItem{
			{Key: "download_type", Value: "video"},
			{Key: "video_quality", Value: "1080"},
		},
		"storage_type": "s3",
		"storage_url":  "your-s3-bucket/your-folder/",
	}

	jsonValue, _ := json.Marshal(payload)
	client := &http.Client{}
	request, _ := http.NewRequest("POST",
		"https://data.oxylabs.io/v1/queries/batch",
		bytes.NewBuffer(jsonValue),
	)
	request.Header.Add("Content-type", "application/json")
	request.SetBasicAuth(Username, Password)
	response, _ := client.Do(request)
	responseText, _ := ioutil.ReadAll(response.Body)
	fmt.Println(string(responseText))
}
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;
import okhttp3.*;
import org.json.JSONArray;
import org.json.JSONObject;
public class Main implements Runnable {
    private static final String AUTHORIZATION_HEADER = "Authorization";
    public static final String USERNAME = "YOUR_USERNAME";
    public static final String PASSWORD = "YOUR_PASSWORD";
    public void run() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("source", "youtube_download");
        
        // Change query to array format like in C# example
        JSONArray queryArray = new JSONArray();
        queryArray.put("9cQBNYsCqQs");
        queryArray.put("KGOsWPF4Wfs");
        jsonObject.put("query", queryArray);
        
        // Add context structure
        JSONArray contextArray = new JSONArray();
        
        JSONObject downloadTypeContext = new JSONObject();
        downloadTypeContext.put("key", "download_type");
        downloadTypeContext.put("value", "video");
        contextArray.put(downloadTypeContext);
        
        JSONObject videoQualityContext = new JSONObject();
        videoQualityContext.put("key", "video_quality");
        videoQualityContext.put("value", "1080");
        contextArray.put(videoQualityContext);
        
        jsonObject.put("context", contextArray);
        
        jsonObject.put("storage_type", "s3");
        jsonObject.put("storage_url", "your-s3-bucket/your-folder/");
        
        Authenticator authenticator = (route, response) -> {
            String credential = Credentials.basic(USERNAME, PASSWORD);
            return response
                    .request()
                    .newBuilder()
                    .header(AUTHORIZATION_HEADER, credential)
                    .build();
        };
        var client = new OkHttpClient.Builder()
                .authenticator(authenticator)
                .build();
        var mediaType = MediaType.parse("application/json; charset=utf-8");
        var body = RequestBody.create(jsonObject.toString(), mediaType);
        var request = new Request.Builder()
                .url("https://data.oxylabs.io/v1/queries/batch")
                .post(body)
                .build();
        try (var response = client.newCall(request).execute()) {
            assert response.body() != null;
            System.out.println(response.body().string());
        } catch (Exception exception) {
            System.out.println("Error: " + exception.getMessage());
        }
        System.exit(0);
    }
    public static void main(String[] args) {
        new Thread(new Main()).start();
    }
}
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
import fetch from 'node-fetch';

const username = 'YOUR_USERNAME';
const password = 'YOUR_PASSWORD';

const payload = {
    source: 'youtube_download',
    query: ['9cQBNYsCqQs', 'KGOsWPF4Wfs'],
      context: [
        { key: "download_type", value: "video" },
        { key: "video_quality", value: "1080"},
      ]
    storage_type: 's3',
    storage_url: 'your-s3-bucket/your-folder/'
};

const response = await fetch('https://data.oxylabs.io/v1/queries/batch', {
    method: 'post',
    body: JSON.stringify(payload),
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Basic ' + Buffer.from(`${username}:${password}`).toString('base64'),
    }
});

console.log(await response.json());
```

{% endtab %}
{% endtabs %}

La API responderá con un objeto JSON que contiene la información del trabajo de cada trabajo creado. El estado del trabajo será **`pendiente`** hasta que la descarga se complete.

## Verificando el estado del trabajo

Si proporcionó un [**URL de callback**](/products/es/web-scraper-api/integration-methods/push-pull.md#callback) al enviar su trabajo, le notificaremos al completarse enviando un `JSON` payload al URL de callback especificado.&#x20;

Sin embargo, si envió un trabajo sin usar [**servicio de callback**](/products/es/web-scraper-api/integration-methods/push-pull.md#callback), puede comprobar el estado del trabajo manualmente. Recupere la URL del `href` campo en la `rel:self` sección del mensaje de respuesta recibido después de enviar el trabajo. La URL para comprobar el estado del trabajo se parecerá a la siguiente: `http://data.oxylabs.io/v1/queries/12345678900987654321`. Consultar esta URL devolverá la información del job, incluido su estado actual `estado`.

### Endpoint <a href="#endpoint-1" id="endpoint-1"></a>

```
GET https://data.oxylabs.io/v1/queries/{id}
```

## Descarga parcial (recorte)

Para descargar un segmento o clip específico en lugar del video completo, añade 2 parámetros adicionales a tu `contexto` matriz:

* `start_at` – marca de tiempo de inicio del clip recortado en `hh:mm:ss` formato.
* `end_at` – marca de tiempo de fin del clip recortado en `hh:mm:ss` formato.

{% hint style="warning" %}
`end_at` el valor de marca de tiempo debe ser posterior a `start_at`. Solo `hh:mm:ss` se admite el formato.
{% endhint %}

```json
{
    "source": "youtube_download",
    "query": "0xFXmJgVgzc",
    "context": [
        {
            "key": "start_at",
            "value": "00:01:30"
        },
        {
            "key": "end_at",
            "value": "00:05:45"
        }
    ],
    "storage_type": "s3",
    "storage_url": "s3://your-s3-bucket/your-folder/"
}
```

{% hint style="info" %}
Si se omiten ambos parámetros, la solicitud se comporta como una descarga estándar del video completo.
{% endhint %}

Si `start_at` o `end_at` fallan la validación, el HTTP `400` se devuelve un error con un `campo message.` campo.

<table><thead><tr><th width="271">Condición</th><th>Mensaje de error</th></tr></thead><tbody><tr><td><code>start_at</code> no está en <code>hh:mm:ss</code> formato</td><td><code>Valor de start_at no válido en el contexto. Formato admitido: hh:mm:ss.</code></td></tr><tr><td><code>end_at</code> no está en <code>hh:mm:ss</code> formato</td><td><code>Valor de end_at no válido en el contexto. Formato admitido: hh:mm:ss.</code></td></tr><tr><td><code>end_at</code> no es posterior a <code>start_at</code></td><td><code>Valor de end_at no válido en el contexto. Debe ser posterior a start_at.</code></td></tr></tbody></table>

## Almacenamiento en la nube

Puedes recibir tus videos de YouTube en [**Google Cloud Storage**](#google-cloud-storage-setup), [**Amazon S3**](#amazon-s3-setup), [**Alibaba OSS**](#alibaba-cloud-oss-setup), o [**otro almacenamiento en la nube compatible con S3**](#s3-compatible-storage-setup).

Los archivos de contenido aparecerán en tu ubicación de almacenamiento en la nube y se nombrarán según uno de los siguientes esquemas de nombres:

* `{video_id}_{job_id}.mp4` – para video
* `{video_id}_{job_id}.m4a` – para audio

### Parámetros de almacenamiento

<table><thead><tr><th width="170.03125">Parámetro</th><th width="263.372304199773">Descripción</th><th>Valores válidos</th></tr></thead><tbody><tr><td><code>storage_type</code></td><td>Tu tipo de almacenamiento en la nube.</td><td><p><code>gcs</code> (Google Cloud Storage);</p><p><code>s3</code> (AWS S3);<br><code>s3_compatible</code> (otras soluciones de almacenamiento compatibles con S3).</p></td></tr><tr><td><code>storage_url</code></td><td>La URL de tu almacenamiento en la nube</td><td><p>Cualquier <code>s3</code> o <code>gcs</code> nombre del bucket;</p><p>Cualquier <code>compatible con S3</code> URL de almacenamiento.</p></td></tr></tbody></table>

### **Configuración de Google Cloud Storage** <a href="#google-cloud-storage-setup" id="google-cloud-storage-setup"></a>

Para que los resultados de tu job se suban a tu bucket de Google Cloud Storage, por favor **configura permisos especiales para nuestro servicio** como se muestra en nuestra [documentación de Google Cloud Storage](/products/es/web-scraper-api/features/result-processing-and-storage/cloud-storage.md#google-cloud-storage).

```json
{
    "source": "youtube_download",
    "query": "9cQBNYsCqQs",
    "storage_type": "gcs",
    "storage_url": "bucket_name/path"
}
```

### Configuración de Amazon S3

Para que los resultados de tu job se suban a tu bucket de Amazon S3, configura los permisos de acceso para nuestro servicio. Para hacerlo, ve a [**https://s3.console.aws.amazon.com/**](https://s3.console.aws.amazon.com/) → **`S3`** → **`Almacenamiento`** → **`Nombre del bucket`**` ``(si no tienes uno, crea uno nuevo)` → **`Permisos`** → **`Política del bucket`**. Puedes encontrar todos los pasos necesarios en nuestra [documentación en la nube de Amazon S3](/products/es/web-scraper-api/features/result-processing-and-storage/cloud-storage.md#amazon-s3).

Usa la política del bucket de abajo (no olvides cambiar el nombre del bucket bajo `YOUR_BUCKET_NAME`):

```json
{
    "Version": "2012-10-17",
    "Id": "Policy1577442634787",
    "Statement": [
        {
            "Sid": "Stmt1577442633719",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::324311890426:user/oxylabs.s3.uploader"
            },
            "Action": "s3:GetBucketLocation",
            "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME"
        },
        {
            "Sid": "Stmt1577442633719",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::324311890426:user/oxylabs.s3.uploader"
            },
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl"
            ],
            "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*"
        }
    ]
}
```

Esta política nos permite escribir en tu bucket, darte acceso a los archivos subidos y conocer la ubicación del bucket.

### Configuración de Alibaba Cloud OSS

Para guardar los resultados en tu Alibaba Cloud Object Storage Service (OSS), debes crear el `ACCESS_KEY_ID` y `ACCESS_KEY_SECRET` y usarlos para formar la URL de almacenamiento. Sigue las instrucciones descritas en nuestra [documentación de Alibaba Cloud OSS ](/products/es/web-scraper-api/features/result-processing-and-storage/cloud-storage.md#alibaba-cloud-object-storage-service-oss).

```json
{
    "source": "youtube_download",
    "query": "9cQBNYsCqQs",
    "storage_type": "s3_compatible",
    "storage_url": "https://ACCESS_KEY_ID:ACCESS_KEY_SECRET@BUCKET_NAME.oss-REGION.aliyuncs.com/FOLDER_NAME"
}
```

### Configuración de almacenamiento compatible con S3

Si quieres que tus resultados se entreguen en [otra ubicación de almacenamiento compatible con S3](/products/es/web-scraper-api/features/result-processing-and-storage/cloud-storage.md#other-s3-compatible-storage) tendrás que incluir la cadena de autenticación de tu bucket en el `ACCESS_KEY:SECRET` cadena de autenticación en el `storage_url` valor en la carga útil:

```json
{
    "source": "youtube_download",
    "query": "9cQBNYsCqQs",
    "storage_type": "s3_compatible",
    "storage_url": "https://ACCESS_KEY:SECRET@s3.oxylabs.io/my-videos"
}
```

## Códigos de error

<table><thead><tr><th width="170.03125">Código</th><th width="263.372304199773">Estado</th><th>Descripción</th></tr></thead><tbody><tr><td><code>11201</code></td><td><code>VIDEO_DELETED</code></td><td>El video está eliminado.</td></tr><tr><td><code>11202</code></td><td><code>VIDEO_UNAVAILABLE</code></td><td>El video no está disponible.</td></tr><tr><td><code>11203</code></td><td><code>VIDEO_PRIVATE</code></td><td>El video está configurado como privado por quien lo subió y solo esa persona y las personas invitadas explícitamente pueden verlo.</td></tr><tr><td><code>11204</code></td><td><code>VIDEO_GEO_RESTRICTED</code></td><td>El video tiene restricción geográfica.</td></tr><tr><td><code>11205</code></td><td><code>VIDEO_LIVE</code></td><td>El video está en vivo ahora.</td></tr><tr><td><code>11206</code></td><td><code>VIDEO_AGE_RESTRICTED</code></td><td>El video tiene restricción de edad.</td></tr><tr><td><code>11207</code></td><td><code>VIDEO_MEMBER_ONLY</code></td><td>El video es solo para miembros del canal, y los espectadores tienen que pagar la cuota mensual de suscripción.</td></tr><tr><td><code>11208</code></td><td><code>VIDEO_PREMIUM_ONLY</code></td><td>El video requiere la suscripción a YouTube Premium.</td></tr><tr><td><code>11209</code></td><td><code>VIDEO_LIVE_OR_TOO_LONG</code></td><td>El video está en vivo o es demasiado largo para descargar.</td></tr><tr><td><code>11210</code></td><td><code>VIDEO_TOO_LONG</code></td><td>El video es demasiado largo para descargar.</td></tr><tr><td><code>11211</code></td><td><code>VIDEO_SIGN_IN_REQUIRED</code></td><td>Se requiere iniciar sesión.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/api-targets/es/video-y-redes-sociales/youtube/youtube-downloader.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
