Help Pulling Instagram Reels data through a scraping API
I'm building Shotery, a tool that tells people who make short-form video (coaches, consultants, founders) what to film next. The core of it is pretty simple: find Reels in a niche that did way better than that account usually does, then read the comments under them to find questions nobody answered yet. Those questions become video ideas.
To do that I need public Instagram data, and I didn't want to maintain my own scraper. So it goes through a third-party API. Here's what I needed, what I looked at, and the stuff that bit me along the way.
What I needed
Five calls, nothing exotic:
What Why
Profile by username Follower count, bio, the account's ID
Related / suggested profiles Find other accounts in the same niche
An account's Reels Views per Reel, to find the outliers
A single Reel by shortcode When someone pastes a link
Comments on a Reel The unanswered questions
What I looked at first
RapidAPI. The free tier on the Instagram API I found gave 20 requests a month. That's one test run.
Apify. The actor from that same vendor was marked deprecated. I didn't want to build on top of that.
Rolling my own. For a solo project, no. I'd be spending my time on logins and blocks instead of the product.
I ended up on HikerAPI with a prepaid balance. For the endpoints I use it works out to roughly $0.60 to $1 per 1,000 requests, and the balance doesn't expire, which matters when you're not hitting the API every day. It also had the related-profiles endpoint, which is the one I couldn't find elsewhere.
One honest caveat: I've made about 74 calls so far. This is what I learned building the integration, not a load test.
- Media IDs are 19 digits and JavaScript will quietly break them Instagram media IDs don't fit in a JavaScript number. JSON.parse doesn't throw, it just rounds:
JSON.parse('{"id": 3512345678901234567}').id
// 3512345678901234700
Anything above Number.MAX_SAFE_INTEGER (9,007,199,254,740,991) gets rounded, so you store an ID that's almost right, and the next call with it fails. The v2 endpoints accept safe_int=true and send big IDs as strings. I add it to every v2 request:
const query = path.startsWith("/v2/") ? { ...params, safe_int: "true" } : params;
Some media objects also carry an id like "_" as a string. Splitting on _ gives you a safe media ID without relying on the number at all.
- The response shape didn't match the docs example For the Reel-by-shortcode endpoint, the docs example shows an items array. What I actually got back was { media_or_ad: {...}, status }. I now read both:
const media = res.media_or_ad ?? res.items?.[0];
General lesson: write your parser against real responses, save one of each, and note the date you checked. Docs drift.
Related profiles come back without follower counts
The suggested-profiles endpoint gives you usernames, bios and avatars, but no follower count. If you filter accounts by size, that's one more profile call per account. I store followers: null for "unknown" instead of 0, so the app doesn't treat a big account as a tiny one before I've looked it up.4xx responses are billed, 5xx aren't
A 404 for a username with a typo costs the same as a successful call. So:
Clean input before you call (strip the @, lowercase the username, validate the shortcode).
Don't retry 4xx. Retry 429 (rate limit) and 5xx only.
Map status codes to errors your app understands: 402 means the balance ran out, 401/403 means the key is wrong. Neither should be retried in a loop.
- play_count includes replays play_count is the number Instagram shows on the Reel, and it counts replays. That's fine for comparing Reels against each other (which is what outlier detection does), but don't present it as unique viewers.
Keeping a small balance alive
With a prepaid balance, the risk isn't one expensive call. It's a background job quietly doing a thousand cheap ones. Two things helped:
Every request is logged against the user and the operation that triggered it. That gives me a per-user daily spend, and the scheduler stops when it hits a cap.
The provider sits behind an interface, with a mock implementation for local development. Day-to-day dev work doesn't spend any credits, and if I ever need to switch providers it's one new adapter. RocketAPI is my noted fallback; they only bill 200 and 404 responses, which is a nicer model when you're exploring.
Even with all that, I got a "your balance is $0.52" email this morning. So, top-up alerts: worth setting up.
What I'd tell myself at the start
Save real responses on day one and parse against those, not the docs.
Treat IDs as strings everywhere: database, URLs, logs.
Count cost per request from the first commit, not after the first surprise.
Accept the tradeoff: a third-party scraping API depends on Instagram not changing things under it. Keep the adapter thin so you can swap it.
If you're building something similar, happy to compare notes in the comments, especially on outlier scoring.
I'm part of HikerAPI's user-rewards program — they credit my account for posts like this. Sharing my actual experience.
原文:https://www.a8q9.cn/en/article/help-pulling-instagram-reels-data-through-a-scraping-api-e19cbc.html