# Video Trainability

The `youtube_video_trainability` source is designed to retrieve information about whether a particular YouTube video **is eligible for AI training purposes**. This service enables verification of training permissions for YouTube content.

## Request samples

The following examples demonstrate how to check AI training permissions for a specific YouTube video.

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

```bash
curl 'https://realtime.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
"source": "youtube_video_trainability",
"video_id": "rFNDylrjn_w"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://realtime.oxylabs.io/v1/queries"
payload = {
    "source": "youtube_video_trainability",
    "video_id": "rFNDylrjn_w"
}
headers = {
    "Content-Type": "application/json"
}
auth = ("USERNAME", "PASSWORD")

response = requests.post(url, json=payload, headers=headers, auth=auth)
print(response.text)
```

{% endtab %}

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

```javascript
const fetch = require('node-fetch');

const url = 'https://realtime.oxylabs.io/v1/queries';
const payload = {
    source: 'youtube_video_trainability',
    video_id: 'rFNDylrjn_w'
};

const options = {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Basic ' + Buffer.from('USERNAME:PASSWORD').toString('base64')
    },
    body: JSON.stringify(payload)
};

fetch(url, options)
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
```

{% endtab %}

{% tab title="HTTP" %}

```http
POST /v1/queries HTTP/1.1
Host: realtime.oxylabs.io
Authorization: Basic [BASE64_ENCODED_CREDENTIALS]
Content-Type: application/json

{
    "source": "youtube_video_trainability",
    "video_id": "rFNDylrjn_w"
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = 'https://realtime.oxylabs.io/v1/queries';
$payload = [
    'source' => 'youtube_video_trainability',
    'video_id' => 'rFNDylrjn_w'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_USERPWD, 'USERNAME:PASSWORD');

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

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

func main() {
    url := "https://realtime.oxylabs.io/v1/queries"
    payload := map[string]string{
        "source": "youtube_video_trainability",
        "video_id":  "rFNDylrjn_w",
    }
    
    jsonPayload, _ := json.Marshal(payload)
    
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload))
    req.Header.Set("Content-Type", "application/json")
    req.SetBasicAuth("USERNAME", "PASSWORD")
    
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        using (var client = new HttpClient())
        {
            var url = "https://realtime.oxylabs.io/v1/queries";
            var payload = @"{
                ""source"": ""youtube_video_trainability"",
                ""video_id"": ""rFNDylrjn_w""
            }";
            
            var content = new StringContent(payload, Encoding.UTF8, "application/json");
            var byteArray = Encoding.ASCII.GetBytes("USERNAME:PASSWORD");
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
                "Basic", Convert.ToBase64String(byteArray));
            
            var response = await client.PostAsync(url, content);
            var responseContent = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseContent);
        }
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Base64;

public class OxylabsRequest {
    public static void main(String[] args) throws IOException, InterruptedException {
        String url = "https://realtime.oxylabs.io/v1/queries";
        String payload = "{\"source\":\"youtube_video_trainability\",\"video_id\":\"rFNDylrjn_w\"}";
        
        String auth = "USERNAME:PASSWORD";
        String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes());
        
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .header("Authorization", "Basic " + encodedAuth)
                .POST(HttpRequest.BodyPublishers.ofString(payload))
                .build();
        
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
    "source": "youtube_video_trainability",
    "video_id": "rFNDylrjn_w"
}
```

{% endtab %}
{% endtabs %}

We use synchronous [**Realtime**](https://developers.oxylabs.io/scraper-apis/web-scraper-api/integration-methods/realtime) integration method in our examples. If you would like to use [**Push-Pull**](broken://pages/DijMC0XcEbNczNgRaHIV) integration, refer to the [**Integration Methods**](broken://pages/PMUQIFSmnxA40vdpqgqd) section.

## Request parameter values

<table><thead><tr><th>Parameter</th><th width="225.04296875">Description</th><th>Default value</th></tr></thead><tbody><tr><td><mark style="background-color:green;"><strong>source</strong></mark></td><td>Sets the scraper.</td><td><code>youtube_video_trainability</code></td></tr><tr><td><mark style="background-color:green;"><strong>video_id</strong></mark></td><td>YouTube video ID.</td><td>-</td></tr><tr><td><code>callback_url</code></td><td>URL to your callback endpoint. <a href="https://app.gitbook.com/o/YFRJGnXcbhIMTe1cuCmz/s/zrXw45naRpCZ0Ku9AjY1/~/changes/830/scraper-apis/web-scraper-api/youtube/youtube-downloader/push-pull-single-job#callback"><strong>More info</strong></a>.</td><td>-</td></tr></tbody></table>

&#x20;    \- mandatory parameter

## Response format

The API returns a structured JSON response with the following fields:

```json
{
  "videoId": "<YOUTUBE_VIDEO_ID>",
  "kind": "youtube#videoTrainability",
  "etag": "<ETAG_VALUE>",
  "permitted": ["<PERMISSION_LEVEL>"]
}
```

The `permitted` field indicates the level of training permission available for the video, with these possible values:

| Value                       | Description                                         |
| --------------------------- | --------------------------------------------------- |
| `["all"]`                   | Training permitted for all parties                  |
| `["none"]`                  | No training permitted for any party                 |
| `["party1", "party2", ...]` | Training permitted only for specific listed parties |

The `etag` value serves as a version identifier for the training status.

### Example response

```json
{
  "videoId": "rFNDylrjn_w",
  "kind": "youtube#videoTrainability",
  "etag": "oXToFpOwrHWvoiN1YbOa0tkzOn0",
  "permitted": ["None"]
}
```


---

# Agent Instructions: 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:

```
GET https://developers.oxylabs.io/api-targets/video-and-social-media/youtube/youtube-video-trainability.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
