Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 5 min read

Can I Track Instagram Follower Growth Over Time Without Maintaining a Scraper?

My original Instagram tracking script broke when I tried to turn a few manual profile checks into a repeatable data collection process. At first, the idea was simple: record an Instagram account's follower count every d

My original Instagram tracking script broke when I tried to turn a few manual profile checks into a repeatable data collection process.

At first, the idea was simple: record an Instagram account's follower count every day and plot how it changes over time.

I wasn't building a full analytics platform. I just wanted a small side project that could answer a few questions:

How quickly is an account gaining or losing followers?

Are there noticeable spikes in follower growth?

Does posting frequency correlate with changes in follower count?

Can I collect this data consistently without maintaining a browser scraper?

The interesting part turned out to be less about plotting data and more about collecting it reliably.

Why My Initial Approach Wasn't Sustainable

My first approach involved checking public Instagram profiles and recording follower counts manually.

That was fine for occasional observations, but it wasn't useful for tracking trends.

I considered automating the process with browser scraping or instagrapi.

Both approaches have their advantages. Scraping gives more control over the extraction process, while instagrapi provides a Python interface for many Instagram operations.

However, I didn't want to maintain browser sessions, handle frequent frontend changes, or depend on an Instagram login for a simple analytics tool.

I started looking into hosted Instagram APIs instead.

One option I experimented with was HikerAPI, a REST Instagram API that uses an x-access-key header for authentication.

Its advertised pricing starts at $0.001 per request, with 100 free requests available for initial testing.

The appeal was straightforward: use HTTP requests for data collection and spend the rest of the time working on the analytics.

Step 1: Fetching Instagram Account Data

I started by checking whether I could retrieve structured information about a public Instagram account.

Here's a basic example that resolves a username and then requests its media:

import requests

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

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

r = requests.get(
f"https://api.hikerapi.com/v2/user/medias?user_id={user['pk']}",
headers=headers
)

print(r.json())

This example retrieves account information first, extracts the account ID, and uses that ID to request media.

For my follower-growth project, the main value was the initial account lookup. The media endpoint was useful for experimenting with posting activity, but it wasn't necessary for the basic follower chart.

I wanted to keep the first version simple.

Step 2: Building a Daily Follower Tracker

I created a Python script that requests the current account data and saves the follower count with a timestamp.

Instead of hardcoding the API key, I used an environment variable.

import os
import sqlite3
import requests
from datetime import datetime, timezone

API_KEY = os.environ["HIKERAPI_KEY"]
USERNAME = "natgeo"

url = "https://api.hikerapi.com/v2/user/by/username"

response = requests.get(
url,
params={"username": USERNAME},
headers={"x-access-key": API_KEY},
timeout=30
)

response.raise_for_status()
data = response.json()

followers = int(data["follower_count"])

with sqlite3.connect("followers.db") as conn:
conn.execute("""
CREATE TABLE IF NOT EXISTS follower_history (
username TEXT NOT NULL,
timestamp TEXT NOT NULL,
followers INTEGER NOT NULL
)
""")

conn.execute(
    """
    INSERT INTO follower_history
    (username, timestamp, followers)
    VALUES (?, ?, ?)
    """,
    (
        USERNAME,
        datetime.now(timezone.utc).isoformat(),
        followers
    )
)

print(f"{USERNAME}: {followers} followers")

The exact response structure should be checked against the API version being used. This example assumes the account response includes a top-level follower_count field.

I chose SQLite because I didn't need a separate database service.

Every execution adds a new historical observation rather than overwriting the previous value.

That distinction is important. A current follower count is only a snapshot. Growth analysis requires historical snapshots.

Step 3: Plotting Follower Growth

Once I had several observations stored in SQLite, I could visualize the history using Pandas and Matplotlib.

import sqlite3
import pandas as pd
import matplotlib.pyplot as plt

with sqlite3.connect("followers.db") as conn:
df = pd.read_sql_query(
"""
SELECT timestamp, followers
FROM follower_history
WHERE username = ?
ORDER BY timestamp
""",
conn,
params=("natgeo",)
)

df["timestamp"] = pd.to_datetime(df["timestamp"])

plt.figure(figsize=(10, 5))

plt.plot(
df["timestamp"],
df["followers"],
marker="o"
)

plt.title("Instagram Follower Growth")
plt.xlabel("Date")
plt.ylabel("Followers")
plt.grid(True)
plt.tight_layout()
plt.show()

At this point, the project had a basic workflow:

Fetch the latest public account information.

Store the follower count and collection timestamp.

Repeat the collection on a schedule.

Read historical observations from SQLite.

Plot follower growth over time.

I could schedule the collection script through cron or Windows Task Scheduler.

There was no need to keep a browser open or manually refresh profiles.

Step 4: Calculating Daily Changes

A follower-count chart shows the overall direction, but daily changes are often more interesting.

I added a simple calculation:

df["growth"] = df["followers"].diff()

df["growth_pct"] = (
df["followers"].pct_change() * 100
)

print(
df[["timestamp", "followers", "growth", "growth_pct"]]
.tail()
)

This made it easier to identify unusually large increases or decreases.

One limitation is that the calculation measures changes between observations, not necessarily calendar days.

If the script runs irregularly, the results need to be normalized by the time between samples.

I also avoided treating follower growth as evidence that a particular post caused the increase. That would require additional data and a more careful analysis.

Hosted API vs. Scraping vs. instagrapi

After experimenting with the architecture, I found the tradeoffs fairly clear.

Approach

Advantages

Limitations

Browser scraping

Full control over extraction logic

Fragile selectors, browser overhead, maintenance

instagrapi

Python-native Instagram interface

Login/session management and potential access restrictions

Hosted REST API

Structured responses, simple HTTP integration

Usage costs, provider dependency, API limits

A hosted API doesn't guarantee uninterrupted access to Instagram data.

The provider can experience outages, change response formats, or encounter upstream restrictions. Requests can fail, and some information may be unavailable.

For production use, I would add retries with exponential backoff, response validation, logging, and alerting when scheduled collection fails.

I'd also monitor API usage because even inexpensive requests create recurring costs when collection frequency and account counts increase.

What I'd Build Next

The current architecture is intentionally small: Python for collecting data, SQLite for historical storage, and Matplotlib for visualization.

The next improvements I'd consider are:

Tracking multiple public accounts in the same database.

Calculating rolling growth averages.

Identifying unusual follower-growth spikes.

Comparing growth with posting frequency.

Building a lightweight dashboard using Streamlit.

Adding automated checks for failed collection runs.

The most useful lesson from this experiment was that follower-growth tracking doesn't require an elaborate architecture.

It requires consistently collected observations, accurate timestamps, and a data model that preserves history.

Using a hosted API reduced the amount of Instagram-specific maintenance I needed to handle, but the responsibility for data quality, scheduling, and interpretation stayed with my application.

I'm curious how others approach this kind of project.

If you're tracking social media metrics over time, do you prefer collecting snapshots through an API, maintaining your own scraper, or using an existing analytics service?

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.