Hashtag research tells you what content works in a niche, which creators are active and how a campaign is spreading. Doing it by hand does not scale. This guide shows how to collect and compare hashtag data with the Hashtag API, step by step.
What you get
For a hashtag, the API returns the popular posts and reels Instagram shows for it: thumbnail, caption, author, likes and a permalink, with a cursor to page further. It is a sample of the best-performing content, which is exactly what research needs. It is not a list of every post that ever used the tag.
The Hashtag API is available on paid plans and costs 3 credits per call.
Step 1: pull the top content for a tag
import os
import requests
HEADERS = {"Authorization": f"Bearer {os.environ['IGRAMAPI_KEY']}"}
def hashtag(tag, limit=24, cursor=None):
params = {"limit": limit}
if cursor:
params["cursor"] = cursor
r = requests.get(f"https://api.igramapi.com/v1/hashtags/{tag}", headers=HEADERS, params=params, timeout=30)
r.raise_for_status()
return r.json()
data = hashtag("streetphotography")
for item in data["items"][:5]:
print(item["author"], item["like_count"], item["permalink"])
Step 2: find the active creators
Group the results by author to see who appears repeatedly. Then enrich each with the Profile API to learn their audience size and verification status:
from collections import Counter
authors = Counter(i["author"] for i in data["items"] if i["author"])
for username, count in authors.most_common(10):
profile = requests.get(
f"https://api.igramapi.com/v1/profiles/{username}", headers=HEADERS, timeout=30
).json()["profile"]
print(username, count, profile["followers"])
Step 3: compare hashtags
Run the same collection for several tags and compare average likes and the share of video content:
def summary(tag):
items = hashtag(tag, limit=50)["items"]
likes = [i["like_count"] for i in items if i["like_count"] is not None]
videos = sum(1 for i in items if i["media_type"] == "video")
return {
"tag": tag,
"avg_likes": round(sum(likes) / len(likes)) if likes else None,
"video_share": round(videos / len(items) * 100) if items else None,
}
for tag in ["streetphotography", "travelgram", "foodie"]:
print(summary(tag))
Step 4: track change over time
Run the collection on a schedule, for example daily, and store the shortcode list for each tag. New shortcodes at the top of the results show what is rising. Keep the date next to every snapshot, because the result set changes continuously.
Step 5: discover related tags
Use the Search API to find hashtags that match a keyword, including their post counts. Feed the best candidates back into step 1.
Plan your credits
Each hashtag call costs 3 credits. Tracking 50 tags once a day is 50 × 3 × 30 = 4,500 credits a month, well inside the Starter plan. Add paging and profile enrichment to your estimate.
Why not use the official hashtag search?
Meta’s official hashtag search needs app review and limits an account to 30 unique hashtags in a rolling seven days. That is hard to work with for broad research. The IGramAPI Hashtag API has no unique-hashtag cap, only your credits and rate limit. See Instagram Graph API limitations for the details.
Good practice
- Treat results as a sample of popular content, and say so in reports.
- Respect people’s privacy: aggregate where you can, and avoid storing more personal data than you need. See the Acceptable Use Policy.
- Add a short pause between pages and respect
Retry-After.
Related
Social media analytics · Brand and competitor monitoring · Pagination