Instagram Comments Scraper avatar

Instagram Comments Scraper

Pricing

from $2.00 / 1,000 results

Go to Apify Store
Instagram Comments Scraper

Instagram Comments Scraper

Scrape comments from public Instagram posts and reels: text, author, likes, time. Works without login for about 15 comments per post; add your own cookies to request more comments and replies.

Pricing

from $2.00 / 1,000 results

Rating

5.0

(1)

Developer

Muhammad Noman Riaz

Muhammad Noman Riaz

Maintained by Community

Actor stats

2

Bookmarked

99

Total users

0

Monthly active users

14 days ago

Last modified

Share

Get the comments of public Instagram posts and reels: comment text, author username and ID, profile picture, likes, reply count and time posted.

Do you need cookies? No, not to start.

  • Without cookies you get the first page of top-level comments that Instagram shows to logged-out visitors, which is about 15 comments per post. Replies are not included.
  • With cookies from your own Instagram account the scraper can page through more comments and fetch replies (up to your limits).

What you get

FieldDescription
postUrlThe post or reel the comment belongs to
commentUrlDirect link to the comment
idComment ID
textComment text
ownerUsername, ownerProfilePicUrlWho wrote it
timestampWhen it was posted (ISO 8601)
likesCountLikes on the comment
repliesCount, repliesReply count and replies (replies only with cookies)
parentCommentIdOnly on replies
ownerAuthor details: id, username, is_verified, profile_pic_url; with cookies also full_name, fbid_v2, is_private

Example item:

{
"postUrl": "https://www.instagram.com/p/CJWTsUMjjiM/",
"commentUrl": "https://www.instagram.com/p/CJWTsUMjjiM/c/18030198328749378",
"id": "18030198328749378",
"text": "Amazing post!",
"ownerUsername": "user123",
"ownerProfilePicUrl": "https://...",
"timestamp": "2024-03-10T13:24:37.000Z",
"repliesCount": 0,
"replies": [],
"likesCount": 1,
"owner": {
"fbid_v2": "",
"full_name": "",
"id": "48544088177",
"is_mentionable": true,
"is_private": false,
"is_verified": false,
"latest_reel_media": 0,
"profile_pic_id": "573323465",
"profile_pic_url": "https://...",
"username": "user123"
}
}

Only posts that return comments are saved and charged. Posts that fail (removed, private, no comments, rejected cookies) are listed with the reason in FAILED_ITEMS in the run's key-value store.

Input

ParameterTypeDescriptionDefault
directUrlsArrayInstagram post or reel URLsRequired
resultsLimitIntegerMax comments per post (0 = no limit)50
includeRepliesBooleanInclude replies (needs cookies)true
maxRepliesPerCommentIntegerMax replies per comment10
cookiesArrayOptional Instagram cookies, see belowNone
proxyObjectProxy for runs without cookiesApify residential
{
"directUrls": [
"https://www.instagram.com/p/CJWTsUMjjiM/",
"https://www.instagram.com/reel/DDIJAfeyemG/"
],
"resultsLimit": 100,
"includeReplies": true,
"maxRepliesPerComment": 20
}

Without cookies the proxy matters: Instagram often shows a login wall to datacenter IPs, so residential proxies work best. With cookies, requests go out without the proxy so your account keeps one IP.

How to get your Instagram cookies

  1. Use a secondary Instagram account, not your main one. Scraping can get an account rate-limited or asked to verify itself.
  2. In Chrome or Edge, log in to that account at https://www.instagram.com.
  3. Press F12 to open developer tools.
  4. Open the Application tab, then Storage, then Cookies, then https://www.instagram.com.
  5. Copy the values of sessionid, ds_user_id and csrftoken.
  6. Put them in one line in this format: sessionid=...; ds_user_id=...; csrftoken=...
  7. Paste that line into the Instagram cookies field as a list item, for example ["sessionid=...; ds_user_id=...; csrftoken=..."].

Or, easier:

  1. Install the Cookie-Editor browser extension.
  2. Open https://www.instagram.com while logged in to your secondary account.
  3. Click the Cookie-Editor icon, then Export, then Export as JSON.
  4. Paste the result into the Instagram cookies field as is.

To rotate several accounts, add one entry per account, for example ["sessionid=...; ds_user_id=...; csrftoken=...", "sessionid=...; ds_user_id=...; csrftoken=..."], or a list of Cookie-Editor exports.

Good to know:

  • Cookies work like a password. Anyone who has them can act as that account. Only paste them into this field.
  • Apify stores this field encrypted, and the scraper never writes cookie values to the log.
  • Cookies expire. When that happens, log in again and copy them again.
  • Heavy use can rate-limit the account. Keep limits reasonable and spread work over several accounts.
  • To revoke them, change the account password, or in Instagram open Settings, Accounts Center, Password and security, Where you're logged in, and log out of all sessions.

FAQ

Do I need cookies?

No. Without cookies you get about 15 top-level comments per post and no replies. Add cookies when you need more comments or replies.

Why did my run fail with expired cookies?

The message "Your Instagram cookies expired or were rejected; refresh them" means Instagram answered with a login page, a 401, login_required or checkpoint_required. The session was logged out, expired or needs a security check. Log in to the account in your browser, clear any check Instagram shows, then copy fresh cookies. If you gave several sessions, the rejected one is dropped and the others keep working.

Is my account safe?

Use a secondary account. Instagram can rate-limit or challenge any account that loads many pages quickly, and that is outside this scraper's control. The cookies field is stored encrypted and its values are never logged.

How many comments can I get?

Without cookies, about 15 per post: the first page Instagram shows to logged-out visitors. With cookies, up to resultsLimit per post (0 means no limit), plus up to maxRepliesPerComment replies per comment.

Notes

  • Only comments on public posts and reels can be scraped.
  • Use the data in line with Instagram's terms and data protection laws (GDPR, CCPA and others).