herascrape
Getting started

Pagination

One opaque cursor, one list shape, one page per call.

Instagram paginates almost every list differently: an integer offset here, a base64 blob there, a compound key-plus-page somewhere else. herascrape hides most of it behind a single cursor.

The list shape

Most list endpoints return the same three fields in data:

{
  "status": "success",
  "data": {
    "items": [],
    "next_cursor": "eyJtYXhfaWQiOiIyNSJ9",
    "has_more": true
  }
}
FieldMeaning
itemsThis page's objects, exactly as Instagram returned them.
next_cursorPass back as ?cursor= for the next page. null on the last page.
has_morefalse means you have reached the end. Stop.

The loop

cursor = None
while True:
    params = {"cursor": cursor} if cursor else {}
    page = http.get(f"/users/{user_id}/followers", params=params).json()["data"]
    handle(page["items"])
    if not page["has_more"]:
        break
    cursor = page["next_cursor"]

Branch on has_more, not on whether items is empty. Instagram occasionally returns a short or empty page mid-sequence and still has more to give.

The cursor is opaque

Pass it back verbatim. Never parse, build or edit one, and do not reuse a cursor from one endpoint on another. A cursor that does not decode returns 400 invalid_cursor; a foreign or edited one may decode and silently return the wrong page. Search cursors are bound to their endpoint and always rejected elsewhere.

Search cursors have one extra continuity rule. For /search/users, /search/hashtags, /search/audio, and /search/top, repeat the exact query, search_session_id, and serp_session_id from page one; audio also repeats browse_session_id. The response's search_context echoes the normalized values. A changed query or ID, an endpoint swap, or a cursor issued before this contract returns 400 invalid_cursor; start a new search without a cursor instead.

One page per call

One request fetches one Instagram page. There is no limit parameter and no server-side aggregation, so N pages is always N calls. Page size is Instagram's choice and differs by endpoint. Measured on 2026-10-28: 25 for followers and following, 15 for comments, 9 for a profile's posts.

Follower and following lists come back reshuffled on every request, so one full walk sees about 70-90% of the list; walk it again to collect the rest. Some business and verified accounts list only about 45-49 followers before has_more goes false. Both are Instagram's behaviour.

The endpoints with their own list shape

A few endpoints put Instagram's own response in data rather than the items list shape, because reshaping them would mean discarding structure the payload carries. They paginate on a token named in their own response, and their reference page says which one.

Two rules cover it. Take the paging token from the endpoint's own What comes back rather than assuming next_cursor, and never feed back a field just because its name looks like a cursor — a token the endpoint does not page on is ignored rather than rejected, so the same page returns forever while more_available stays true. We do not reject such parameters, so check the endpoint page before you loop.

Lists that never paginate

Some endpoints return everything at once and always report has_more: false with a null cursor — active stories, a highlights tray, a single reel's media, comment likers, and place search. The same loop works; it exits after one pass.

On this page