PHII Labs
Inst Helper: Hashtag Video Analytics
2024Social

Inst Helper: Hashtag Video Analytics

Problem

No easy way to analyze all videos for a hashtag and get analytics in Telegram.

Solution

Bot fetches, paginates, and analyzes all hashtag videos using HikerAPI, reporting results in Telegram.

Result

  • Automated hashtag analytics
  • Telegram chat integration
  • Handles large datasets

Stack

Pythonpython-telegram-botrequests

Inst Helper: Hashtag Video Analytics

Instagram hashtags are a discovery surface, but Instagram's own interface gives you no aggregate view. You can scroll a hashtag page and see individual posts, but you cannot get the full set of videos for a hashtag, their engagement metrics, and a summary of the distribution. For a social media analyst or a content strategist, the question is never "show me one video" — it is "what does the whole hashtag look like?"

The problem

The task was to take a hashtag, fetch every video tagged with it, and report aggregate analytics back to the user in Telegram. The constraints: Instagram does not expose a public API for hashtag media, the result set can be large (thousands of videos for a popular hashtag), and the user wants the answer in a chat, not a dashboard.

This means three hard problems stacked: retrieving all the media for a hashtag via pagination through an unofficial endpoint, handling the volume without timing out or getting rate-limited, and turning a large raw dataset into a compact summary that fits in a Telegram message.

The approach

We built a Telegram bot on python-telegram-bot that uses HikerAPI as the backend for Instagram data. The stack is minimal: Python, python-telegram-bot for the chat interface, requests for HTTP calls to HikerAPI. No database, no queue, no web frontend. The bot is the entire product.

The flow is user-driven. A user sends a hashtag to the bot. The bot issues the first request to HikerAPI for that hashtag's media, then follows pagination tokens until it has exhausted the result set. Every page of results is parsed into a normalized record: video URL, view count, like count, comment count, upload timestamp, author. The bot accumulates all records in memory for the duration of the request.

Pagination is the part that breaks naive implementations. HikerAPI returns pages with a cursor; the bot follows every cursor until the API returns an empty page or the cursor stops advancing. For a hashtag with 5,000 videos, that is dozens of sequential HTTP calls. The bot does not parallelize them — the cursor for page N depends on page N-1's response — so it walks the chain linearly and reports progress to the user as it goes. A user who kicks off a large hashtag query gets a "fetching page 12 of ~80" message so the bot does not appear to hang.

Once the full set is collected, the bot computes the summary: total video count, median and mean views, median and mean likes, top 10 videos by view count, most prolific authors, and a rough upload-date distribution. This is the payload that goes back to the Telegram chat — not the raw dataset, but the aggregates a strategist actually reads.

What was built

A Telegram bot that accepts a hashtag and returns a structured analytics summary in chat. The bot handles the full lifecycle: parse the user's request, paginate through HikerAPI until the hashtag is exhausted, compute aggregates, and format the result as a Telegram message with the top videos linked.

The formatting is deliberate. A raw dump of 3,000 records is useless in a chat. The bot returns a summary block — counts, medians, top performers — followed by links to the top 10 videos by engagement. The default response is the summary, because that is what answers the question "what does this hashtag look like?"

Progress reporting was a design decision. A large hashtag can take several minutes to fully paginate. Without intermediate messages, the user assumes the bot died. With them, the user sees the fetch is alive and roughly how long it will take.

Results

  • Automated hashtag analytics for any hashtag the user submits, with the full video set retrieved via paginated HikerAPI calls.
  • Telegram chat integration — the user sends a hashtag, the bot returns a summary, no dashboard or login required.
  • Handles large datasets — thousands of videos per hashtag, paginated sequentially with progress reporting so the user is never left staring at a silent bot.

The bot runs as a single process. State is ephemeral — each request is independent, and nothing is persisted between queries. The product is the summary, not a historical archive. If a user wants to re-analyze a hashtag, they send it again.

The takeaway

The hard part of hashtag analytics is not the math — medians and top-10 lists are trivial. The hard part is getting the data: paginating an unofficial API reliably and without losing the user's trust during a long fetch. The design choices that made this work were sequential pagination with progress messages, and returning a summary instead of a dump. Users do not want a spreadsheet in a chat. They want the answer.

Want something similar?

Share your workflow and we will show where AI systems can make it stronger.