NAVNavbar
Logo
cURL php NodeJS Python cSharp

Live YouTube Comments Advanced


Live YouTube Comments provides real-time data on comments on the video you specify in the request. You will get the top 20 comments on the video as well as information about the author, and key comment metrics.

Instead of ‘login’ and ‘password’ use your credentials from https://app.dataforseo.com/api-access

<?php
// You can download this file from here https://cdn.dataforseo.com/v3/examples/php/php_RestClient.zip
require('RestClient.php');
$api_url = 'https://api.dataforseo.com/';
try {
    // Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-access
    $client = new RestClient($api_url, null, 'login', 'password');
} catch (RestClientException $e) {
    echo "n";
    print "HTTP code: {$e->getHttpCode()}n";
    print "Error code: {$e->getCode()}n";
    print "Message: {$e->getMessage()}n";
    print  $e->getTraceAsString();
    echo "n";
    exit();
}
$post_array = array();
// You can set only one task at a time
$post_array[] = array(
    "language_code" => "en",
    "location_code" => 2840,
    "video_id" => mb_convert_encoding("vQXvyV0zIP4", "UTF-8")
);
try {
    // POST /v3/serp/youtube/video_comments/live/advanced
    // in addition to 'youtube' and 'video_comments' you can also set other search engine and type parameters
    // the full list of possible parameters is available in documentation
    $result = $client->post('/v3/serp/youtube/video_comments/live/advanced', $post_array);
    print_r($result);
    // do something with post result
} catch (RestClientException $e) {
    echo "n";
    print "HTTP code: {$e->getHttpCode()}n";
    print "Error code: {$e->getCode()}n";
    print "Message: {$e->getMessage()}n";
    print  $e->getTraceAsString();
    echo "n";
}
$client = null;
?>

The above command returns JSON structured like this:

