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/v1/scrape/youtube/video/comments?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ&order=top',
{
headers: {
'x-api-key': 'YOUR_API_KEY'
}
}
);
const comments = await response.json();
Parameters
| Parameter | Required | Description |
|---|---|---|
url | Yes | YouTube video URL |
order | No | top (default) or newest |
continuationToken | No | Token from previous response for pagination |
Note: Returns ~20 top-level comments per page. Max ~1k with
order=top, ~7k withorder=newest. YouTube's displayed count includes reply threads — the API returns top-level comments only.
Sample Response
Comments are returned as an object with numeric keys. Use Object.values() to iterate.
{
"success": true,
"data": {
"comments": {
"0": {
"id": "Ugz02PQAsHBQfJ_PIxR4AaABAg",
"content": "This is the best video I've ever seen! 🔥",
"publishedTimeText": "3 months ago",
"publishedTime": "2025-11-08T23:18:52.207Z",
"replyLevel": 0,
"author": {
"name": "@ViewerName",
"channelId": "UCvFT6_Z1fpHOmj6T-vxHTdg",
"isVerified": false,
"isCreator": false,
"avatarUrl": "https://yt3.ggpht.com/...",
"channelUrl": "https://youtube.com/@ViewerName"
},
"engagement": {
"likes": 15230,
"replies": 45
}
}
},
"continuationToken": "Eg0SCzRPbUlfY0xZVEpR..."
},
"credits_used": 1
}
Use Cases
Sentiment Analysis
Analyze audience reaction:
async function analyzeSentiment(videoUrl) {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/video/comments?url=${encodeURIComponent(videoUrl)}&order=top`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const comments = Object.values(data.comments);
const positive = comments.filter(c =>
c.content.match(/love|amazing|great|best|awesome|perfect/i)
).length;
const negative = comments.filter(c =>
c.content.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:
async function findQuestions(videoUrl) {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/video/comments?url=${encodeURIComponent(videoUrl)}`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const comments = Object.values(data.comments);
const questions = comments.filter(c =>
c.content.includes('?') ||
c.content.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.content}`));
}
Identify Top Commenters
Find your most engaged community members:
async function topCommenters(videoUrl) {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/video/comments?url=${encodeURIComponent(videoUrl)}&order=newest`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const comments = Object.values(data.comments);
const commenterCounts = {};
comments.forEach(c => {
const name = c.author.name;
commenterCounts[name] = (commenterCounts[name] || 0) + 1;
});
const top = Object.entries(commenterCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 10);
console.log('Most active commenters:', top);
}
Track Competitor Mentions
Find mentions of brands or products:
async function trackMentions(videoUrl) {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/video/comments?url=${encodeURIComponent(videoUrl)}`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const comments = Object.values(data.comments);
const brandKeywords = ['competitor1', 'competitor2', 'your-brand'];
const mentions = brandKeywords.map(brand => ({
brand,
count: comments.filter(c =>
c.content.toLowerCase().includes(brand.toLowerCase())
).length
}));
console.log('Brand mentions:', mentions);
}
Find Most Liked Comments
Get the highest engagement comments:
async function mostLiked(videoUrl) {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/video/comments?url=${encodeURIComponent(videoUrl)}&order=top`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const comments = Object.values(data.comments);
const sorted = comments.sort((a, b) => b.engagement.likes - a.engagement.likes);
console.log('Top liked comments:');
sorted.slice(0, 5).forEach(c => {
console.log(`[${c.engagement.likes} likes] ${c.author.name}: ${c.content}`);
});
}
## Pagination
Get more comments from a video using `continuationToken`:
```javascript
async function getAllComments(videoUrl) {
let allComments = [];
let continuationToken = null;
do {
const params = new URLSearchParams({ url: videoUrl, order: 'newest' });
if (continuationToken) params.set('continuationToken', continuationToken);
const response = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/video/comments?${params}`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await response.json();
allComments = [...allComments, ...Object.values(data.comments)];
continuationToken = data.continuationToken || null;
} while (continuationToken);
return allComments;
}
Related Endpoints
- YouTube Video Details - Video metadata
- YouTube Videos Scraper - Channel videos
- YouTube Transcript - Video transcripts
- TikTok Comments - TikTok comments
Frequently Asked Questions
Can I get replies to comments?
The API returns top-level comments only. Each comment includes engagement.replies (the reply count) and replyLevel: 0. To see reply counts, check the engagement field.
How many comments can I scrape?
You can paginate through comments using continuationToken. Max ~1k comments with order=top, ~7k with order=newest. Use order=newest to retrieve more comments.
Are deleted comments included?
No, only currently visible comments are returned.
Can I filter by date?
Comments are returned sorted by order parameter (top or newest). Filter by publishedTime 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.