Solutions

Instagram Giveaway Comments

Give your giveaway tool a public Instagram post or Reel URL. Collect visible top-level comments in recent-first order, then apply your own entry rules to the exported IDs and timestamps.

$0.0004 per request ($0.40 per 1,000), flat. Only successful calls are billed.

Endpoints

curl --request GET \
  --url 'https://api.herascrape.com/posts/B4XpqViUFUI/comments?sort=recent' \
  --header "x-api-key: $HERASCRAPE_KEY"
Response
{
  "status": "success",
  "data": {
    "comments": [{ "pk": "18012345678901234", "text": "Count me in!", "created_at": 1699999999 }],
    "has_more": true,
    "next_min_id": "eyJzZXJ2ZXJfY3Vyc29yIjo..."
  }
}

Collect visible giveaway comments

Try a public post or Reel from a completed giveaway. Save the example as giveaway.py and run it with your HeraScrape key set as HERASCRAPE_KEY. It exports comment IDs and text as JSON.

Python
import json
import os
import sys
from urllib.parse import quote, urlencode
from urllib.request import Request, urlopen
from urllib.parse import urlsplit

API = "https://api.herascrape.com"
KEY = os.environ["HERASCRAPE_KEY"]


def get(path, **params):
    query = "?" + urlencode(params) if params else ""
    request = Request(API + path + query, headers={"x-api-key": KEY})
    with urlopen(request, timeout=30) as response:
        return json.load(response)["data"]


if len(sys.argv) < 2:
    sys.exit('Usage: python3 giveaway.py "PUBLIC_INSTAGRAM_POST_URL" [PAGES]')

post_url = urlsplit(sys.argv[1])
parts = post_url.path.strip("/").split("/")
if (
    post_url.scheme not in {"https", "http"}
    or post_url.hostname not in {"instagram.com", "www.instagram.com"}
    or len(parts) != 2
    or parts[0] not in {"p", "reel"}
    or not parts[1]
):
    sys.exit("Use a public instagram.com/p/... or instagram.com/reel/... URL.")

max_pages = int(sys.argv[2]) if len(sys.argv) > 2 else 3
if max_pages < 1:
    sys.exit("Page limit must be at least 1.")

path = "/posts/" + quote(parts[1], safe="") + "/comments"
comments = {}
params = {"sort": "recent"}
cursors = set()
has_more = False
for _ in range(max_pages):
    page = get(path, **params)
    for comment in page["comments"]:
        comments[str(comment["pk"])] = {
            "id": str(comment["pk"]),
            "text": comment["text"],
            "created_at": comment.get("created_at"),
        }
    has_more = page["has_more"]
    if not has_more:
        break
    cursor = page.get("next_min_id")
    if not cursor or cursor in cursors:
        sys.exit("Comment pagination could not continue. Retry the export.")
    cursors.add(cursor)
    params["min_id"] = cursor

result = {"comments": list(comments.values()), "has_more": has_more}
print(json.dumps(result, indent=2))
Run
python3 giveaway.py "YOUR_PUBLIC_POST_URL" 3
  • The last argument caps billable comment pages. If has_more is true, raise the cap for a longer export.
  • The output contains visible top-level comments. Instagram may withhold comments that still count toward the post total. Replies use a separate endpoint, and your application handles eligibility and winner selection.