Instagram · Guide

How to scrape Instagram comments with an API

To scrape Instagram comments, send the post or Reel URL to one endpoint, then follow nextCursor while it is set. This guide shows the request, a real response and what to do on errors.

TL;DR
GET /v1/instagram/comments with url and limit (1–500, default 10). You pay 0.9 credits per comment returned, rounded up, with a 2-credit minimum. De-duplicate by comment id when you page.

1. Send the request

Create a free account (100 credits, no card), copy the key from the dashboard and export it as CAPTAPI_KEY. The only required parameter is url, the link of a public post or Reel.

Get five comments from one post

curl -G "https://api.captapi.com/v1/instagram/comments" \
  --data-urlencode "url=https://www.instagram.com/p/DZFqdAxlkUG/" \
  --data-urlencode "limit=5" \
  -H "Authorization: Bearer $CAPTAPI_KEY"

2. Read the response

This is a real response from 22 November 2026, trimmed to two of its five comments. That call cost 5 credits. We masked user names and ids, shortened the cursor, and left out avatar URLs and timing data.

200 OK

{
  "success": true,
  "data": {
    "platform": "instagram",
    "url": "https://www.instagram.com/p/DZFqdAxlkUG/",
    "requested": 5,
    "totalReturned": 5,
    "totalAvailable": 1127,
    "hasMore": true,
    "nextCursor": "<opaque cursor, shortened>",
    "comments": [
      {
        "id": "<comment-id-1>",
        "text": "😂",
        "author": "<username-1>",
        "authorId": "<user-id-1>",
        "authorIsVerified": true,
        "likeCount": 0,
        "publishedAt": "2026-06-03T16:49:03.000Z",
        "replyCount": 0
      },
      {
        "id": "<comment-id-2>",
        "text": "goodness gracious… somebody’s aunt made that costume and she certainly did try",
        "author": "<username-2>",
        "authorId": "<user-id-2>",
        "authorIsVerified": false,
        "likeCount": 558,
        "publishedAt": "2026-06-03T19:26:35.000Z",
        "replyCount": 11
      }
    ],
    "source": "native",
    "fetchedAt": "2026-11-22T19:22:39.392Z",
    "cached": false
  }
}
  • totalReturned counts the comments in this response. totalAvailable is the post's own comment count when Instagram exposes it; it is not a promise that every one can be fetched.
  • likeCount, publishedAt and replyCount can be missing or null when Instagram does not provide them, so read them with a default.
  • publishedAt is an ISO 8601 time in UTC.

3. Page through the comments

Send nextCursor back as cursor, with the same url and limit. Treat the cursor as opaque.

Pages are not exact slices. A page can repeat comments from the one before it, and with a small limit the next page can skip some, so ask for as many as you need in one call, keep a set of ids, and stop when a page adds nothing new. Repeated comments are still billed as returned rows.

Collect unique comments with a page cap

import os
import time

import requests

API = "https://api.captapi.com/v1/instagram/comments"
HEADERS = {"Authorization": f"Bearer {os.environ['CAPTAPI_KEY']}"}


def get_page(params, attempts=4):
    for attempt in range(1, attempts + 1):
        res = requests.get(API, params=params, headers=HEADERS, timeout=150)
        body = res.json()
        if res.ok:
            return body["data"]
        error = body["error"]
        if not error["retryable"] or attempt == attempts:
            raise RuntimeError(f"{res.status_code} {error['code']}: {error['message']}")
        time.sleep(int(res.headers.get("Retry-After", "30")))


def scrape_comments(url, limit=100, max_pages=3):
    params = {"url": url, "limit": limit}
    seen = {}
    for _ in range(max_pages):
        data = get_page(params)
        before = len(seen)
        for comment in data["comments"]:
            seen[comment["id"]] = comment
        if not data.get("nextCursor") or len(seen) == before:
            break
        params["cursor"] = data["nextCursor"]
    return list(seen.values())


comments = scrape_comments("https://www.instagram.com/p/DZFqdAxlkUG/")
print(len(comments), "unique comments")
  • nextCursor set: there is another page to request.
  • hasMore true and nextCursor null: more comments exist but cannot be paged. truncatedReason says why. Do not loop on hasMore alone.
  • hasMore false: there is nothing more to fetch.

Choose the parameters

