Back to Blog
General

YouTube Comments Scraper API: Extract Video Comments & Replies

February 15, 2026
4 min read
S
By SociaVault Team
youtubecomments scraperapisentiment analysis

YouTube Comments Scraper API: Extract & Analyze Video Comments

Need to understand what viewers are saying? This guide shows you how to scrape YouTube comments for sentiment analysis, audience research, and engagement monitoring.

Why Scrape YouTube Comments?

Comments reveal insights metrics can't capture:

  • Sentiment Analysis - Gauge audience reactions
  • Product Feedback - Find feature requests and complaints
  • Content Ideas - Discover what viewers want to see
  • Brand Monitoring - Track mentions and perception
  • Engagement Analysis - Identify active community members

Using the Comments API

const response = await fetch('https://api.sociavault.com/youtube/video/comments', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
  })
});

const comments = await response.json();

Sample Response

{
  "comments": [
    {
      "id": "abc123xyz",
      "text": "This is the best video I've ever seen! 🔥",
      "author": {
        "name": "Viewer Name",
        "channelId": "UCxxx",
        "profilePicture": "https://..."
      },
      "likes": 15230,
      "replyCount": 45,
      "publishedAt": "2026-01-08T14:30:00Z",
      "isHearted": true,
      "isPinned": false,
      "replies": [
        {
          "id": "abc123xyz_reply1",
          "text": "I totally agree!",
          "author": {
            "name": "Another Viewer",
            "channelId": "UCyyy"
          },
          "likes": 234,
          "publishedAt": "2026-01-08T15:00:00Z"
        }
      ]
    }
  ],
  "totalComments": 89000,
  "hasMore": true,
  "cursor": "next_page"
}

Use Cases

Sentiment Analysis

Analyze audience reaction:

const { comments } = await getComments(videoUrl);

const positive = comments.filter(c =>
  c.text.match(/love|amazing|great|best|awesome|perfect/i)
).length;

const negative = comments.filter(c =>
  c.text.match(/hate|bad|worst|boring|disappointed|waste/i)
).length;

const sentiment = {
  positive: (positive / comments.length * 100).toFixed(1) + '%',
  negative: (negative / comments.length * 100).toFixed(1) + '%',
  neutral: ((comments.length - positive - negative) / comments.length * 100).toFixed(1) + '%'
};

console.log('Sentiment breakdown:', sentiment);

Find Questions

Extract viewer questions for FAQ content:

const { comments } = await getComments(videoUrl);

const questions = comments.filter(c =>
  c.text.includes('?') ||
  c.text.match(/^(how|what|where|when|why|who|can|do|does|is|are)/i)
);

console.log(`Found ${questions.length} questions:`);
questions.forEach(q => console.log(`- ${q.text}`));

Identify Top Commenters

Find your most engaged community members:

const { comments } = await getComments(videoUrl);

const commenterCounts = {};
comments.forEach(c => {
  const name = c.author.name;
  commenterCounts[name] = (commenterCounts[name] || 0) + 1;
});

const topCommenters = Object.entries(commenterCounts)
  .sort((a, b) => b[1] - a[1])
  .slice(0, 10);

console.log('Most active commenters:', topCommenters);

Track Competitor Mentions

Find mentions of brands or products:

const { comments } = await getComments(videoUrl);

const brandKeywords = ['competitor1', 'competitor2', 'your-brand'];

const mentions = brandKeywords.map(brand => ({
  brand,
  count: comments.filter(c => 
    c.text.toLowerCase().includes(brand.toLowerCase())
  ).length
}));

console.log('Brand mentions:', mentions);

Get pinned and hearted comments:

const { comments } = await getComments(videoUrl);

const pinned = comments.find(c => c.isPinned);
const hearted = comments.filter(c => c.isHearted);

console.log('Pinned comment:', pinned?.text);
console.log(`Hearted comments: ${hearted.length}`);

Pagination

Get all comments from a video:

async function getAllComments(videoUrl) {
  let allComments = [];
  let cursor = null;

  do {
    const response = await fetch('https://api.sociavault.com/youtube/video/comments', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ url: videoUrl, cursor })
    });

    const data = await response.json();
    allComments = [...allComments, ...data.comments];
    cursor = data.hasMore ? data.cursor : null;

  } while (cursor);

  return allComments;
}

Frequently Asked Questions

Can I get replies to comments?

Yes, each comment includes a replies array with nested reply comments.

How many comments can I scrape?

You can scrape all available comments using pagination. Videos with millions of comments may take longer to fully retrieve.

Are deleted comments included?

No, only currently visible comments are returned.

Can I filter by date?

Comments are returned by YouTube's default sorting. Filter by publishedAt client-side for date ranges.

Can I get comments from private videos?

No, only public videos' comments are accessible.

Get Started

Sign up free and start extracting YouTube comments.

Documentation: /docs/api-reference/youtube/video-comments

Found this helpful?

Share it with others who might benefit

Ready to Try SociaVault?

Start extracting social media data with our powerful API. No credit card required.