{
  "version": "0.1.20220819",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "4.1248 sec.",
  "cost": 0.002,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "11151946-4426-0139-0000-83bae32ab24e",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "4.0397 sec.",
      "cost": 0.002,
      "result_count": 1,
      "path": [
        "v3",
        "serp",
        "youtube",
        "video_comments",
        "live",
        "advanced"
      ],
      "data": {
        "api": "serp",
        "function": "live",
        "se": "youtube",
        "se_type": "video_comments",
        "language_code": "en",
        "location_code": 2840,
        "video_id": "vQXvyV0zIP4",
        "device": "desktop",
        "os": "windows"
      },
      "result": [
        {
          "video_id": "vQXvyV0zIP4",
          "se_domain": "youtube.com",
          "location_code": 2840,
          "language_code": "en",
          "check_url": "https://www.youtube.com/watch?v=vQXvyV0zIP4",
          "datetime": "2022-11-15 17:46:30 +00:00",
          "spell": null,
          "refinement_chips": null,
          "item_types": [
            "youtube_comment"
          ],
          "title": "The first-ever BMW M5 CS.",
          "comments_count": 4080,
          "items_count": 20,
          "items": [
            {
              "type": "youtube_comment",
              "rank_group": 1,
              "rank_absolute": 1,
              "author_name": "BMW M",
              "author_thumbnail": "https://yt3.ggpht.com/mf6fcFw9Rt5jYWkkvld0rm8BMBaUtByv4vkgxl4RM5X_TBChHeWMKfc5nOy96DBu3DOLlWmtoto=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCl1hby9X42xkXUiAVcJS81A",
              "text": "To get notifications for all new exciting BMW M videos, subscribe here: http://b.mw/yt-bmwm-subscribe",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 417,
              "reply_count": 55
            },
            {
              "type": "youtube_comment",
              "rank_group": 2,
              "rank_absolute": 2,
              "author_name": "racemonkey",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu-JbekVxh3072_1hajVv847mU51S88foZygmmqJ=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCK4-fJHOpJpGhaZ_aSAY53A",
              "text": "Let’s just take a minute to appreciate what BMW have achieved here. At a time where other manufacturers are starting to shy away from performance cars.",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 487,
              "reply_count": 24
            },
            {
              "type": "youtube_comment",
              "rank_group": 3,
              "rank_absolute": 3,
              "author_name": "Leonardo Mangili",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu9gYjG_zEL_8ksmQHMPFfAdZFIAo-vkLI5SxBU=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCe5y4sBdt_snCl9zRbl5vbQ",
              "text": "I think for the first time in my life I got goosebumps from a car advert. Great video, whoever directed it, needs a raise",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 315,
              "reply_count": 4
            },
            {
              "type": "youtube_comment",
              "rank_group": 4,
              "rank_absolute": 4,
              "author_name": "Павел Багнюк",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu-NCY_h-mWzqRbCIR5zToOjsyz3Usk3cSNGjmTkZQ=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCXOXOSlU-gLDbXpq4QP_IBg",
              "text": "Я хочу сказать что вы, люди, которые создали этот автомобиль и те которые работали над этим роликом, настоящие мастера своего дела Этим роликом вы влюбили в данный автомобиль фанатов да и не только, и подарили людям мечту, особенно парнишкам, коим я был когда вышел этот шедевр, он меня покорил Само видео это отдельная история все сделано великолепно:саундизайн, монтаж и трек. Такой тонкости я удивляюсь до сих пор (прошло уже почти 2 года)!!!!!",
              "publication_date": "1 month ago",
              "timestamp": "2022-10-15 17:46:30 +00:00",
              "likes_count": 2,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 5,
              "rank_absolute": 5,
              "author_name": "Ryan Pederson",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu9gnPR_8w-B0WzEXln1FflM_SdvvW1tdROtFFinSNU=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCj5csH9RKphXvAa0_YykqbA",
              "text": "Wife: but we can’t live in an M5. Me: challenge accepted.",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 604,
              "reply_count": 11
            },
            {
              "type": "youtube_comment",
              "rank_group": 6,
              "rank_absolute": 6,
              "author_name": "Rinascimento",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu-FTlu41gv7oLt5ZcNaJqBeOxmlBR8aK1t-j1_M2Tw=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCA3wc9PumrDpwnYP5GBgv6g",
              "text": "This is not just an ad.It's a piece of art like this car.I am so impressed!",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 129,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 7,
              "rank_absolute": 7,
              "author_name": "Alm Kcr",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu8BQ-cy-chDpE9WDnmQBYiUKV7AzYqiYCyiEOCWNA=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UC6JYQJohAiVRCHmLOoPy_xA",
              "text": "The kind of car commercial we want to see. Motorsports, enthusiasm. That's what emotional cars  like M cars are all about.",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 61,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 8,
              "rank_absolute": 8,
              "author_name": "Alejandro Bonilla",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu9SKrwW0P7apJRfjrIH6IDUelDYxzCAjuIB8sMp=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCxg4NdoH-5ZlMiksixXtnIA",
              "text": "BMW and their current 5 series is proof that the company can do brilliant things",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 299,
              "reply_count": 9
            },
            {
              "type": "youtube_comment",
              "rank_group": 9,
              "rank_absolute": 9,
              "author_name": "Ferrari Scuderia",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu-TiNfmN-igsHotZ0BGg6byYkhWMC8CkzF3JQ=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCrJJCc1x3leJQL0vwlLENzA",
              "text": "Yes, this is the kind of BMW marketing that is needed! Great job! I feel that the M division should just take over BMW entirely. Also, that M5 CS, wow!!",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 51,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 10,
              "rank_absolute": 10,
              "author_name": "Vivid thespis",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu9L0c7qFQggJxJB0Mlwf2ffmdpLRCwfPNO2IA=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCtT8xfhW5b4qG55mcnaQsNA",
              "text": "Makes me proud to own a 5 Series. Welcome back BMW.",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 8,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 11,
              "rank_absolute": 11,
              "author_name": "taemi",
              "author_thumbnail": "https://yt3.ggpht.com/gC8CG3xayNmgHwuV-JulcQr7RgT36xWAbiVeEa6CNnajDemM7SlRMaO5IsOxsmRWd2xs7-x6=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UC1dUZT6MXpCiRWA8NaBI2PQ",
              "text": "I watched some ads for a marketing assignment but this one was amazing and I ended up watching it multiple times just out of enjoyment. It really shows that driving pleasure that BMW is all about.",
              "publication_date": "3 weeks ago",
              "timestamp": "2022-10-25 17:46:30 +00:00",
              "likes_count": 0,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 12,
              "rank_absolute": 12,
              "author_name": "Michal K",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu9aBOfFrVykKZEQaVMdjv22gyawEly_knAqfQ=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCB-TVr1zHI4blfBvHSORu0w",
              "text": "Best car commercial spot that I`ve seen for years. What a combination of music, feeling, acting, idea and camera work. And M5 CS... is just Unbelievable !",
              "publication_date": "1 year ago (edited)",
              "timestamp": null,
              "likes_count": 141,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 13,
              "rank_absolute": 13,
              "author_name": "George Kostician",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu8jtWQXZAkTzHXp5qr1fvNuS_arByWDPi6fa3t23A=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UC2zWzfipkJCz40oazCP-TFQ",
              "text": "I see this car going up in value in the years to come it’s fast looks like a work of art flying on the track just amazing car all around I love it 😍",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 4,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 14,
              "rank_absolute": 14,
              "author_name": "Calvin Huang",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu9jPy3MxeNf3Sx_CCuSyXAhPD-1IzDMHlga7ulZAQ=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCFhG6SE9C0E5nlcMS97aw2w",
              "text": "I got goosebumps when I’m watching this video. Just speechless, only stunning can describe this beast. BMW M, you definitely nailed it!",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 296,
              "reply_count": 8
            },
            {
              "type": "youtube_comment",
              "rank_group": 15,
              "rank_absolute": 15,
              "author_name": "hexlgaming",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu9PajNdWw_hj2QEo8zoJ-KgrWyrfw092id2zbiP=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCYB31yxp5XmnBm6gHkQGRoQ",
              "text": "I really like the orange accents in the headlights. The warm touch make it a whole lot nicer to look at and it's a great contrast to the usual blue. Also this car would look so damn good in britisch racing green with a brown leather Interior now..",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 1,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 16,
              "rank_absolute": 16,
              "author_name": "7UCKY",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu-YFBKWl9RcXVxtOH8s-GWQM03u-0Z1qiS9Ft3e=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCBoTxpj58ua7GpHHc7r4-Hw",
              "text": "This video is amazing. Whoever produced this, please keep them!",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 33,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 17,
              "rank_absolute": 17,
              "author_name": "Гарри",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu8XFjKfXRL4GB2uNH0axPSXqFd3MiuEhtoa49WGLg=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UC3_GjdvOWxEFIle1fD2v6cQ",
              "text": "Awesome commercial. Fantastic camera work, breathtaking sound design. And of course, an absolute beast of a car. German sedans one love.",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 3,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 18,
              "rank_absolute": 18,
              "author_name": "Hazi Pazi",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu_fgQQPBV6X65i5W0fGR6JDUU_icJtAOx3d9_nKCw=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UC4xX7H4-89kuNEU_CysgjbQ",
              "text": "This was unexpected to be honest. I have no words to describe how beautiful it is 😍",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 0,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 19,
              "rank_absolute": 19,
              "author_name": "Billy Lena",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu8Ez7JkjXLf5EbV2428MAzCJSP-Y6TwMpFAcHrBNQ=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCWYCpVAZaUS8x4e6iCCwLhQ",
              "text": "Man I felt this 😳 ...It was experiencing every single performance aspect of the Car without being in it 🤯",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 2,
              "reply_count": 0
            },
            {
              "type": "youtube_comment",
              "rank_group": 20,
              "rank_absolute": 20,
              "author_name": "PS91195",
              "author_thumbnail": "https://yt3.ggpht.com/ytc/AMLnZu_54BYGnpOvvu-HwFGQiG1mLtuMNy1w0Wmv7A49=s176-c-k-c0x00ffffff-no-rj",
              "author_url": "https://www.youtube.com/channel/UCetfAgEm_Da-kwm2e9PnFZQ",
              "text": "The first proper piece of BMW Marketing since the introduction of „that grill“? Looks promising!",
              "publication_date": "1 year ago",
              "timestamp": "2021-11-15 17:46:30 +00:00",
              "likes_count": 0,
              "reply_count": 20
            }
          ]
        }
      ]
    }
  ]
}

