herascrape
API reference

Posts

A post by id or shortcode, its comments and its likers. Page every list until has_more is false; for a complete comment export use sort=recent, since the default sort=relevant is a ranked subset.

/posts/{id} accepts either the numeric media pk or the shortcode. The two are interconvertible, so there is no separate by-code or by-URL endpoint — pull the code out of an instagram.com/p/<code>/ URL and pass it straight in.

GET /posts/2168384974851429640     # pk
GET /posts/B4XpqViUFUI             # shortcode — same post

The post

One call returns the whole object, which is more than it looks. Instagram packs into it what other providers split across extra endpoints:

Looking forIt is already in /posts/{id}
Media file URLsimage_versions2, video_versions
Carousel childrencarousel_media
Reel audio / musicclips_metadata
Tagged accounts (photos)usertags
Collaboratorscoauthor_producers
Like and comment countslike_count, comment_count
Locationlocation

So there is no download, clips-metadata, usertags or comment-count endpoint: fetching the post gives you all of it for one call.

On video posts, usertags comes back empty — Instagram does not populate it for clips. Collaborators still surface in coauthor_producers, and caption mentions are in the caption text. If you need a clean tagged-users list for videos, tell us.

Path Parameters

post_id*Post Id
GET
/posts/{post_id}
curl -X GET "https://example.com/posts/string"
{
  "status": "success",
  "data": {}
}
{}

What comes back in data

Instagram's media object, roughly 240 top-level fields. Abridged:

{
  "pk": "2168384974851429640",
  "id": "2168384974851429640_25025320",
  "code": "B4XpqViUFUI",
  "taken_at": 1699999999,
  "media_type": 8,
  "product_type": "carousel_container",
  "caption": { "text": "A caption", "created_at": 1699999999,
               "user": { "pk": "25025320", "username": "instagram" } },
  "like_count": 120345,
  "comment_count": 892,
  "play_count": null,
  "user": { "pk": "25025320", "username": "instagram", "is_verified": true },
  "image_versions2": { "candidates": [{ "width": 1080, "height": 1350, "url": "..." }] },
  "video_versions": [],
  "carousel_media": [{ "pk": "...", "media_type": 1, "image_versions2": {} }],
  "usertags": { "in": [] },
  "coauthor_producers": [],
  "location": { "pk": "213385402", "name": "New York, New York", "lat": 40.7, "lng": -74.0 },
  "clips_metadata": null
}
FieldNote
media_type1 photo, 2 video, 8 carousel.
product_typefeed, clips (a reel), or carousel_container.
captionAn object, not a string. The text is caption.text, and it is null for an uncaptioned post.
image_versions2.candidatesSized variants, largest first.
video_versionsPresent on videos and reels; empty on photos.
carousel_mediaChild items, each with its own versions. Only on carousels.
clips_metadataReel audio and music. null unless product_type is clips.

URLs in image_versions2 and video_versions are signed and expire within hours. Download promptly rather than storing the URL.

Counts

GET /posts/counts?ids=2168384974851429640,2168384974851429641

Comment, like and play counts for up to 20 posts in one call — one billed request. Ids are comma-separated and may be shortcodes, bare pks or composite <pk>_<owner> pks. This is basic info only; fetch /posts/{id} for the full media object.

Query Parameters

ids*Ids

Up to 20 post ids (shortcode, bare or composite pk), comma-separated

GET
/posts/counts
curl -X GET "https://example.com/posts/counts?ids=string"
{
  "status": "success",
  "data": {}
}
{}

What comes back in data

{
  "items": [
    {
      "pk": "2168384974851429640",
      "id": "2168384974851429640_25025320",
      "code": "B4XpqViUFUI",
      "media_type": 1,
      "taken_at": 1699999999,
      "comment_count": 42,
      "like_count": 1200,
      "play_count": null
    }
  ]
}

play_count is null on photos. More than 20 ids returns invalid_parameter.

Comments

Pass only the post id (shortcode, bare or composite pk):

GET /posts/2168384974851429640/comments

A deleted or unavailable post returns not_found here — the same 404 as /posts/{id}, not a billed empty page.

This endpoint keeps Instagram's own comment-stream shape rather than the standard list shape, because its paging token is structural to the response:

{
  "comments": [],
  "has_more": true,
  "next_min_id": "...",
  "media_pk": "2168384974851429640_25025320",
  "...": "..."
}

Page by passing next_min_id back as min_id, and stop only when has_more is false — never on a short page. A 404 comes only from the first page; a later page Instagram fails to serve is retried for you and, if it still fails, answered with a retryable 503 upstream_unavailable. Instagram sometimes returns a page of a few comments mid-walk, and a client that stops there misses the rest. Treat next_min_id as opaque — pass back exactly what you were given.