ParameterDefaultWhen to change it
urlrequiredThe post or Reel link. A profile link is refused.
limit10Raise it to get more comments in one call, which also avoids gaps between pages.
sortpopularUse recent for newest first. Keep the same sort on every page; recent can fail more often.
minLengthnoneDrop short comments. With minLengthMode=letters, emoji, spaces and punctuation are not counted.
skipEmojiOnlyfalseSet true to leave out comments with no letter or digit.
cachefalseSet true when a result up to 24 hours old is good enough; a cache hit costs 0 credits.

Export Instagram comments to CSV

For a spreadsheet or a labelling job, write only the columns you need. This example keeps the text, time and like count and leaves out who wrote each comment, which is enough for most sentiment and topic work. A spreadsheet can run a cell that starts with =, +, - or @ as a formula, so the script puts an apostrophe in front of those.

Write one call to comments.csv

import csv
import os
import time

import requests

API = "https://api.captapi.com/v1/instagram/comments"
HEADERS = {"Authorization": f"Bearer {os.environ['CAPTAPI_KEY']}"}


def get_page(params, attempts=4):
    for attempt in range(1, attempts + 1):
        res = requests.get(API, params=params, headers=HEADERS, timeout=150)
        body = res.json()
        if res.ok:
            return body["data"]
        error = body["error"]
        if not error["retryable"] or attempt == attempts:
            raise RuntimeError(f"{res.status_code} {error['code']}: {error['message']}")
        time.sleep(int(res.headers.get("Retry-After", "30")))


data = get_page({"url": "https://www.instagram.com/p/DZFqdAxlkUG/", "limit": 50})
with open("comments.csv", "w", newline="", encoding="utf-8") as file:
    out = csv.writer(file)
    out.writerow(["publishedAt", "likeCount", "text"])
    for comment in data["comments"]:
        text = comment["text"]
        if text.startswith(("=", "+", "-", "@")):
            text = "'" + text
        out.writerow([comment.get("publishedAt"), comment.get("likeCount"), text])

4. Handle errors and retryable

Every error has the same body: success is false and error holds code, message and retryable. Retry only when retryable is true, wait for the Retry-After header, and cap the attempts. Failed requests cost 0 credits.

Statuserror.coderetryableWhat to do
400WRONG_RESOURCE_TYPE or BAD_REQUESTfalseSend a post or Reel URL, not a profile or another platform's link.
401UNAUTHORIZEDfalseCheck the API key.
402insufficient_creditsfalseYour balance must cover the full limit before the call runs. Lower limit or add credits.
404NOT_FOUNDfalseThe post is gone or is not public.
422VALIDATION_ERRORfalseKeep limit between 1 and 500.
429rate_limit_exceededtrueYou passed your plan's per-minute limit. Wait for Retry-After.
502UPSTREAM_UNAVAILABLEtrueNo comments could be read in time. Retry later.
503SESSION_UNAVAILABLEtrueOnly a short preview was available, so nothing was billed. Retry after the header's delay.

Limits and cost

  • limit goes up to 500, and a call can return fewer.
  • 100 returned comments cost 90 credits. One or two comments cost 2. An empty result costs 0.
  • cache=true can return a response up to 24 hours old for 0 credits. The default is a fresh read.
  • A call can take up to 110 seconds before it fails, so set the client timeout above that.
  • Only comments on public posts are covered. Private accounts and direct messages are not.

Responsible use

Captapi returns publicly available data only. You are responsible for how you use it and for complying with applicable laws and each platform's terms.

Comments are personal data in many countries. Keep only the fields you need, set a deletion date, honour deletion requests, and don't use the data to profile, contact or harass the people who wrote them.

Sources: Instagram Terms of Use

Frequently asked questions

Can I scrape Instagram comments with Python?

Yes. Send a GET request with the requests library to /v1/instagram/comments with the post or Reel URL and your Captapi key. The comments are in data.comments.

How many Instagram comments can I get per call?

Up to 500 with limit, though a call can return fewer. To go further, pass nextCursor back as cursor while it is set.

Why do I see the same comment on two pages?

Pages can overlap. De-duplicate by comment id and stop when a page adds no new ids.

Do comment replies come back too?

Each comment carries replyCount when Instagram provides it. Don't treat a page as a complete reply tree.

How much does it cost to scrape 1,000 Instagram comments?

900 credits for 1,000 returned comments, at 0.9 credits each. Repeated rows count, and a post may expose fewer comments than its counter shows.

Plans and credit packs are on the pricing page. Every parameter and field is on the Instagram Post Comments API page.