All POST data should be sent in the JSON format (UTF-8 encoding). When setting a task, you should send all task parameters in the task array of the generic POST array. You can send up to 2000 API calls per minute, each Live SERP API call can contain only one task.

Below you will find a detailed description of the fields you can use for setting a task.

Description of the fields for setting a task:

Field name Type Description
video_id string ID of the video
required field
you can find video ID in the URL or ‘youtube_video’ item of YouTube Organic result
example:
vQXvyV0zIP4
location_name string full name of search engine location
required field if you don’t specify location_code
if you use this field, you don’t need to specify location_code
you can receive the list of available locations of the search engine with their location_name by making a separate request to the https://api.dataforseo.com/v3/serp/youtube/locations
example:
United States
location_code integer search engine location code
required field if you don’t specify location_name 
if you use this field, you don’t need to specify location_name
you can receive the list of available locations of the search engines with their location_code by making a separate request to the https://api.dataforseo.com/v3/serp/youtube/locations
example:
2840
language_name string full name of search engine language
required field if you don’t specify language_code
if you use this field, you don’t need to specify language_code
you can receive the list of available languages of the search engine with their language_name by making a separate request to the https://api.dataforseo.com/v3/serp/youtube/languages
example:
English
language_code string search engine language code
required field if you don’t specify language_name
if you use this field, you don’t need to specify language_name
you can receive the list of available languages of the search engine with their language_code by making a separate request to the https://api.dataforseo.com/v3/serp/youtube/languages
example:
en
device string device type
optional field
only value: desktop
os string device operating system
optional field
choose from the following values: windows, macos
default value: windows
depth integer parsing depth
optional field
number of results in SERP
default value: 20
max value: 700
Note: your account will be billed per each SERP containing up to 20 results;
thus, setting a depth above 20 may result in additional charges if the search engine returns more than 20 results;
if the specified depth is higher than the number of results in the response, the difference will be refunded automatically to your account balance
tag string user-defined task identifier
optional field
the character limit is 255
you can use this parameter to identify the task and match it with the result
you will find the specified tag value in the data object of the response

