Instagram Comments Scraper avatar

Instagram Comments Scraper

Pricing

from $5.00 / 1,000 results

Go to Apify Store
Instagram Comments Scraper

Instagram Comments Scraper

Scrape comments and replies from any Instagram post or reel. Paste post/reel URLs; get comment text, author, likes, reply count, timestamps and threading. Date-range filter, popular/newest ordering. Requires a session (cookies or automated login).

Pricing

from $5.00 / 1,000 results

Rating

0.0

(0)

Developer

code craker

code craker

Maintained by Community

Actor stats

0

Bookmarked

8

Total users

4

Monthly active users

2 days ago

Last modified

Categories

Features

Limited permissions

Share

Apify actor that scrapes comments — and optionally replies — from any Instagram post, reel or IGTV video and exports them as structured data.

A session is required. Instagram only serves comments to logged-in sessions. The actor authenticates the same way as the Instagram post search actor, in priority order:

  1. cookies input — a JSON cookie export from a logged-in browser (Cookie-Editor / EditThisCookie); the sessionid cookie carries the session
  2. IG_COOKIES secret env var on the actor (same JSON, or a name=value; ... string)
  3. the cached session in the instagram-session key-value store (needs full permissions)
  4. automated login with igUsername/igPassword (or IG_USERNAME/IG_PASSWORD)

Always use a throwaway account. Optionally set IG_PROXY_SESSION (e.g. igacct1) so the account keeps one exit IP across runs.

How it works

A real Chrome (Playwright) opens the first post once with the session — HTML document only, Instagram's scripts, styles and media are not downloaded — and verifies the session via /api/v1/media/{id}/info/ (owner, caption, comment count). Every post is then read through Instagram's comments API (/api/v1/media/{id}/comments/, next_min_id cursor) called from inside that logged-in page, with no further page loads. Reply threads come from /api/v1/media/{id}/comments/{commentId}/child_comments/ and are fetched right after their parent comment. If the comments API is unavailable for a post that has at least 25 comments, the actor falls back to loading the full page and collecting the comments it loads while scrolling.

Cost controls

The run stops collecting once the user's maximum charge for the run is reached, so no comments are scraped that cannot be charged for. It also tracks its own estimated platform cost (proxy traffic and compute) against what it has earned and stops early when the cost outgrows the earnings — for example a date-filtered scan of a long thread that matches almost nothing, or a long list of posts without comments. The thresholds are the constants at the top of src/main.js.

Shortcodes are decoded to media ids locally, so post, reel, IGTV, profile-scoped and share (?igsh=) links all work, as do bare shortcodes.

Input

{
"startUrls": [{ "url": "https://www.instagram.com/p/De9ZzxeAJ76/" }],
"postUrls": ["https://www.instagram.com/reel/DfXn6bByKOn/", "DexT0nAy7ok"],
"maxComments": 200,
"includeReplies": true,
"maxRepliesPerComment": 20,
"start_date": "2026-11-01",
"end_date": "2026-11-30",
"proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"], "apifyProxyCountry": "US" }
}
  • maxComments is per post; replies count toward it when includeReplies is on.
  • start_date / end_date (yyyy-mm-dd, inclusive, UTC) filter on each comment's time. Instagram's web API only returns comments in its relevance order (there is no newest-first option), so with a date filter the actor scans the thread and keeps only matching comments.
  • Aliases for compatibility: directUrls (= postUrls), resultsLimit (= maxComments), includeNestedComments (= includeReplies).
  • debug: true saves Instagram's responses, a screenshot and the HTML to the run's key-value store.

Output

One dataset item per comment:

{
"id": "18013753928992349",
"commentId": "18013753928992349",
"text": "This is amazing!! Would you ever consider ...",
"mentions": [],
"hashtags": [],
"date": "2026-10-26T18:44:09.000Z",
"timestamp": 1793040249,
"likesCount": 17,
"repliesCount": 1,
"isReply": false,
"parentCommentId": null,
"threadingDepth": 0,
"commentUrl": "https://www.instagram.com/p/De9ZzxeAJ76/c/18013753928992349/",
"isPinned": false,
"isLikedByPostOwner": false,
"isEdited": false,
"isHidden": false,
"isRankedComment": true,
"contentType": "comment",
"hasTranslation": false,
"author": {
"id": "123456", "username": "selah_studio_za", "fullName": "Selah Studio",
"profileUrl": "https://www.instagram.com/selah_studio_za/",
"profilePicUrl": "https://scontent.cdninstagram.com/...",
"isVerified": false, "isPrivate": false
},
"ownerId": "123456",
"ownerUsername": "selah_studio_za",
"ownerFullName": "Selah Studio",
"ownerProfileUrl": "https://www.instagram.com/selah_studio_za/",
"ownerProfilePicUrl": "https://scontent.cdninstagram.com/...",
"ownerIsVerified": false,
"postUrl": "https://www.instagram.com/p/De9ZzxeAJ76/",
"postId": "4016479951657148154",
"postShortcode": "De9ZzxeAJ76",
"postOwnerUsername": "mosseri",
"postCaption": "Sat down with @tessalyonsss ...",
"postCommentsCount": 2025,
"postCreatedAt": "2026-10-26T15:00:40.000Z",
"inputUrl": "https://www.instagram.com/p/De9ZzxeAJ76/",
"scrapedAt": "2026-11-06T09:33:46.826Z"
}

Replies have isReply: true, threadingDepth: 1 and parentCommentId set. isHidden marks comments Instagram covers as potentially offensive. GIF/sticker comments have an empty text. postCommentsCount is Instagram's count (it includes replies, and can exceed what is retrievable when comments are deleted or restricted).

Local development

npm install
mkdir -p storage/key_value_stores/default
cat > storage/key_value_stores/default/INPUT.json <<'JSON'
{ "postUrls": ["DexT0nAy7ok"], "maxComments": 30,
"cookies": [ ...exported from a logged-in browser... ],
"proxyConfiguration": { "useApifyProxy": false } }
JSON
npm start

Deploy with apify push.