How to get Instagram comments with an API
Posts are published in English only. The rest of the site reads in ten languages; these do not, because a translated archive is one nobody keeps current.
Comments are the most requested thing we serve and the one people most often build subtly wrong. Here is the whole flow, then the three problems that show up a week later.
The flow
- POST the shortcode and a limit
- One call to the comments endpoint. It answers immediately with a 202 and a run id, not with comments — reading a page takes seconds rather than milliseconds, and an API that blocked for that long would be a worse API.
- Poll the run, or register a webhook once
- Polling is fine for a script. Webhooks are what you want on a schedule: a polling loop held open across thousands of runs is a lot of connections doing nothing.
- Read typed JSON
- Comment id, text, author username and id, timestamp, like count, and reply count where the platform exposes one. No HTML to parse and no platform-shaped envelope to unwrap. Replies are their own endpoint, because a thread's replies page independently.
Trap one: the counts will not match
The count shown on a post and the number you can retrieve rarely agree, and the gap is not a bug. Instagram hides comments from blocked accounts, filters some by region, collapses others behind moderation, and counts replies in the total on some surfaces and not others. Build for the number you got rather than the number displayed. A pipeline that retries until they match will retry forever.
Trap two: pagination is not stable
Ordering shifts while you page, because new comments arrive and moderation moves things. Ask for three pages of a busy post and you will get some duplicates and miss a few. Deduplicate on comment id rather than assuming pages are disjoint. For a genuinely complete snapshot of a busy thread, ask for it in one larger request rather than several small ones.
Trap three: this is personal data
Comment authors are people. The comments are public, but a stored database of who said what carries obligations in most jurisdictions: a lawful basis, a retention period, and an answer if somebody asks what you hold. Decide those before you build the table. Most analysis needs the text and the timestamp far more than a permanent record of the username, and storing less is the cheapest compliance decision available.
What it costs
You set the limit and are billed for what actually comes back. TikTok, YouTube and Snapchat use the same route, the same polling loop and the same response structure — a different platform in the path.
Questions people ask
Can I get Instagram comments without logging in?
Why do I get fewer comments than the post says it has?
How do I get replies to a comment?
Is storing Instagram comments GDPR-relevant?
Try it on your own targets
The only comparison that settles anything is your own. A new account gets 1,000 credits, needs no card, and runs on the same endpoints and rate as a paying one.