‌‌‌
As a response of the API server, you will receive JSON-encoded data containing a tasks array with the information specific to the set tasks.

Description of the fields in the results array:

Field name Type Description
version string the current version of the API
status_code integer general status code
you can find the full list of the response codes here
Note: we strongly recommend designing a necessary system for handling related exceptional or error conditions
status_message string general informational message
you can find the full list of general informational messages here
time string execution time, seconds
cost float total tasks cost, USD
tasks_count integer the number of tasks in the tasks array
tasks_error integer the number of tasks in the tasks array returned with an error
tasks array array of tasks
        id string task identifier
unique task identifier in our system in the UUID format
        status_code integer status code of the task
generated by DataForSEO; can be within the following range: 10000-60000
you can find the full list of the response codes here
        status_message string informational message of the task
you can find the full list of general informational messages here
        time string execution time, seconds
        cost float cost of the task, USD
        result_count integer number of elements in the result array
        path array URL path
        data object contains the same parameters that you specified in the POST request
        result array array of results
            video_id string ID of the video received in a POST array
            se_domain string search engine domain in a POST array
            location_code integer location code in a POST array
            language_code string language code in a POST array
            check_url string direct URL to search engine results
you can use it to make sure that we provided accurate results
            datetime string date and time when the result was received
in the UTC format: “yyyy-mm-dd hh-mm-ss +00:00”
example:
2019-11-15 12:57:46 +00:00
            spell object autocorrection of the search engine
if the search engine provided results for a keyword that was corrected, we will specify the keyword corrected by the search engine and the type of autocorrection
            refinement_chips object search refinement chips
equals null
            item_types array types of search results in SERP
contains types of search results (items) found in SERP.
possible item:
youtube_comment
            title string title of the video
            comments_count integer number of comments on the video
            items_count integer the number of results returned in the items array
            items array elements of search results found in SERP
                type string type of element = ‘youtube_comment’
                rank_group integer group rank in SERP
position within a group of elements with identical type values
positions of elements with different type values are omitted from rank_group
                rank_absolute integer absolute rank in SERP for the target domain
absolute position among all the elements in SERP
                author_name string name of the author of the comment
                author_thumbnail string the URL of the page where the author’s channel logo is hosted
                author_url string URL of the author’s channel
                text string text of the comment
                publication_date string displayed publication date
                timestamp string date and time when the result was published
in the UTC format: “yyyy-mm-dd hh-mm-ss +00:00”
example:
2022-11-15 12:57:46 +00:00
                likes_count integer number of likes on the comment
                reply_count integer number of replies on the comment

‌‌