How to calculate an Instagram engagement rate in Python
Checked on 2026-11-19.
An engagement rate is interactions divided by an audience, times 100. The versions differ in what they take as the audience: followers, reach or views. For an account you do not own only the follower and view versions can be computed, because reach is private. Here are the formulas, where each number comes from, and Python code for both cases.
The formulas, and which is which
The names in quotation marks are the ones Hootsuite's guide to these formulas uses.
| Name | Formula | Who can compute it |
|---|---|---|
| By followers ("ER post") | engagements on a post / followers × 100 | Anyone: both numbers are public |
| By reach ("ERR") | engagements on a post / reach of that post × 100 | The account's owner |
| By impressions ("ER impressions") | engagements on a post / impressions × 100 | The account's owner |
| By views ("ER views") | engagements on a video / video views × 100 | Anyone, for Reels that show their plays |
| Daily ("Daily ER") | engagements in a day / followers × 100 | The account's owner |
Two things decide what a quoted rate means. The first is the audience in the lower half of the fraction. The second is what counts as an engagement: Hootsuite defines it as "any action someone takes to interact with your content, including likes, comments, shares, saves". On a public profile only likes and comments are visible, so a rate computed from outside counts those two, and it is lower than the same formula with saves and shares added. Always say which formula and which interactions you used.
You will find no "good engagement rate" figure here. Published benchmarks mix formulas and samples, so a number is only comparable with numbers made the same way. Compare accounts of similar size with one formula.
Where the numbers come from
- Followers: on the public profile.
- Likes and comments of recent posts: public, unless the owner hides like counts. Meta's reference says of its own field that
like_count"is omitted if the media owner has hidden like counts". - Plays of Reels: part of what a public profile shows for its Reels; the profile endpoint below returns them as
playCount. - Reach, saves and shares: only in the Insights of your own professional account, as the metrics
reach,saved,sharesandtotal_interactions. Meta's reference notes thatsaved_countandshares_countare not accessible through Business Discovery, its endpoint for other people's accounts. Theimpressionsmetric is deprecated for media created after July 2, 2024.
Any public account: the rate by followers
The Pipefetch profile endpoint returns the exact follower count and the latest posts with their like and comment counts in one request, which is everything the first formula needs.
import os
import requests
res = requests.get(
"https://pipefetch.com/v1/instagram/profile",
params={"username": "nasa"},
headers={"x-api-key": os.environ["PIPEFETCH_API_KEY"]},
timeout=90,
)
if res.status_code == 404:
raise SystemExit("No such account") # not charged
res.raise_for_status()
profile = res.json()["data"]
followers = profile["followerCount"]
posts = [p for p in profile["latestPosts"] if not p["isPinned"] and p["likeCount"] is not None]
if not followers or not posts:
raise SystemExit("Not enough public numbers: private account, no posts or hidden like counts")
avg_likes = sum(p["likeCount"] for p in posts) / len(posts)
avg_comments = sum(p["commentCount"] or 0 for p in posts) / len(posts)
rate = (avg_likes + avg_comments) / followers * 100
print(f"{rate:.3f} % by followers, over {len(posts)} posts")
print(profile["engagementRate"], profile["avgLikes"], profile["avgComments"]) # the same, precomputedThe endpoint already returns this figure as engagementRate, next to avgLikes, avgComments, avgPlays and postsPerWeek. The value is a percentage: 0.088 means 0.088 %. Like the code above, it leaves pinned posts out of the average as long as at least three other posts remain, since a pinned post is an old pick that stays on top. In the example answer on the reference page, nasa read on 18 November 2026, that is 104,328,951 followers and, over 14 posts, an average of 90,661 likes and 1,362 comments: 0.088 %.
For Reels the same answer has the plays, so the rate by views is a few more lines:
for reel in posts:
if reel["isReel"] and reel["playCount"]:
by_views = (reel["likeCount"] + (reel["commentCount"] or 0)) / reel["playCount"] * 100
print(reel["url"], f"{by_views:.2f} % by views")Where it stops: the sample is what Instagram shows without a login, about the 12 latest Reels and the newest grid posts, not the full history. When the owner hides like counts, engagementRate is null and the code above stops; a private account returns no posts at all. Saves, shares and reach are not public, so they are not in the answer. A profile costs 2 credits, an account that does not exist answers 404 and costs nothing, and a new account has 100 free credits and needs no card. Pipefetch is not an official API and is not affiliated with Instagram or Meta.
Business and creator accounts: the official route
Meta's Business Discovery returns the follower count and the like and comment counts of another account's posts, if that account is a business or creator account and you have a professional account, a Meta app and a token of your own. The request joins the two field lists of Meta's examples:
import os
import requests
ME = os.environ["IG_ACCOUNT_ID"] # the ID of your own professional account
fields = "business_discovery.username(bluebottle){followers_count,media{like_count,comments_count}}"
res = requests.get(
f"https://graph.facebook.com/v27.0/{ME}",
params={"fields": fields, "access_token": os.environ["IG_ACCESS_TOKEN"]},
timeout=30,
)
found = res.json()["business_discovery"]
media = [m for m in found["media"]["data"] if "like_count" in m] # left out when likes are hidden
if media:
engagements = sum(m["like_count"] + m.get("comments_count", 0) for m in media)
print(engagements / len(media) / found["followers_count"] * 100)This reads the first page of the account's posts; further pages take the after cursor of the answer. Personal accounts are out of its reach. The guide on follower counts lists what the setup takes.
Your own account: the rate by reach
For an account you run, Insights has the numbers nobody else sees. Per post, total_interactions counts likes, saves, comments and shares, and reach is the number of unique users who saw it at least once. On the Unified Login setup the token needs the instagram_basic and instagram_manage_insights permissions.
import os
import requests
media_id = os.environ["IG_MEDIA_ID"] # the ID of one of your own posts
res = requests.get(
f"https://graph.facebook.com/v27.0/{media_id}/insights",
params={"metric": "reach,total_interactions", "access_token": os.environ["IG_ACCESS_TOKEN"]},
timeout=30,
)
metrics = {m["name"]: m["values"][0]["value"] for m in res.json()["data"]}
print(metrics["total_interactions"] / metrics["reach"] * 100)Meta notes that the data behind these metrics can be delayed by up to 48 hours, and that reach is an estimate. The reference lists the host and the permission names of the two older setups, which differ.
Which one should you use?
| Situation | Formula | Numbers from |
|---|---|---|
| Vetting or comparing accounts you do not run | By followers, by views for Reels | An HTTP API such as Pipefetch, or Business Discovery for business and creator accounts |
| Reporting on your own account | By reach | Insights in the official API |
| Comparing your account with others | By followers for all of them, yours included | The same source for every account |
What skews the number
- Fresh posts. A post from an hour ago is still collecting likes. Use
publishedAtto leave out posts younger than a cut-off you choose. - Mixed formats. One average over Reels and photos hides the difference between them.
isReellets you compute a rate per format. - Paid posts.
isPaidPartnershipmarks posts labelled as paid partnerships, if you want organic posts only. - A small sample. A dozen posts with one outlier give a different picture than a quarter of posts. Store each reading and average over time.
To compare the accounts of a niche, the search endpoint returns business and creator accounts named after a keyword with their follower counts, for 1 credit; it asks the advertiser search of Meta's Ad Library and is not the search of the Instagram app. Each account you then read in full is one profile request.
Try it with 100 free credits. No card needed. No login, cookies or proxies. Get an API key or read the docs.
Free tools for this
APIs used in this guide
-
2 credits
Instagram Profile API
Exact followers, bio, links, account type and engagement of a public Instagram account, with its latest posts and Reels.
GET /v1/instagram/profile -
1 credit
Instagram Search API
Instagram business and creator accounts named after a keyword, with follower counts, or the hashtags for a word with post counts.
GET /v1/instagram/search
More Instagram guides
- How to get an Instagram follower count in Python
- Instagram Basic Display API alternatives: what to use after the shutdown
- Instaloader 401 Unauthorized, 429 and "Login required": what to do
- How to get an Instagram follower count in Node.js
- How to get Instagram follower counts in Google Sheets
- How to get Instagram Reel views in Python
Guides for other sources
Every source
YouTube
- How to get a YouTube transcript in Python
- How to get a YouTube transcript in Node.js
- YouTube API quota exceeded: what the error means and how to fix it
- How to find a YouTube channel ID from a handle or URL
- How to download YouTube subtitles as SRT or VTT
- youtube-transcript-api RequestBlocked or IpBlocked: why it happens and how to fix it
- How to get YouTube comments in Python
- How to search YouTube from Python
- How to list a YouTube channel's videos in Python
- How to summarize a YouTube video with an LLM in Python
- How to get YouTube transcripts and video stats in Google Sheets
- How to get YouTube video views and likes in Python
- How to get YouTube transcripts in n8n, Make and Zapier
- LangChain YoutubeLoader fails on a server: why, and a loader that works
- How to get a YouTube channel's subscriber count in Python
- How to give Claude or Cursor access to YouTube (MCP server)
- How to get YouTube comments in Node.js
- How to analyze YouTube comments with an LLM in Python
- How to list a YouTube channel's Shorts in Python
- How to search YouTube from JavaScript
Websites
- Clearbit Logo API alternatives: get a company logo from its domain
- How to extract email addresses from a website in Python
- How to turn a web page into Markdown in Python
- How to detect what a website is built with, in Python
- How to get the contact emails and phone numbers of websites in Google Sheets
- How to build a LangChain tool that reads web pages and searches Google
- How to turn a web page into Markdown in JavaScript for RAG
- How to extract social media links from a website in Python
- How to get a website's favicon in Python
- How to check robots.txt in Python before you fetch a page
TikTok
- How to get a TikTok video's views and likes in Python
- How to get the comments of a TikTok video in Python
- How to get a TikTok follower count in Python
- TikTok Research API: who can get access, and what to do if you cannot
- How to get TikTok video views, likes and shares in Node.js
- How to get TikTok views, likes and follower counts in Google Sheets
- How to get a Facebook Page's posts without app review
- Is there a Facebook Marketplace API?
- Facebook Groups API alternatives after its removal in 2024
- How to get a Facebook Page's follower count and contact details in Python
- How to get Google search results in Python
- pytrends 429 TooManyRequestsError: what it means and what to do
- How to get Google Trends data in Python
- Why is Wyoming first in Google Trends?
- How to get Google search results in Node.js
- How to get Google search results into Google Sheets
- How to give an LLM live Google results with tool calling
Threads
- How to get LinkedIn company data in Python
- How to search LinkedIn jobs from Python
- How to get a LinkedIn company page's latest posts in Python