DEV Community

What I Learned After My Instagram Scraper Broke While Vetting Influencers

What I Learned After My Instagram Scraper Broke While Vetting Influencers

When I was checking Instagram profiles before paying influencers, my previous approach eventually broke. The problem wasn't the Python code itself—it was the usual scraping problems: requests failing, changes on the platform side, and more maintenance than I wanted for a fairly simple task.

I only needed profile data. I didn't need another project maintaining a scraper.

So I switched to an API approach with HikerAPI, a REST Instagram API starting at $0.001 per request with 100 free requests.

What You Need

You need Python, the requests package, and an HikerAPI access key.

Install requests if it isn't already installed:

pip install requests

Then the actual request is only a few lines:

import requests

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

r = requests.get(
"https://api.hikerapi.com/v2/user/by/username",
params={"username": "natgeo"},
headers=headers
)

print(r.json())

The API returns the profile information as JSON, which makes it straightforward to inspect or pass into the rest of a Python workflow.

Using the Response

Because the response is JSON, I can store it in a variable and access individual fields when needed:

import requests

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

r = requests.get(
"https://api.hikerapi.com/v2/user/by/username",
params={"username": "natgeo"},
headers=headers
)

data = r.json()

print("Username:", data.get("username"))
print("User ID:", data.get("pk"))
print("Followers:", data.get("follower_count"))

The exact fields available depend on the response, so I usually print the JSON first when I'm building a new script.

For influencer vetting, this is enough to make profile lookups part of a larger workflow without manually opening every profile and copying information.

Why I Prefer This Approach

The main lesson for me was that scraping and using an API solve different problems: scraping means maintaining the collection mechanism yourself, while an API gives me a defined interface for requesting the data.

For a small marketing workflow, that trade-off is useful. I can keep the Python code short, make requests when I actually need them, and spend less time debugging the collection layer.

Tags: #python #api #beginners

Top comments (0)