Tutorial · Instagram · cURL, Python, Node.js, PHP, Go, Ruby

Get likes, comments and views for 20 posts in one call

Like, comment and view counts for up to 20 posts in one call. Complete code for GET /v1/instagram/posts/stats in six languages and both official SDKs, each tested against the documented response.

Short answer. One call returns counts.likes, counts.comments and counts.views for 1 to 20 posts, passed as comma-separated shortcodes or ids in ids. The whole batch costs 1 credit.

Facts checked 2 December 2026. Prices change: follow the links before you decide.

Why call it

  • Refresh engagement on campaign posts for influencer reports without one call per post.
  • Track how a set of reels grows over hours or days for clipping and content teams.
  • Keep dashboards current by re-checking the counts of posts you already stored.

The request

GET https://api.handlehaul.com/v1/instagram/posts/stats with your key in the X-Api-Key header. Like, comment and view counts for up to 20 posts in one call. Like, comment and view counts for up to 20 posts in one call. 1 credit. Docs: https://api.handlehaul.com/docs/instagram-post-api

Parameters for Like, comment and view counts for up to 20 posts in one call
ParameterInDescription
ids requiredquery1 to 20 posts, comma-separated (shortcodes or ids).
freshquerytrue skips the cache (full price).

Code in 6 languages

Each sample is a complete program: it reads the key from HANDLEHAUL_API_KEY, waits and retries when the API answers 429 (using Retry-After), stops with the error code on anything else. The SDK versions do the retries for you.

instagram-post-stats.sh

# Like, comment and view counts for up to 20 posts in one call. --retry waits out a 429 using its Retry-After header;
# --fail exits with code 22 on any other error (drop it to read the error JSON).
curl -sS --fail --retry 3 -G "https://api.handlehaul.com/v1/instagram/posts/stats" \
  -H "X-Api-Key: $HANDLEHAUL_API_KEY" \
  --data-urlencode "ids=C9xYzAbCdEf,DCSf3TJ3gB7"
Generated from the OpenAPI spec (2026-12-02); every sample was syntax-checked and run against a local mock serving the response below. Language guides: Python, Node.js, PHP, Go, Ruby, cURL.

Response

A list in data, and meta with what the call cost. Example values; mediastats rows: id, shortcode and counts of the post sample, from the API docs. Lists are cut to two rows here.

200 · application/json
{
  "data": [
    {
      "id": "3500000000000000123",
      "shortcode": "DCSf3TJ3gB7",
      "counts": {
        "likes": 915,
        "comments": 148,
        "views": null
      }
    }
  ],
  "meta": {
    "request_id": "req_…",
    "cached": false,
    "cache_age_seconds": 0,
    "credits_charged": 1,
    "credits_remaining": 26943
  }
}

Cost, cache and limits

  • 1 credit per call, for up to 20 posts. At $1.40 to $0.80 per 1,000 calls. Cache hits, failed calls and 429 answers are free; meta.credits_charged says what each call cost.
  • Cache. Identical calls that arrive while an answer is cached are served from it. Add fresh=true to force a live call (billed).
  • Speed. Over your plan's requests-per-second limit the API answers 429 rate_limited with Retry-After; the samples wait that long and retry.
  • Testing. A kd_test_ key returns sample data in this exact shape at no cost, so you can run the code before you spend anything.

Things to know

  • ids takes 1 to 20 values, comma-separated shortcodes or numeric ids. Split longer lists into batches of 20.
  • Each row has only id, shortcode and counts. Call the post route for caption, owner or media.
  • counts.views is null on photos. Match rows back to your list by shortcode or id.

Next steps

Instagram post stats (batch) API: questions

How do I track likes on many Instagram posts at once?
Call GET /v1/instagram/posts/stats?ids=a,b,c with up to 20 posts: one call, one credit, the like, comment and view counts of each.
How many posts can one stats call check?
Up to 20, as a comma-separated list of shortcodes or ids in ids. Send more than 20 as several calls.

Run it on real data

One key for Instagram and TikTok. $1.40 to $0.80 per 1,000 calls; failed calls and cache hits are free.

Want to test first? Sandbox keys are free and unlimited, with sample data in the live schema.