Order the comments with sort: relevant (Instagram's default ranking, "For you"), recent (chronological, newest first), or meta_verified. The first request (the one without min_id) picks the order, and the cursor carries it for the rest of the walk. Sending sort again on later requests is harmless — the cursor's order wins, so a walk cannot switch order midway.

For a complete top-level export use sort=recent — it pages chronologically (newest first) with no repeats. The default sort=relevant is Instagram's ranked view: a bounded subset that can serve the same comment on more than one page, so dedupe by pk if you walk it. If a page brings only comments the walk has already returned, the walk ends there with has_more: false. An empty last page is retried on other sessions before the walk ends. Either way the declared comment_count is inflated — it counts deleted, hidden and spam-filtered comments Instagram now serves to no one — so expect only ~20–25% of it to be retrievable (the same ceiling every provider hits). comment_count also counts replies, which come from /comments/{id}/replies.

Instagram's own has_more_comments appears in this response and does not mean what it says: it tracks the inline preview strip, so it reads false on a post with thousands of comments. Branch on has_more above.

Replies are not included here — fetch them per comment through /comments/{id}/replies, which now walks the full reply thread rather than the short inline preview (minus any replies Instagram filters out).

For a carousel, carousel_media_id and carousel_index scope comments to one child.

Path Parameters

post_id*Post Id

Query Parameters

min_id?|

next_min_id from the previous page

max_id?|

Walk toward older comments

sort?|

Comment order: relevant (default ranked), recent (chronological, newest first), or meta_verified. Fixed for the walk — the cursor carries it.

carousel_media_id?string|null
carousel_index?Carousel Index
Default0
GET
/posts/{post_id}/comments
curl -X GET "https://example.com/posts/string/comments"
{
  "status": "success",
  "data": {}
}
{}

What comes back in data

{
  "comments": [
    {
      "pk": "18012345678901234",
      "text": "Great shot",
      "created_at": 1699999999,
      "comment_like_count": 12,
      "child_comment_count": 2,
      "is_liked_by_media_owner": false,
      "user_id": "51065942432",
      "user": { "pk": "51065942432", "username": "example" }
    }
  ],
  "next_min_id": "eyJzZXJ2ZXJfY3Vyc29yIjo...",
  "media_pk": "2168384974851429640_25025320",
  "has_more": true,
  "has_more_comments": true
}

child_comment_count is how many replies a comment has — fetch the full thread with /comments/{pk}/replies, passing the post id as media_id. Instagram omits deleted and hidden replies, so the thread can come back shorter than child_comment_count.

Likers

Keyed by the post id alone, like comments.

GET /posts/2168384974851429640/likers

The ranked likers Instagram surfaces for a post — a single page of ~100, has_more always false. For the complete list, use /posts/{id}/likers/all.

Path Parameters

post_id*Post Id
GET
/posts/{post_id}/likers
curl -X GET "https://example.com/posts/string/likers"
{
  "status": "success",
  "data": {}
}
{}

What comes back in data

The standard list shape, with compact user objects identical to followers.

All likers

GET /posts/2168384974851429640/likers/all

Every account that liked the post — the full chronological list in a single call, not the ranked ~100 above. Returns up to ~1,000–2,000: Instagram sets the ceiling itself on very high-engagement posts (there is no cursor to page past it), and below that ceiling the list is complete. Same flat price as any other call.

Path Parameters

post_id*Post Id
GET
/posts/{post_id}/likers/all
curl -X GET "https://example.com/posts/string/likers/all"
{
  "status": "success",
  "data": {}
}
{}

What comes back in data

The same list shape as likers above — compact user objects — just many more of them.

Insights

GET /posts/3752130627736173135/insights

A post's insight object: its like and comment counts, media type, creation time, and ad_media for a post that has run as a boosted ad. Accepts the same ids as the post.

Path Parameters

post_id*Post Id
GET
/posts/{post_id}/insights
curl -X GET "https://example.com/posts/string/insights"
{
  "status": "success",
  "data": {}
}
{}

What comes back in data

FieldMeaning
instagram_media_idThe post's media pk.
organic_instagram_media_idThe pk of the organic post.
instagram_media_typeThe media type, such as CAROUSEL_V2.
creation_timeUnix seconds.
like_count, comment_countThe post's counts. like_count can be null.
ad_mediaSet when the post has run as a boosted ad, null otherwise.
display_url, imagePreview image URL and its size.

save_count, inline_insights_node and the shopping click counts are visible only to the post's owner, so they are always null.

Errors

CodeWhen
not_foundDeleted, or no such pk or shortcode.
private_accountThe owner is private.
invalid_parameterThe id is neither a valid pk nor a valid shortcode.
unprocessable_entityA query parameter has the wrong type, such as a non-integer carousel_index.
upstream_errorTransient. Retry.

On this page