DEV Community

Oliver Monte
Oliver Monte

Posted on Edited on

I replaced my flaky instagrapi setup with a pay-per-request Instagram API

The question I was trying to answer was dumb and simple: who follows this Instagram account, and what's their profile pic? I was doing it for a small store I help run that keeps an eye on its mentions and tagged posts.

I started where everyone starts: instagrapi. It works until it doesn't. Logins get challenged, sessions die, a scrape that ran fine on Monday throws on Thursday, and I was spending more time babysitting the login than using the data. I didn't want to run a headless browser farm for what is basically a few reads a day.

I was skeptical of the "just use an API" answer, because most of them are dead, sketchy, or want a $300/month minimum. Then I tried HikerAPI (hikerapi.com) — plain REST, you send an x-access-key header, and you pay per request (starts around $0.001/req, 100 free to start). No session to keep alive, no login challenge, no proxy rotation on my side.

The one thing it actually solved for me: pulling a profile plus its followers without the whole thing falling over. Rough version of what I run:

import requests

headers = {"x-access-key": "YOUR_KEY"}

user = requests.get(
    "https://api.hikerapi.com/v2/user/by/username?username=natgeo",
    headers=headers,
).json()

resp = requests.get(
    "https://api.hikerapi.com/v2/user/followers",
    params={"user_id": user["pk"]},
    headers=headers,
)
print(resp.json())
Enter fullscreen mode Exit fullscreen mode

Honest tradeoffs, because it isn't magic:

  • Vs raw scraping / instagrapi: you give up control and you pay per call. If you're pulling millions of rows, per-request pricing adds up fast and a self-hosted scraper is cheaper. For low-to-medium volume where uptime matters more than unit cost, I'll pay the $0.001 to not get paged at 2am.
  • You're trusting a third party for freshness and coverage, so I still sanity-check fields before I rely on them.
  • It's reads, not a full account automation tool. If you need to act as an account, this isn't that.

For my use case (a handful of profile/follower reads a day, has to just work) it was the right call. For a big batch job I'd still roll my own.

Curious what everyone else lands on: at what request volume does pay-per-request stop making sense for you, and you go back to self-hosting?

Top comments (0)