Skip to main content

Instagram comments API

GET /ig/media/comments/{pk|shortcode} · GetSocialAPI

Comments of a media, with full pagination via the min_id cursor.

Request​

ParameterInRequiredDescription
pkpathyesNumeric media id, or the post shortcode from its URL (e.g. Deu3BoCBbDP)
countquerynoPage size, 1–50 (values above 50 are rejected with 400). The real page holds ~12–20 comments regardless
sort_orderquerynorecent or ranked. Always pass recent for full pagination (see below)
min_idquerynoCursor from next_min_id of the previous response. Pass verbatim, URL-encoded — it is a long JSON string with +, `
Two rules of this endpoint
  1. Instagram never returns next_max_id here (always null) — the usual max_id pagination does not work. The only cursor is next_min_id in the response body.
  2. Without sort_order=recent the server returns a ranked preview (~15 comments) and pages fetched from different pool accounts overlap. With recent pages are strictly chronological (newer → older) and disjoint — concatenation of pages is the final order, no sorting needed.

Response​

Response example — click to expand (collapsed: one array item shown per array)
{
"can_view_more_preview_comments": false,
"caption": {
"bit_flags": 0,
"content_type": "comment",
"created_at": 1791993604,
"created_at_for_fb_app": 1791993604,
"created_at_utc": 1791993604,
"did_report_as_spam": false,
"is_covered": false,
"is_created_by_media_owner": true,
"is_ranked_comment": true,
"has_translation": true,
"media_id": 4007854180690832102,
"pk": "17978851976922109",
"private_reply_status": 0,
"share_enabled": true,
"status": "Active",
"strong_id__": "17978851976922109",
"text": "when dance meets Double Dutch 💃⁣\n⁣\n#InTheMoment⁣\n⁣\nVideo by @asuki_millecolle and @ikkyon_millecolle⁣\n⁣\nMusic by MagnusTheMagnus⁣\n⁣\nChoreography by @sangmyungdance",
"type": 1,
"user": {
"fbid_v2": 17841400039600391,
"full_name": "Instagram",
"id": "25025320",
"is_private": false,
"is_unpublished": false,
"is_verified": true,
"pk": 25025320,
"pk_id": "25025320",
"profile_pic_id": "3725434617063385984_25025320",
"profile_pic_url": "https://scontent-bcn1-1.cdninstagram.com/v/t51.82787-19/550891366_18667771684001321_1383210656577177067_n.jpg?stp=dst-jpg_e0_s150x150_tt6&_nc_cat=1&ig_cache_key=GGbv1SApFvlLPVJCAOtF0XrDJjITbmNDAQAB1501500j-ccb7-5&ccb=7-5&_nc_sid=669407&efg=eyJ2ZWJjb2RlX3RhZyI6InByb2ZpbGUtcGljLnd3dy4xMDgwLkMzIn0%3D&_nc_ohc=jrfX0ud5Bn8Q7kNvwFYwP1Z&_nc_oc=Adoj5DJR06Iyu-TxYkRwlbH9jbBRjJKqaCUNFpoYYMgwZKl21YUPX6dLx9Y4GmqLlo&_nc_ad=z-m&_nc_cid=3033&_nc_zt=24&_nc_ht=scontent-bcn1-1.cdninstagram.com&_nc_gid=lG8I_SNM-6K1ivQDKUDFJw&_nc_ss=7c3ba&oh=00_AQP9KA4Zukignoml-YV44guX-Gjmfofg-IcZ7INTpC3qHQ&oe=6AD80B27",
"strong_id__": "25025320",
"username": "instagram"
},
"user_id": 25025320
},
"caption_is_edited": false,
"comment_count": 9370,
"comment_cover_pos": "bottom",
"comment_filter_param": "no_filter",
"comment_likes_enabled": true,
"comments": [
{
"bit_flags": 0,
"child_comment_count": 1,
"comment_index": 0,
"comment_like_count": 30,
"content_type": "comment",
"created_at": 1792032082,
"created_at_for_fb_app": 1792032082,
"created_at_utc": 1792032082,
"did_report_as_spam": false,
"has_liked_comment": false,
"has_disliked_comment": false,
"has_more_head_child_comments": true,
"has_more_tail_child_comments": false,
"has_translation": true,
"inline_composer_display_condition": "never",
"is_covered": false,
"is_photo_comments_enabled_for_comment_author": false,
"is_text_editable": false,
"is_edited": false,
"meta_ai_comment_type": "NONE",
"is_ranked_comment": true,
"keywords_data": [],
"liked_by_media_coauthors": [],
"other_preview_users": [],
"media_id": 4007854180690832102,
"num_head_child_comments": 1,
"pk": "18352635277266062",
"preview_child_comments": [],
"private_reply_status": 0,
"share_enabled": true,
"status": "Active",
"strong_id__": "18352635277266062",
"text": "Excellent 👌👌🔥🔥",
"type": 0,
"user": {
"fbid_v2": 17841427866344219,
"full_name": "Kajal Dubey",
"id": "27873752878",
"is_mentionable": true,
"is_private": false,
"is_verified": false,
"latest_reel_media": 1792119390,
"pk": 27873752878,
"pk_id": "27873752878",
"profile_pic_id": "3978532103600131336_27873752878",
"profile_pic_url": "https://scontent-bcn1-1.cdninstagram.com/v/t51.82787-19/792909884_18120152086928879_6040443973252350336_n.jpg?stp=dst-jpg_e0_s150x150_tt6&_nc_cat=111&ig_cache_key=GDzYQi-v3Wqs7mBAAIABWz-K99NTbmNDAQAB1501500j-ccb7-5&_nc_sid=669407&efg=eyJ2ZWJjb2RlX3RhZyI6InByb2ZpbGUtcGljLnd3dy4xMDgwLkMzIn0%3D&_nc_ohc=C0cc4QxSYfoQ7kNvwEa2RPy&_nc_oc=Adogpe1tTgGm9ecssYmsiDXE8RsYNeV-mOLR3dvbrQbz9DAfGIXoUX7dTR5uwxiY&_nc_ad=z-m&_nc_cid=3033&_nc_zt=24&_nc_ht=scontent-bcn1-1.cdninstagram.com&_nc_gid=lG8I_SNM-6K1ivQDKUDFJw&_nc_ss=7c3ba&oh=00_AQMU-lsIwtKBLQwFo5o1T_6P28KG7dtm1IxUokBE3EkzCQ&oe=6AD80F02",
"strong_id__": "27873752878",
"username": "kajaldubey_ayodhya",
"aigm_account_label_info": {
"is_enabled": false,
"is_auto_detected": false,
"is_manually_enabled": false
},
"qe_use_smaller_comment_like_tap_target": false
},
"user_id": 27873752878
}
],
"has_more_comments": false,
"has_more_headload_comments": true,
"initiate_at_top": true,
"insert_new_comment_to_top": true,
"is_ranked": true,
"liked_by_media_owner_badge_enabled": true,
"media_header_display": "none",
"next_min_id": "{\"cached_comments_cursor\":\"18070014281759690\",\"bifilter_token\":\"GgYYiQEAmmCh8cRbQABvQsrQ2PQ_AI7MZOKfM0EAWRZapKBuQAAar7C_Vrs_AL7miZskqz8ASeyX3yFMQABMJjBNfF1AAInula6JXkAA7-LKhiHlPwCjgLel501AAH3PfBg-L0AA4Yp-B6SKQADeavYzl7xAAKzw3WvuaEAAtLdOeBR-PwBezZNLLGhAAAA=\"}",
"quick_response_emojis": [
{
"unicode": "❤️"
}
],
"scroll_behavior": 1,
"sort_order": "popular",
"threading_enabled": true,
"filter_options": [],
"sort_options": [],
"should_render_upsell": false,
"foundation_improvements_enabled": true,
"geoblocked_comment_notices": [],
"has_more_headload_fb_comments": false,
"fb_comments": [],
"ai_topic_filters": [],
"status": "ok"
}

Key fields​

FieldDescription
comments[]Comments of the page: pk, text, created_at, user.username, comment_like_count, child_comment_count (replies in the thread), preview_child_comments[] (first 1–2 replies)
next_min_idCursor of the next page — a JSON string with cached_comments_cursor + bifilter_token; pass back as min_id, URL-encoded, unmodified
comment_countTotal counter claimed by the post (includes replies and spam-hidden comments)
has_more_commentsContinuation flag

Collecting all comments​

import json, time, urllib.request, urllib.parse

API = "https://api.getsocialapi.com/v1"
KEY = "<API key>"

def api(path):
req = urllib.request.Request(f"{API}{path}",
headers={"X-API-Key": KEY})
return json.loads(urllib.request.urlopen(req, timeout=60).read())

def all_root_comments(pk):
roots, cursor = [], None
while True:
url = f"/ig/media/comments/{pk}?count=50&sort_order=recent"
if cursor:
url += "&min_id=" + urllib.parse.quote(cursor, safe="")
d = api(url)
batch = d.get("comments") or []
roots += batch
cursor = d.get("next_min_id")
if not cursor or not batch:
return roots # collected everything available
time.sleep(1.0) # stay ≤1 request/sec

roots = all_root_comments("4012386322294878415")
json.dump(roots, open("comments.json", "w"),
ensure_ascii=False, indent=1)
  • End condition: next_min_id is null/empty or comments is empty.
  • Dedupe by comment["pk"] as a safety net — with recent there should be no duplicates.
  • The concatenation of pages is already the final order (newer → older); nothing to sort.
  • Python SDK: client.instagram.media_comments(pk, count, sort_order, min_id) — cursor handled per call.

Limits and behavior​

  • The sum of collected comments is usually less than comment_count: the remainder is hidden by the Instagram spam filter and is not served to regular accounts.
  • Pace: ~12–20 comments per page; a post with 300 root comments ≈ 20–25 requests.
  • Keep ≤1 request/sec (key RPS limit); on 429 pause 2–5 s and retry the same cursor.
  • Reply threads: child_comment_count and the first 1–2 replies in preview_child_comments are available per root comment; a full listing of a thread's replies is not served by this route.
note

The full list of comment likers is closed server-side — only comment_like_count is available.