The first time I tried putting together a monthly Instagram report, I realized how much time I was wasting collecting information manually.
I had to check different accounts, look through posts, collect engagement numbers, and organize everything into something presentable. It wasn't particularly difficult, but repeating the same process every month for freelance SMM clients quickly became boring.
I thought: why not automate most of it?
So I started building a small Python tool that collects Instagram data and prepares monthly statistics reports.
The idea behind the tool
I didn't want to build a full social media management platform. I wanted something relatively simple:
Retrieve basic Instagram account information.
Collect available post and highlight data.
Organize engagement statistics.
Compare activity between reporting periods.
Generate a report that I could review before sending it to a client.
Eventually, I decided to connect everything to a Telegram bot. That way, I could request information without opening a separate dashboard.
Choosing how to collect the data
My first thought was to use Python requests and scrape Instagram directly.
I'd done some experiments with scraping before, but maintaining everything became frustrating. Sessions expired, requests occasionally failed, and rate limits made repeated collection unpredictable.
I considered building my own proxy infrastructure, but that meant spending more time maintaining the scraper.
I wanted to focus on the actual reporting logic instead.
That's when I started experimenting with HikerAPI, a hosted REST API for retrieving Instagram data.
The idea was straightforward: send an authenticated HTTP request, receive JSON, and process the response in Python.
Making the first API request
I started by testing the account information endpoint.
Here's the basic request:
import requests
headers = {"x-access-key": "YOUR_KEY"}
user = requests.get(
"https://api.hikerapi.com/v2/user/by/username?username=nasa",
headers=headers
).json()
r = requests.get(
f"https://api.hikerapi.com/v2/user/highlights?user_id={user['pk']}",
headers=headers
)
print(r.json())
This retrieves account information and then uses the returned user ID to request highlights.
I used this as an initial test to understand the response structure and how different endpoints could fit into the project.
For the actual reporting system, I would also need to collect post-level information and make sure the metrics were available for the accounts being analyzed.
Turning the data into monthly reports
This was where things became more interesting.
Collecting JSON responses is one thing. Turning them into useful statistics is another.
I decided to keep the processing separate from the API requests.
For example, a basic engagement calculation could look like this:
def calculate_engagement(likes, comments, followers):
if not followers:
return 0
return round(
((likes + comments) / followers) * 100,
2
)
For each post, I wanted to store its publication date, likes, comments, and other available metrics.
Then I could group posts by month and calculate:
Total posts published.
Average likes per post.
Average comments per post.
Average engagement rate.
Best-performing posts.
Changes compared with the previous month.
I also wanted to avoid treating missing metrics as zero because that could distort the results.
Connecting everything to Telegram
I chose Telegram because it was convenient for requesting reports.
The general workflow became:
Send an Instagram username to the bot.
Retrieve the account information.
Collect the available statistics.
Process the data using Python.
Generate a monthly report.
Send the report back as a file or formatted message.
I kept the bot separate from the data-processing code. This makes it easier to change the API integration without rewriting the Telegram interface.
What was harder than expected?
Honestly, it wasn't making API requests. That part was relatively straightforward.
The harder part was making monthly comparisons meaningful.
For example, an account might publish fewer posts this month but receive more engagement per post. Looking only at total likes would give a misleading impression.
I also had to consider that follower counts change, older posts have had more time to accumulate engagement, and not every metric is necessarily available through every endpoint.
Another important distinction: likes and comments are not reach or impressions. I don't want to present engagement statistics as actual reach when those metrics aren't available.
Is using a hosted API worth it?
HikerAPI pricing starts at $0.001 per request, with 100 free requests available.
Building your own scraper might be cheaper if you already have the infrastructure and experience to maintain it.
However, maintaining authentication, proxies, and scraping logic also takes development time. For this project, I preferred spending more time on reporting and less time troubleshooting data collection.
Of course, using a hosted API doesn't guarantee uninterrupted access or eliminate rate limits. It's still important to handle errors, respect applicable access restrictions, and avoid assuming every request will succeed.
What's next?
I'd like to improve the reporting system with historical comparisons, automatic monthly report generation, and charts showing account performance over time.
I also want to make the reports more useful rather than simply filling them with numbers.
The main lesson so far is that automating data collection is only the beginning. The real value comes from turning that data into information someone can actually use.
Have you built anything similar for Instagram reporting? I'm particularly interested in how other developers store historical statistics and handle monthly comparisons.
Top comments (0)