How to Scrape Instagram Comments (Giveaways, Sentiment & Export)
Comments are where the real signal lives on Instagram. Likes are a thumbs-up; comments are people telling you what they actually think — and, for giveaways, they're the entry mechanism itself. The trouble is that Instagram gives you no way to export them. You can scroll a post's comments forever, but try pulling 2,000 of them into a spreadsheet by hand and you'll give up around comment 40.
This guide shows you how to export comments from any public post or reel with a few lines of code, then put them to work for three common jobs: running a fair giveaway, gauging sentiment on a launch, and catching spam. Code's in both JavaScript and Python.
The endpoint
One endpoint does the work:
GET /v1/scrape/instagram/comments
Parameters:
url(required) — the full URL of the post or reel, e.g.https://www.instagram.com/p/Cz123abc/cursor(optional) — pass the cursor from a previous response to fetch the next page of comments
It costs 1 credit per request, and each request returns a page of comments. For a viral post with thousands of comments, you page through with the cursor until you've got them all.
A quick smoke test with curl:
curl -G "https://api.sociavault.com/v1/scrape/instagram/comments" \
--data-urlencode "url=https://www.instagram.com/p/Cz123abc/" \
-H "x-api-key: YOUR_API_KEY"
The response looks like this:
{
"success": true,
"data": {
"num_comments_grabbed": 343,
"comments": [
{
"id": "17916526530048829",
"text": "This is amazing 🔥 @sarah @mike you need to see this",
"created_at": "2025-01-17T14:07:40.000Z",
"user": {
"username": "fan_account_1",
"is_verified": false,
"profile_pic_url": "https://..."
}
}
]
},
"credits_used": 1,
"endpoint": "instagram/comments"
}
The comments array is at data.comments, and each comment gives you the text, the author's user.username, and a timestamp. That's everything you need.
Fetching comments
A single request returns a page of comments (in our testing, a few hundred at a time). Here's the basic fetch in JavaScript:
const API_KEY = process.env.SOCIAVAULT_API_KEY;
const BASE = "https://api.sociavault.com/v1";
async function getComments(postUrl, cursor = null) {
const params = new URLSearchParams({ url: postUrl });
if (cursor) params.set("cursor", cursor);
const res = await fetch(`${BASE}/scrape/instagram/comments?${params}`, {
headers: { "x-api-key": API_KEY },
});
const json = await res.json();
if (!json.success) throw new Error(json.error);
return json.data.comments || [];
}
const comments = await getComments("https://www.instagram.com/p/Cz123abc/");
console.log(`Got ${comments.length} comments`);
If a post has more comments than one response returns, the endpoint supports pagination through the cursor parameter — pass the cursor from the response back in to fetch the next page (see the docs for the exact field). Each request is one credit, so when you loop for a viral post, set a page cap and keep a small delay between calls rather than hammering the endpoint.
Use case 1: Run a fair giveaway
The classic giveaway rule is "tag 3 friends to enter." To pick a winner fairly, you need to find every commenter who actually tagged enough people, then draw randomly from that pool.
function eligibleEntrants(comments, minTags = 3) {
const entrants = new Map(); // de-dupe by username
for (const c of comments) {
const mentions = (c.text.match(/@[a-zA-Z0-9._]+/g) || []).filter(
(m) => m.toLowerCase() !== "@",
);
const uniqueMentions = new Set(mentions.map((m) => m.toLowerCase()));
if (uniqueMentions.size >= minTags) {
entrants.set(c.user.username, uniqueMentions.size);
}
}
return [...entrants.keys()];
}
function pickWinner(entrants) {
return entrants[Math.floor(Math.random() * entrants.length)];
}
const comments = await getComments("https://www.instagram.com/p/Cz123abc/");
const pool = eligibleEntrants(comments, 3);
console.log(`${pool.length} valid entries`);
console.log("Winner:", pickWinner(pool));
De-duplicating by username matters — people comment multiple times to boost their odds, and counting each person once keeps the draw honest. You now have a transparent, reproducible winner instead of "trust me, we picked fairly."
Use case 2: Sentiment on a launch
Want to know how people reacted to a competitor's product drop? Pull the comments on the announcement post and score them. Here's a simple Python version (swap the naive keyword check for a real model when you're ready):
import os, requests
API_KEY = os.environ["SOCIAVAULT_API_KEY"]
BASE = "https://api.sociavault.com/v1"
def get_comments(post_url, cursor=None):
params = {"url": post_url}
if cursor:
params["cursor"] = cursor
r = requests.get(f"{BASE}/scrape/instagram/comments",
params=params, headers={"x-api-key": API_KEY}).json()
return r.get("data", {})
POSITIVE = {"love", "amazing", "🔥", "want", "need", "obsessed", "perfect"}
NEGATIVE = {"ugly", "overpriced", "scam", "disappointed", "meh", "worst"}
def quick_sentiment(comments):
pos = neg = 0
for c in comments:
text = c["text"].lower()
if any(w in text for w in POSITIVE): pos += 1
if any(w in text for w in NEGATIVE): neg += 1
return {"positive": pos, "negative": neg, "total": len(comments)}
data = get_comments("https://www.instagram.com/p/Cz123abc/")
print(quick_sentiment(data.get("comments", [])))
Even a rough pass tells you whether a launch landed or flopped before the sales numbers come in. For a serious analysis, feed the comment text into a proper sentiment model — the scraping part is identical, only the scoring changes.
Use case 3: Spam and bot detection
Mass-posted bot comments tend to share fingerprints: identical text across many accounts, fresh-looking usernames, link spam. Group by text and flag anything that repeats suspiciously:
function findSpam(comments) {
const byText = {};
for (const c of comments) {
const key = c.text.trim().toLowerCase();
(byText[key] ||= []).push(c.user.username);
}
// Same exact comment from many accounts = likely a bot ring
return Object.entries(byText)
.filter(([, users]) => users.length >= 5)
.map(([text, users]) => ({ text, count: users.length }));
}
Frequently Asked Questions
How do I export Instagram comments to a spreadsheet?
Pull the comments via the API (as shown above), then write them to CSV. Each comment gives you the text, author username, and timestamp — map those to columns and you have a spreadsheet-ready export. There's no native Instagram feature for this, which is why an API or scraper is the practical route.
Can you scrape comments from any Instagram post?
You can scrape comments from any public post or reel by passing its URL. Posts on private accounts aren't accessible — the same boundary applies to all social data: public content only, never private accounts.
How much does it cost to scrape comments?
With SociaVault it's 1 credit per request, and each request returns a page of comments. A post with a few hundred comments takes a handful of paged requests; a viral post with thousands takes more. You control the spend with a page cap in your code.
How do I pick a giveaway winner fairly?
Scrape all the comments, filter to entrants who met your rule (e.g. tagged 3 unique friends), de-duplicate by username so repeat commenters count once, then draw randomly from that pool. The code above does exactly this, giving you a transparent and reproducible result.
Can I get the email or profile of people who commented?
You get each commenter's public username, which you can then pass to the profile endpoint for more public details. You can't access private information like email unless the user published it publicly themselves. Scraping is limited to publicly visible data.
Is scraping Instagram comments allowed?
Reading public comments — content visible to anyone viewing the post — is standard practice for giveaways, research, and moderation. Stay on public posts, don't attempt to access private accounts or restricted data, and use the data responsibly.
Wrapping up
Comments are one of the richest public signals on Instagram, and exporting them turns "I think people liked it" into actual numbers — fair giveaway winners, sentiment scores, spam flags. The scraping is a few lines of code; what you do with the export is where the value is.
Ready to pull your first batch? Start free with SociaVault with 50 credits, or read the docs for the full endpoint reference.
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.