DEV Community

Cover image for How to Scrape Instagram Comments in Python Without Logging In (2026 Guide)
Azzam
Azzam

Posted on

How to Scrape Instagram Comments in Python Without Logging In (2026 Guide)

You have a few Instagram posts and you want every comment under them in a spreadsheet: username, text, likes and date. Maybe it's a giveaway, maybe a client wants to know what people said about a launch. This guide shows how to scrape Instagram comments in Python without an Instagram account, using a hosted Instagram comment scraper on Apify.

Quick start

Install the client:

pip install apify-client
Enter fullscreen mode Exit fullscreen mode

Then run this with your Apify API token:

import csv
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("automly/instagram-comments-scraper").call(run_input={
    "postUrls": [
        "https://www.instagram.com/p/DdG4RIxIPyf/",
        "https://www.instagram.com/reel/DdHyaYAifb6/",
    ],
    "resultsPerPost": 500,
})

comments = list(client.dataset(run["defaultDatasetId"]).iterate_items())

with open("instagram_comments.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.DictWriter(
        f,
        fieldnames=["postUrl", "ownerUsername", "text", "likes", "createdAt"],
        extrasaction="ignore",
    )
    writer.writeheader()
    writer.writerows(comments)

print(f"Saved {len(comments)} comments")
Enter fullscreen mode Exit fullscreen mode

That's the whole thing. You get up to 500 comments from each post, newest first, in instagram_comments.csv. No Instagram login, cookies or Meta developer app.

Why not the official API?

Meta does have an Instagram API, and if you only need comments on posts from accounts you manage, it's a fine choice. For anyone else's posts it doesn't help much.

Option Access needed Cost What you get
Instagram API, /comments edge An Instagram professional (Business or Creator) account, a token from the user who created the post, instagram_business_basic + instagram_business_manage_comments permissions. App Review and Business Verification for accounts you don't own or manage No fee listed by Meta Comments on your own media. Up to 50 per query, top-level only by default, no date filter
Business Discovery Your own professional account and a Meta app No fee listed by Meta Follower count, media count and comments_count for other professional accounts. Not the comment text, and age-gated accounts return nothing
Instagram Basic Display API n/a n/a Shut down on 4 December 2024
Instagram Comments Scraper An Apify account $0.40 per 1,000 comments Comments on any public post or reel, with likes, date and commenter

So the official route gives you comment counts for other accounts, and comment text only for your own. If the posts belong to someone else, you need a different tool.

Step 1: Get an Apify token

Create a free account at apify.com (no credit card). Your token is in Apify Console under Settings > API & Integrations. Put it in an environment variable rather than in your code:

import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
Enter fullscreen mode Exit fullscreen mode

Step 2: Collect the post links

postUrls takes post links (https://www.instagram.com/p/...) and reel links (https://www.instagram.com/reel/...). Links copied from the app with extra parameters on the end work too. You can pass as many as you want in one run, and every comment row tells you which post it belongs to.

Step 3: Choose how many comments

resultsPerPost is the most comments to get from each post. The default is 100 and it goes up to 100,000. Comments come newest first, and the scraper stops when it has that many or the post runs out.

One thing to know before you compare numbers: the count Instagram shows on a post includes replies to comments. This scraper collects the comments themselves, not the replies under them, so you'll usually get fewer rows than the number on the post.

Step 4: Only get new comments

This one matters when you follow a post over several days: without it, every run pays again for comments you already have. commentsPostedAfter keeps only comments posted on or after a date (UTC if you don't give an offset):

run_input = {
    "postUrls": ["https://www.instagram.com/p/DdG4RIxIPyf/"],
    "resultsPerPost": 10000,
    "commentsPostedAfter": "2026-10-01",
}
Enter fullscreen mode Exit fullscreen mode

It also takes a time, like 2026-10-01T12:00:00Z. Because comments arrive newest first, the run stops as soon as it reaches older ones.

Step 5: Read the output

Each row is one comment. Here's a trimmed one (names changed):

{
  "id": "17995635840044270",
  "text": "Amazing shot!",
  "createdAt": "2026-10-02T10:24:54Z",
  "likes": 3,
  "ownerUsername": "travel.with.jane",
  "ownerId": "1234567890",
  "ownerVerified": false,
  "ownerProfilePicUrl": "https://scontent.cdninstagram.com/v/...jpg",
  "postShortCode": "DdG4RIxIPyf",
  "postId": "3983118388705688735",
  "postUrl": "https://www.instagram.com/p/DdG4RIxIPyf/",
  "source": "https://www.instagram.com/p/DdG4RIxIPyf/",
  "fetchedAt": "2026-10-02T10:31:42Z"
}
Enter fullscreen mode Exit fullscreen mode

source is the exact link you passed in, and postUrl and postShortCode identify the post. If you'd rather work in pandas, the same list goes straight into a DataFrame:

import pandas as pd

df = pd.DataFrame(comments)
df["createdAt"] = pd.to_datetime(df["createdAt"])
df.to_excel("instagram_comments.xlsx", index=False)
print(df.groupby("postShortCode")["likes"].sum())
Enter fullscreen mode Exit fullscreen mode

What else can you scrape?

Most comment jobs start before the comments: you need to find the posts, or you want to know more about who wrote them.

Scaling up

Put all your links in one run instead of starting a run per post. In my test, 30 posts gave 6,000 comments in 41 seconds.

For monitoring, save the input as a task in Apify Console, add a daily schedule, and move commentsPostedAfter forward each time (or set it from your own code before calling). Results can go to Google Sheets, Slack, Make or Zapier through Apify integrations.

Each run also saves a short report: how many posts and comments it covered, and any link it couldn't scrape with the reason, such as a deleted or private post. Read it from Python:

store = client.key_value_store(run["defaultKeyValueStoreId"])
report = store.get_record("report-summary")
print(report["value"])
Enter fullscreen mode Exit fullscreen mode

You can also set a maximum cost on a run in Console, and the run stops when it reaches it.

No code? Use the Console

  1. Open Instagram Comments Scraper and click Try for free.
  2. Paste post or reel links into Post or reel URLs, one per line.
  3. Set Comments per post and, if you want, Comments posted after.
  4. Click Start, then export the Instagram comments as CSV, Excel, JSON, HTML or XML.

What it costs

You pay per comment you get: $0.40 per 1,000 comments, the same on every Apify plan, plus $0.00005 when a run starts. 10,000 comments cost about $4. Every Apify account gets $5 of free usage each month, which covers roughly 12,000 comments at that price.

Responsible use

Only scrape public posts, and only for a real reason. Comments can contain personal data that laws like GDPR and CCPA protect, so follow Instagram's terms and ask a lawyer if you're not sure. The tool isn't affiliated with Instagram or Meta.

Links

If you need Instagram comments for more than a handful of posts, try Instagram Comments Scraper on Apify. The free monthly credit is enough to see if it fits.

Top comments (0)