SocialHolmes

How to get Instagram comments with an API

3 min read

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.

Instagram comments are the most requested thing we serve and the one where people most often build something subtly wrong. This is the whole flow, and then the three problems that show up a week later.

The request

A comment pull is one POST to the comments endpoint with the post's shortcode and a limit, and it answers immediately with a run id and a 202. It does not answer with comments, because reading a page takes seconds rather than milliseconds and an API that blocked for that long would be a worse API. You then either poll the run until it is terminal, or register a webhook once and let finished runs come to you. Polling is fine for a script; webhooks are what you want for anything running on a schedule, because a polling loop held open across thousands of runs is a lot of connections doing nothing.

What comes back

A list of comments, each with the comment id, the text, the author's username and id, the timestamp, the like count, and the reply count where the platform exposes one. Replies are a separate endpoint, because a thread's replies are paged independently and folding them into the parent would make the page size unpredictable. Every field is already extracted. There is no HTML to parse and no platform-shaped envelope to unwrap — that work has been done, which is most of what you are paying for.

Trap one: comment counts do not match

The count shown on a post and the number of comments you can actually retrieve rarely agree, and the gap is not a bug. Instagram hides comments from blocked accounts, filters some for the viewer's 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 the counts match will retry forever.

Trap two: pagination is not stable

Comment ordering shifts while you page through it, 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. If you need a genuinely complete snapshot of a busy thread, pull it in one larger request rather than several small ones — the window in which things move is what causes the drift.

Trap three: what you pull 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 rather than after. In practice most analysis needs the text and the timestamp far more than it needs a permanent record of the username, and storing less is the cheapest compliance decision available.

What it costs

$0.50 per thousand comments delivered. You set the limit and are billed for what actually comes back, so a post with forty comments costs forty comments even if you asked for four hundred, and a post whose comments are turned off costs nothing. The same shape works on TikTok, YouTube and Snapchat — same route, same polling loop, same response structure, different platform in the path.

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.