How do I compare engagement changes between two observations of an Instagram campaign post?
To measure how engagement on an Instagram campaign post changed, save two responses from the same detail action, instagram.v2.fetch_post_info or instagram.v3.get_post_info. Check that both responses describe the same shortcode and account, export each response to a CSV with instagram_snapshot.py, and calculate the changes locally with compare_instagram.py. If you have only one response, keep the response as the baseline for the next observation.
For example, for a launch Reel, record likes, comments and plays on launch day and check again the next day. Give the team both observation times, the counts, the net changes and the sources.
Which question are you answering?
Deliver two snapshots, the original responses and a change report with the before and after values, net changes, elapsed time and availability of each counter. A photo without play data can still be compared by likes and comments.
How do I brief an assistant?
Save this campaign Reel’s current engagement with shortcode, caption, account and query time. Once another observation of the same item is available, compare net changes in likes, comments and plays with both sources. List unavailable values and state the observation interval.
instagram_snapshot.py saves one post, and compare_instagram.py compares two saved observations. You schedule the later retrieval yourself; neither script installs a scheduler. Each detail request is charged at the current pricing; the local comparison needs no additional detail request.
1. Prepare the target and budget
Prepare the post link and its shortcode for data:instagram.v2.fetch_post_info. Save the first observation now, and use the same detail action for the later observation so the two records are comparable. If you already have a valid response, start at step 3.
2. Retrieve and save the detail
Replace <post_url_or_shortcode> with your post. On an HTTP failure, keep the error output and stop. After an HTTP success, still check the business status in response.json. Keep the raw JSON and the request_id for traceability.
3. Export the requested post
Save the script below as instagram_snapshot.py and run it with Python 3. The input is the direct /v1/social-data/call response. The script reads action to choose v2 data.data or v3 data.items[], then requires exactly one item whose code matches. The script keeps zero and missing values distinct, escapes text that starts with a formula character and refuses to overwrite an existing CSV.
4. Run and check the result
Check code and username against your source URL; rows should be 1. v2 counters come from the metrics object; v3 counters sit on the item itself. caption is the post text, not a transcript. taken_at is the publication time, not the collection time, so record the collection time separately in your collection manifest. If the export fails, read the error instead of producing a zero-engagement row.
5. Collect the second snapshot without overwriting the first
For the next query, use a new filename and record the collection time. Compare likes, comments and plays only between valid snapshots of the same code, and leave missing counters out of the differences. Plays are not unique reach, and a difference is not follower growth. Keep both raw responses before comparing, and never overwrite an earlier snapshot.
Detail inputs · Metric paths · Similar accounts
Sources: the gateway output contracts for data:instagram.v2.fetch_post_info and data:instagram.v3.get_post_info and the current response rendering.
6. Answer “How much did this Reel change after the first snapshot?”
compare_instagram.py compares two saved CSV snapshots locally, without another request. Both snapshots must come from the same shortcode and the same detail action. Pass the actual API query times, not file modification times. Missing plays on a photo stay missing, and a zero baseline does not produce an infinite growth rate. compare_instagram.py reports net changes, including downward revisions; the net changes are not new followers, unique reach or attributed campaign impact.
Save the script below as compare_instagram.py and run python3 compare_instagram.py instagram-snapshot-1.csv 2026-11-16T10:00:00Z instagram-snapshot-2.csv 2026-11-17T10:00:00Z instagram-change.json, replacing the example times with your query times. instagram-change.json contains both sources, both request IDs, the elapsed observation time and the before, after and change values for each counter. Different targets, reversed times, invalid counts or an existing output file stop the script. To compare different posts, collect each post at the same age after publication instead of ranking current totals.
Evidence check before sending the change report
instagram_snapshot.py records the raw response’s absolute path and SHA-256 in the CSV. compare_instagram.py re-reads both raw files and verifies the status, action, request ID, shortcode, generic post ID and all three counters. An edited CSV count, a substituted response or changed source bytes stop the report. A CSV exported without the hash must be re-exported from its saved JSON; re-exporting makes no new API call. Keep the raw files at the recorded paths, or re-export after moving the raw files.
The hash detects changes relative to the saved CSV; the hash is not a server signature and cannot prove that a CSV and JSON edited together are authentic. The query times are recorded by the caller. caption and username are context; compare_instagram.py does not verify them. The generic id column is not the numeric media_id that comment requests need; for comments, use the detail-to-comments handoff.
For a client report, attach both source JSON files, the two CSVs and instagram-change.json. Write: “Over this recorded observation interval, this post’s reported likes changed from A to B, a net change of B−A.” Keep a missing metric as unavailable, explain negative revisions, and do not label the difference as reach, conversions or paid-campaign lift. Neither local script sends a request.
Put the follow-up request in a different directory such as instagram-query-2; the mkdir ... && curl ... command stops when the directory already exists instead of overwriting earlier evidence. Record each query’s actual timezone-aware time when you collect the response, not the later CSV export time. A failed curl can leave error headers and an error body for diagnosis; those files are not a successful snapshot.
Why does an apparently numeric value stop the report?
Each count must be a nonnegative JSON integer within the exact safe-integer range, or an original ASCII digit string. 0 stays zero, and a missing counter stays unavailable. Decimal or exponent strings, floats, booleans, rounded display labels and integers outside the safe range stop both the export and the comparison; never convert such values to zero or strip punctuation from them. An original digit string above the safe-integer limit stays exact in Python. A generic post ID must not be rebuilt from a rounded number either.
If a file fails the count check, keep the file and record “not comparable: invalid or precision-unsafe source value”. Do not edit the raw JSON and its hash to force a client result, and do not spend on another call automatically. To compare against an older snapshot, re-export the older snapshot from its saved raw response first. A response with a successful outer status and a non-null error is rejected by both scripts.

