# YouTube Video API

Each successful request to this API will cost **`5`** credits.

### Parameters

#### Scrapingdog Parameters

| Parameter                                                          | Description                                                                                               |
| ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| <p>api\_key<br></p><p><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> |

#### Localization

| Parameter | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| country   | <p>This parameter specifies the country for the YouTube Videos using a two-letter country code (e.g., US for the United States, UK for the United Kingdom, or FR for France). For a complete list of supported countries, visit the <a href="https://docs.scrapingdog.com/google-search-scraper-api/google-country-parameter-supported-google-countries">Google countries page</a>. <br><br>Default Value - <strong><code>us</code></strong> </p><p></p><p>Type - <em><strong>String</strong></em></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. Visit <a href="https://docs.scrapingdog.com/google-search-scraper-api/google-language-page">Google's languages page</a> for a complete list of supported countries. <br><br>Default Value - en <br><br>Type - <em><strong>String</strong></em></p>                                                          |

#### Search Query

| Parameter                                                        | Description                                                                |
| ---------------------------------------------------------------- | -------------------------------------------------------------------------- |
| <p>video\_id<br><br><mark style="color:red;">required</mark></p> | <p>The YouTube Video ID.<br><br>Type: <em><strong>String</strong></em></p> |

### API Example

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

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

{% endtab %}

{% tab title="Python" %}

```python
import requests

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

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/video/';

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/video/?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/video/?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/video/?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
{
    "video": {
        "id": "0e3GPea1Tyg",
        "title": "$456,000 Squid Game In Real Life!",
        "length_seconds": 1541,
        "views": "876,754,415 views",
        "likes": "19M",
        "author": "MrBeast",
        "published_time": "3 years ago",
        "description": "MAKE SURE YOU WATCH UNTIL GLASS BRIDGE IT'S INSANE!\n\nWatch Beast Games now on Prime Video!!! https://www.beastgames.com\n\nThank you GoPro for supplying us with cameras to get some of these shots. You can get them here: https://prf.hn/l/6bNbQB3\n\nShoutout to SOKRISPYMEDIA for helping with visuals!\n\nCheck out Viewstats! - https://www.viewstats.com/\n\nFor any questions or inquiries regarding this video please reach out to chucky@mrbeastbusiness.com\n\n----------------------------------------------------------------\nfollow all of these or i will kick you\n• Facebook -   / mrbeast6000  \n• Twitter -   / mrbeast  \n•  Instagram -   / mrbeast  \n--------------------------------------------------------------------",
        "keywords": [
            "video",
            "sharing",
            "camera phone",
            "video phone",
            "free",
            "upload"
        ],
        "thumbnail": "https://i.ytimg.com/vi/0e3GPea1Tyg/maxresdefault.jpg"
    },
    "channel": {
        "id": "UCRkuUgtDAL4XSU5jB40J_wA",
        "name": "MrBeast",
        "link": "https://www.youtube.com/@MrBeast",
        "subscribers": "440M subscribers",
        "featured_channel": {
            "id": "UCRkuUgtDAL4XSU5jB40J_wA",
            "name": "MrBeast",
            "link": "https://www.youtube.com/@MrBeast"
        },
        "thumbnail": "https://yt3.ggpht.com/nxYrc_1_2f77DoBadyxMTmv7ZpRZapHR5jbuYe7PlPd5cIRJxtNNEYyOC0ZsxaDyJJzXrnJiuDE=s176-c-k-c0x00ffffff-no-rj"
    },
    "comment": {
        "total": "634K"
    },
    "key_moments": [
        {
            "title": "Red Light",
            "start_seconds": 0,
            "thumbnail": "https://i.ytimg.com/vi/0e3GPea1Tyg/hqdefault_4000.jpg?sqp=-oaymwEnCNACELwBSFryq4qpAxkIARUAAIhCGAHYAQHiAQoIGBACGAY4AUAB&rs=AOn4CLCcFMhkEIiZf7Wbhqtg8cRxUxbYXQ"
        },
        {
            "title": "Honeycomb",
            "start_seconds": 240,
            "thumbnail": "https://i.ytimg.com/vi/0e3GPea1Tyg/hqdefault_246000.jpg?sqp=-oaymwEnCNACELwBSFryq4qpAxkIARUAAIhCGAHYAQHiAQoIGBACGAY4AUAB&rs=AOn4CLAAEgrwqyRs5nVyoPo5A4Lh5xAdEg"
        },
        {
            "title": "Tug Of War",
            "start_seconds": 460,
            "thumbnail": "https://i.ytimg.com/vi/0e3GPea1Tyg/hqdefault_480000.jpg?sqp=-oaymwEnCNACELwBSFryq4qpAxkIARUAAIhCGAHYAQHiAQoIGBACGAY4AUAB&rs=AOn4CLA6xvoUFRrrAxFfDIcYOCKl2pYCgw"
        },
        {
            "title": "Marbles",
            "start_seconds": 624,
            "thumbnail": "https://i.ytimg.com/vi/0e3GPea1Tyg/hqdefault_631000.jpg?sqp=-oaymwEnCNACELwBSFryq4qpAxkIARUAAIhCGAHYAQHiAQoIGBACGAY4AUAB&rs=AOn4CLC7asCNMSqwAsFtbVp_bSAUq8Vsdg"
        },
        {
            "title": "Elimination",
            "start_seconds": 676,
            "thumbnail": "https://i.ytimg.com/vi/0e3GPea1Tyg/hqdefault_703500.jpg?sqp=-oaymwEnCNACELwBSFryq4qpAxkIARUAAIhCGAHYAQHiAQoIGBACGAY4AUAB&rs=AOn4CLDHmmk0CYH4kchE8zIEof35kOR8Fg"
        },
        {
            "title": "Glass Bridge",
            "start_seconds": 989,
            "thumbnail": "https://i.ytimg.com/vi/0e3GPea1Tyg/hqdefault_993000.jpg?sqp=-oaymwEnCNACELwBSFryq4qpAxkIARUAAIhCGAHYAQHiAQoIGBACGAY4AUAB&rs=AOn4CLAW3qCntt6NTrsBPbX-xBO2HFXW_A"
        },
        {
            "title": "Final Game",
            "start_seconds": 1291,
            "thumbnail": "https://i.ytimg.com/vi/0e3GPea1Tyg/hqdefault_1312500.jpg?sqp=-oaymwEnCNACELwBSFryq4qpAxkIARUAAIhCGAHYAQHiAQoIGBACGAY4AUAB&rs=AOn4CLCXWGtmxG_kLAPUXudsW-LUQ3J4xA"
        }
    ],
    "chapters": []
}
```
