# YouTube Transcripts API

Each successful request to this API will cost **`1`** credits.<br>

| Parameter                                                           | Description                                                                                                                                                                                                                                                      |
| ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>api\_key<br><br><br><mark style="color:red;">required</mark></p> | <p>Your personal API key. Available on your dashboard. <br><br>Type: <em><strong>String</strong></em></p>                                                                                                                                                        |
| <p>v<br><br><mark style="color:red;">required</mark></p>            | <p>YouTube Video ID.<br><br>Type: <em><strong>String</strong></em></p>                                                                                                                                                                                           |
| country                                                             | <p>This is the <a href="https://en.wikipedia.org/wiki/ISO_3166-1">ISO code</a> of the country from which you are seeking Youtube search results. <br><br>Default Value - <strong><code>us</code></strong> <br><br>Type - <strong>String</strong></p>             |
| language                                                            | <p>Language of the results. Possible Values - <strong><code>en</code></strong>, <strong><code>es</code></strong>, <strong><code>fr</code></strong>, <strong><code>de</code></strong>, etc. <br><br>Default Value - en <br><br>Type - <strong>String</strong></p> |

### API Example

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

```json
cURL "https://api.scrapingdog.com/youtube/transcripts?api_key=APIKEY&v=0e3GPea1Tyg"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

api_key = "5eaa61a6e562fc52fe763tr516e4653"
url = "https://api.scrapingdog.com/youtube/transcripts/"

params = {
    "api_key": api_key,
    "v": "0e3GPea1Tyg"
}

response = requests.get(url, params=params)

if response.status_code == 200:
    data = response.json()
    print(data)
else:
    print(f"Request failed with status code: {response.status_code}")

```

{% endtab %}

{% tab title="Node JS" %}

```javascript
const axios = require('axios');

const api_key = 'APIKEY';
const url = 'https://api.scrapingdog.com/youtube/transcripts/';

const params = {
  api_key: api_key,
  v: '0e3GPea1Tyg'
};

axios
  .get(url, { params: params })
  .then(function (response) {
    if (response.status === 200) {
      const data = response.data;
      console.log(data)
    } else {
      console.log('Request failed with status code: ' + response.status);
    }
  })
  .catch(function (error) {
    console.error('Error making the request: ' + error.message);
  });

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

// Set the API key and request parameters
$api_key = 'APIKEY';
$v = '0e3GPea1Tyg';

// Set the API endpoint
$url = 'https://api.scrapingdog.com/youtube/transcripts/?api_key=' . $api_key . '&v=' . $v;

// Initialize cURL session
$ch = curl_init($url);

// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request
$response = curl_exec($ch);

// Check if the request was successful
if ($response === false) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    // Process the response data as needed
    echo $response;
}

// Close the cURL session
curl_close($ch);

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'

# Set the API key and request parameters
api_key = 'APIKEY'
v = '0e3GPea1Tyg'

# Construct the API endpoint URL
url = URI.parse("https://api.scrapingdog.com/youtube/transcripts/?api_key=#{api_key}&v=#{v}")

# Create an HTTP GET request
request = Net::HTTP::Get.new(url)

# Create an HTTP client
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true # Enable SSL (https)

# Send the request and get the response
response = http.request(request)

# Check if the request was successful
if response.is_a?(Net::HTTPSuccess)
  puts response.body # Process the response data as needed
else
  puts "HTTP request failed with code: #{response.code}, message: #{response.message}"
end

```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        try {
            // Set the API key and request parameters
            String apiKey = "APIKEY";
            String v = "0e3GPea1Tyg";

            // Construct the API endpoint URL
            String apiUrl = "https://api.scrapingdog.com/youtube/transcripts/?api_key=" + apiKey
                    + "&v=" + v

            // Create a URL object from the API URL string
            URL url = new URL(apiUrl);

            // Open a connection to the URL
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();

            // Set the request method to GET
            connection.setRequestMethod("GET");

            // Get the response code
            int responseCode = connection.getResponseCode();

            if (responseCode == 200) {
                // Read the response from the connection
                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String inputLine;
                StringBuilder response = new StringBuilder();

                while ((inputLine = reader.readLine()) != null) {
                    response.append(inputLine);
                }
                reader.close();

                // Process the response data as needed
                System.out.println(response.toString());
            } else {
                System.out.println("HTTP request failed with response code: " + responseCode);
            }

            // Close the connection
            connection.disconnect();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}
{% endtabs %}

### API Response

```json
{
    "transcripts": [
        {
            "text": "- [Mr. Beast] I've\nrecreated every single set",
            "start": 0.15,
            "duration": 1.773
        },
        {
            "text": "from Squid Game in real life,",
            "start": 1.923,
            "duration": 1.857
        },
        {
            "text": "and whichever one of these 456\npeople survives the longest,",
            "start": 3.78,
            "duration": 3.6
        },
        {
            "text": "wins 456 grand.",
            "start": 7.38,
            "duration": 2.1
        },
        ........
     ]
} 
```


---

# 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://docs.scrapingdog.com/youtube-scraper-api/youtube-transcripts-api.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.
